sockets

Separate threads for socket input and output

I got assigned to work on some performance and random crashing issues of a multi-threaded java server. Even though threads and thread-safety are not really new topics for me, I found out designing a new multi-threaded application is probably half as difficult as trying to tweak some legacy code. I skimmed through some well known books in...

Non-blocking I/O versus using threads (How bad is context switching?)

We use sockets a lot in a program that I work on and we handle connections from up to about 100 machines simultaneously at times. We have a combination of non-blocking I/O in use with a state table to manage it and traditional Java sockets which use threads. We have quite a few problems with non-blocking sockets and I personally like...

Java GUI amd FPGA

Hi, I study on a robot simulator that written on Java environment.But sonar scan simulations and computational burden of some driven algorithms on robot drop my simulator's performance. So ı have decided to use fpga module and put the computational burden on it.I have spartan 3a development kit for this implemenatation. Does anyone ha...

Connect to a computer behind router in .net

We have a client server application which we are developing in .net. We want the server to push data to client. But the client is behind a router (like a home network setup). What are the various options to implement this in .net? ...

Threading and Sockets

I have the following: ThreadStart startThread = delegate { mySocket.StartListen(); }; mySocket is now looping on a Listen() when I: new Thread(startThread).Start(); Here is StartListen: public void StartListen() { Object locker = new Object(); // Lock resources lock (locker) { S = new System.N...

Should Sockets be secured

I am working on an update function for a pet project of mine, and was wondering if I need to spend the time to make sure my connections are secure? Basically the client sends the version number of the software on the users computer to a server, the server checks the users version against the latest version available, and if a newer vers...

Question about send / recv

New to socket programming. Got a couple questions: My program is really inconsistent with its output. Sometimes my client receives, sometimes it doesnt. I am also using the same input each time. Just need confirmation: Can the number of bytes received be less than the number of bytes sent from the server? How do I make it so that I st...

Maintaining many socket connections with a single thread

Many tutorials on socket communication I see seem to use 1 thread per socket. But on a server used for online gaming, you might have 10k concurrent users - 10k threads isn't probably a wonderful idea. I came across a tool (SmartFox) which claims to use a single thread for monitoring all socket connections, potentially thousands of them. ...

Error with parsing string and trying to find '\0' character

I'm trying to get one side to send an error message to client, but client isn't able to parse it correctly. My error is >>>>> in my parseString function, it lets index = 0 and therefore I get an out of range for my 'substr' call. Server Side::: #define ERRBUFSIZE 51 string error = "Error - Already Registered: "; erro...

How to check if port is available

Is there an API function on Linux (kernel 2.6.20) which can be used to check if a given TCP/IP port is used - bound and/or connected ? Is bind() the only solution (binding to the given port using a socket with the SO_REUSEADDR option, and then closing it) ? ...

How can I tell if there is data in an input filehandle's buffer in Perl?

I'm working on a program that uses an epoll-based event loop to handle multiple simultaneous socket connections. When the app detects that there is data to be read, it calls a process_request() sub, which uses buffered IO. For example: sub process_request { my ( $fh ) = @_; if ( my $line = <$fh> ) { # Do something inte...

What should be the maximum number of opened socket on a server?

For a web server, the socket connection are kept alive to save overhead. At which point the server should start to drop connection that doesn't have pending request and based on what premises? ...

Java web server and PDF files

I have created my own HTTP server. I need to return a PDF file (generated by Jasper Reports) to the web browser. However, when I read the PDF file and write its contents to the socket, the web browser receives a blank PDF file. When I save this file and compare it to the original, I see that many of the characters have been converted ...

Castor and sockets

I'm new to Castor and data binding in general. I'm working on an application that, in part, needs to take data off of a socket and unmarshall the data to make POJOs. Now, I've got the socket stuff down, and I've even generated and compiled java files thanks to Ant and Castor. Here's the problem: the data stream that I'll receive could b...

Linux socket value

I have a client-server program, on the server side: sockListen = socket(PF_INET, SOCK_STREAM, 0); socketListen always seems to equal 3. Why? how about 0, 1 or 2? What is the value range of sockets in Linux? ...

Reopen same socket for reuse C++

Hi I am having an application which listens on a particular RPC Port number say 10001 for connection with another device(hardware) using socket programming. Meanwhile the hardware device will be trying to establish connection to my IP and same port number 10001. So that way my application and the hardware are connected. Now assume i ...

APN Error in Server Script (php)

Hi All, I am getting this error in my php script , while sending payload data. Warning: stream_socket_client() [function.stream-socket-client]: Unable to set private key file `/Applications/XAMPP/xamppfiles/htdocs/test/apn/apns-dev.pem' in /Applications/XAMPP/xamppfiles/htdocs/test/apn/push.php on line 42 Warning: stream_socket_client...

Is there a way to manipulate udp packets after an application sends it to a socket?

In other words, can I intercept those packets (possibly at the stack level) using a separate application, manipulate them and then send them to the destination the original application was trying to send them to? ...

C++ HTTP / HTML Socket Question

I'm building an application which I'd like to have it connect to a website and parse some data off it. I'm wondering if anyone could provide me some raw example code. I don't necessarily need help parsing, I'm just wondering in C++ how would I go about downloading the data from the page into my app so that I can start parsing the data I...

General sockets UDP programming question

I have an FPGA device with which my code needs to talk. The protocol is as follows: I send a single non-zero byte (UDP) to turn on a feature. The FPGA board then begins spewing data on the port from which I sent. Do you see my dilemma? I know which port I sent the message to, but I do not know from which port I sent (is this port no...