sockets

New thread per client connection in socket server?

I am trying to optimize multiple connections per time to a TCP socket server. Is it considered good practice, or even rational to initiate a new thread in the listening server every time I receive a connection request? At what time should I begin to worry about a server based on this infrastructure? What is the maximum no of background...

How To Trace Win32 Socket Calls and Requests

How can I effectively trace the raw data sent to my socket server listening on a win32 machine? I want the trace to be specific to the port my server is listening on, so I can monitor only that traffic. I want to see how the data exchange works on the wire. ...

How To Read Data using Ip Address

I am doing punch card reader programming.. Establish connection with BioAccess V2 Device... socket successdully connected but data can't read... so how to read data ? Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream,ProtocolType.Tcp); var ipaddress = IPAddress.Parse("192.168.000.111"); IPAddress add = new IP...

Reusable socket

I tryed to create a socket in php and reuse it from other process. I know this can be done with a daemon script but I want to do this without. I created a socket and binded it to a specific port. $sock = socket_create (AF_INET, SOCK_STREAM, SOL_TCP); socket_set_option ($sock, SOL_SOCKET, SO_REUSEADDR, 1); socket_bind ($sock, 'xx.xx....

Ethernet Communication Error

Hi, I wrote a program to query the status of the Ethernet printer for that i created a TCP Stream Socket and i send the query command to the printer.In case of Error less condition it returns No error status but in error case its getting hang at recv command.Even i used Non blocking now the recv command returns nothing and error set as ...

How can I test TCP socket status in Perl?

I've got a TCP socket which reads data. When an error occurs when reading the data, I return an undef (NULL) value. Errors can be caused by badly formatted messages or broken sockets. Can someone tell me if there is a specific function which returns the status of a socket? ...

The Scala way to use one actor per socket connection

I am wondering how it is possible to avoid one socket connection pr. thread in Scala. I have thought a lot about it, but I always end up with some code which is listening for incoming data for each client connection. The problem is that I want to develop an application which should simultanously handle perhaps a couple of thousand conne...

Windows Phone 7 : Socket Programming

Is there any support for TCP/IP Sockets in Windows Phone 7? I'm not having any luck finding it so far. I want to connect to a port on a server and issue commands/receive responses ...

How to get fopen to timeout properly

hey all, I have the following snippet of php code if($fp = fopen($url, 'r')) { stream_set_timeout($fp, 1); stream_set_blocking($fp, 0); } $info = stream_get_meta_data($fp); I'd like the request to timeout after 1 second... if I put a sleep(20) in my $url that I'm reading it just waits the whole 20 seconds and never times out...

Sync Vs. Async Sockets Performance in .NET

Everything that I read about sockets in .NET says that the asynchronous pattern gives better performance (especially with the new SocketAsyncEventArgs which saves on the allocation). I think this makes sense if we're talking about a server with many client connections where its not possible to allocate one thread per connection. Then I...

inet_ntoa problem

Hi I am declaring following variables unsigned long dstAddr; unsigned long gateWay; unsigned long mask; These variables contains ipaddresses in network byte order. So when I am trying to print the dot notation using inet_ntoa function for mask variable sometimes it is printing strange values. The below code is in a while loop ....

How to handle Socket Exception ideally?

Hi, I'm using socket for chat application and I get SocketException unexpectedly. How this exception should ideally be handled? I'm currently simply reconnecting socket. How to make sure my socket is live on application level? I'm aware of method setKeepAlive ...

What to use instead of getaddrinfo() and freeaddrinfo() targetting legacy Windows?

By requirement, I'm targeting old legacy Windows systems (9x branch) where getaddrinfo() and freeaddrinfo() are not available. What can I use instead of that? The code I'm using right now is extracted from the MSDN site (I'm testing it in a Vista computer): ... /* WinSock data: */ WSADATA wsaData; /* Initialize the WinSock data: */ sho...

Is it possible to use connection proxies using sockets?

Hi, I need to connect to a server from an environment with a SSL proxy on, is it possible to handle that environment using just sockets? Is it was a no-SSL proxy, would that be possible? Thank you very much. ...

Should I use StreamReader/Writer with NetworkStream for C# server/client?

I'm in the process of building a client/server based game for a project(feeling quite out my depth). I've been using TCPclient and a multi-threaded socket server. Everything is working fine at the moment but I have been using StreamReader and StreamWriter to communicate between both client and server. I keep seeing examples like this fo...

Socket Sessions For Persistent Connections

I am developing a socket server where a client will be bound after being authenticated similar to SMPP. Is there support for cookies in this regard? How do you maintain a session for socket client that is "logged in"? ...

Sending the array of arbitrary length through a socket. Endianness.

Hi everyone, I'm fighting with socket programming now and I've encountered a problem, which I don't know how to solve in a portable way. The task is simple : I need to send the array of 16 bytes over the network, receive it in a client application and parse it. I know, there are functions like htonl, htons and so one to use with uint16 ...

Is there any way to use getaddrinfo() and freeaddrinfo() and still be the program compatible with legacy versions of Windows?

Hi, in the Winsock2 library getaddrinfo() and freeaddrinfo() was only added in Windows XP and on. I know how to replace them in legacy systems, but a conditional use depending on the Windows version won't help. The application won't start in 9x with a message saying that it was linked to a missing export in WS2_32.dll. I'm using MinGW ...

Spikes in Socket Performance

We are facing random spikes in high throughput transaction processing system using sockets for IPC. Below is the setup used for the run: The client opens and closes new connection for every transaction, and there are 4 exchanges between the server and the client. We have disabled the TIME_WAIT, by setting the socket linger (SO_LINGER)...

Async Socket Listener on separate thread - VB.net

I am trying to use the code from Microsoft for an Async Socket connection. It appears the listener runs in the main thread locking the GUI. I am new at both socket connections and multi-threading all at the same time. Having a hard time getting my mind wrapped around this all at once. The code used is at http://msdn.microsoft.com/en-us/...