Jump to content
  • Advertisement
Sign in to follow this  
Lesan

[.net] TCP: Closing connections without TIME_WAIT

This topic is 2703 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In my multiplayer game, the server remembers all data concerning the game and the clients (players) regularly ask the server for updates. Currently, I do this thus:

The server opens a single instance of the TCP listener class on a specified port. The clients, whenever they want to request updates, create a TCP Client object, send the request, wait for the server's response and then, when no more data are coming through, use the Close() method to close, then they interpret the response and when the time comes (say a second later), they create another TCP client object and repeat the process. The server calls "client.Close()" after it sends the response.

It worked, however, the connections remained open in the background, and netstat says their status is "TIME_WAIT". After a minute/several minutes, the connections are gone from netstat.
Do you know how I could force the connections to end "clean"?

Share this post


Link to post
Share on other sites
Advertisement
The connections are not actually "open" as such in the background, it's just that the ports are blocked with TIME_WAIT, so that new connections will not use the same port. This is a safety measure to avoid possible packets meant for the old connection to be received on the port after a new connection uses it.

You can read about the TCP close sequence for example at http://en.wikipedia.org/wiki/Transmission_Control_Protocol under Connection termination.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!