Solved

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

Posted on 1997-12-18
1
282 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 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What's the problem with my DSL? 4 56
Routing Over XO Communications MPLS 7 44
Failing ALG SIP test for new VoIP phone system 4 49
SOFS cluser offline 3 43
If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now