Solved

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

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DHCP Server 14 85
Is it possible to host a website on a windows vps 4 57
MAC address learning of Riverbed 4 42
Use of vpn-filter value  in S2S VPN 2 31
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

770 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