TCP/IP stack goes into TIME_WAIT state on closing a socket ???
Posted on 1997-12-18
I am using Sun OS 5.5.1
I've written a small server program, which binds to port 8000, and listens
for incoming request.
When a client connects to it, it sends back some simple message like "Hello
The client can send a special terminate message, in which case the server
closes the socket and terminates.
My problem is that after the client sends the terminate message ( and the
server shuts down ), I cannot immediately start the server, I get the
following error :
"Address 8000 already in use"
if I do a "netstat -f inet | grep 8000", I see that the port 8000 has gone
in TIME_WAIT state .
After some time the OS release this port, and I can restart my server.
Is there any way I can avoid this TIME_WAIT state ??, am I not closing the
server socket properly ?? ( I do a close( socket_id ) )
Is there any option I can set on the socket to avoid the TIME_WAIT state ??
Any help will be greatly appreciated....