Sign in to follow this  
md_lasalle

Outgoing connection problem

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this