Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

TCP/IP stack goes into TIME_WAIT state on closing a socket ???

Posted on 1997-12-18
1
Medium Priority
?
292 Views
Last Modified: 2013-12-23
Hi,

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
World"

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....

Thanx,







0
Comment
Question by:AnantS
1 Comment
 
LVL 1

Accepted Solution

by:
rjhoward earned 400 total points
ID: 1583061
Try setting the SO_REUSEADDR socket option.  I believe this flags the socket as one that may be immediately reused.

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question