Outgoing connection problem

Started by
6 comments, last by Evil Steve 17 years, 1 month ago
Hi all! I'm having troubles with my game server, well, not all of them are having the problem so that's why i post here so i can maybe get a light on this Every 20 seconds, the game server tries to establish a TCP connection with the master server to send its latest game infos. For some strange reasons, after some time, the call to connect() just fails after my predetermined timeout (10 seconds) why would connect() fail after sometime ? thanks for any help.
Advertisement
What language / OS? What does errno or WSAGetLastError (Or whatever the error reporting function for the platform you're using is) return?
it's running on linux (centOS 4.4) and im using C++ ( gcc 4.4 )

i'll check for error code as soon as i get the chance
If you want to send data every 20 seconds, why not just keep the connection open?

It may be that you're running out of some resource, such as available file descriptors, or have too many sockets waiting in TIME_WAIT, or something like that.
enum Bool { True, False, FileNotFound };
Quote:Original post by hplus0603
or have too many sockets waiting in TIME_WAIT, or something like that.


can you explain this a little more ?

When you close a default TCP socket it will wait for any errant data to be recved from the other end of the connection. This effectively leaves the socket open until the TIME_WAIT expires. You cannot open up and infinite number of sockets. 2^16 is the theortical limit.

I strongly recommend you leave the socket open until you are completely finished sending data for the sessions. The connection setup cost is sigificant when using TCP.
TIME_WAIT is defined to what and is there a way to set it up ?
Quote:Original post by md_lasalle
TIME_WAIT is defined to what and is there a way to set it up ?
TIME_WAIT is a TCP/IP state, like listening. You can alwayse use setsockopt() with SO_REUSEADDR to avoid the TIME_WAIT phase, but you should check if you really need to first.

This topic is closed to new replies.

Advertisement