View Full Version : TCP TIME_WAIT state

12-26-2001, 10:26 PM
Just though to share this with those of you who are into network programming:

According to every network programming resource I have seen TIME_WAIT state after closing a TCP connection is a normal thing. It should remain there up to 2MSL and then it dissappears. I have written and seen a lot of TCP servers and clients that demonstrate this perfectly. Most of the time TCP acts according to specification, and depending on which side made the active close, the same side would remain in the TIME_WAIT state preventing the reincarnation of this socket.

The TIME_WAIT state can be avoided if the connection is reset after one side initiated an active close. In this case the connection dissappears completely from the netstat table. This is what I wanted to achieve and I actually did this in my latest server.

But after doing some research on the Internet and reading some Stevens books and some RFCs I discovered that immediate termination of the TIME_WAIT state can lead to problems with TCP especially using TCP connections.

I was thinking about this and I really can't think of any problems that might arise from doing this, especially if my own internal data is enumerated and sequential (but it could be either synchronous or asynchronous).

Any help will be greatly appreciated...

Merry Christmas and Happy New Year, Everyone!!!

12-27-2001, 08:50 AM
hmm...what problems did it say it causes? I can't really think of any, but you know as well as I do that when you're programming something, the least likely bug always becomes the most likely.