January 10th, 2009, 03:44 PM
Slow socket performance
This is a pretty long and sordid tale...
I am frustrated. Immensely so. I'm in the process of creating a small, multi-player MUD-like game. I have done so before without much trouble. This game is being designed with a Flex-based, web-accessible client application which then makes a TCP socket connection to a server currently running on my PC. The client app runs wonderfully. The server is where I'm running into problems...
If I test everything locally, it runs swiftly and responsively. Once I connect to it from somewhere outside my LAN, things go downhill. Data sent to the server from the client is received server-side immediately. Anything sent from the server to the client takes an absolutely unacceptable period of time. Sometimes 5-60 seconds for a single packet, sometimes it never gets there at all. This problem is also (mostly) language-independent. The vexing thing is that the send() call returns non-error values, indicating X number of bytes were sent, but the client still never gets the info. It's almost as though it's hanging out in the socket's send buffer and never actually getting sent out, despite what the send() function is saying. I understand that sometimes things can hang out in this buffered state for awhile before being sent off, but this is completely unrealistic and unacceptable performance.
To simplify the troubleshooting, I built a simple echo server that immediately echoes the client's input back to them in C++ and in Python with the same problem. In both languages I've used the select() function to allow for asynchronous input handling.
I've also created a simple threaded server that uses a block socket to listen for connections, and spawns a new thread for each connection, each thread using a blocking socket to constantly poll for input and echo it back right away, no use of the select() function. Same problem.
So, I tried a pre-written C# socket server that simple echoes input back. It works perfectly.. data is sent out and received by the client immediately after the call is made to send it.
Bypassed the router, disabled the firewall, made sure all my drivers were up to date, etc., same issue.
If I compile and run the C++ server code on a friend's computer (we're both using Visual Studio 2008), it works perfectly.
Also, setting or clearing the TCP_NODELAY option to disable/enable Nagle's algorithm has no effect.
So, this problem is local to my PC, and I'm at a complete loss as to what could cause it. I'm wondering if anyone here has any suggestions as to where to go next before I pull all my hair out. I can't see it being a hardware issue, as any other network applications I have installed send and receive data without a problem.
Any suggestions? Anyone else had the same or similar problems? Help!
Tags for this Thread
Click Here to Expand Forum to Full Width