Solved

TIME_WAIT after socket is closed?

Posted on 2002-04-09
3
269 Views
Last Modified: 2008-02-01
I have a server and client socket program written under Visual C++ 5.0.

After sending data, I successfully closed client's socket and server's socket by using <closesocket> function provided by <winsock2.h>.

But when I netstat -a under windows platform. I can see some of the port that previously been established showing "TIME_WAIT". It this cause by my program???

If it is cause by my program, how come only some of the port is "PENDING" there. Because I tried to do a loop that open, send data, and close 30 socket in a time. Only 5 socket show "TIME_WAIT". After certain time, I netstat again the "TIME_WAIT" disappear.

Guys, any idea?

0
Comment
Question by:realman1
3 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 10 total points
ID: 6932216
TIME_WAIT is just the state that the socket goes into to ensure that packets are not accepted later from the same host to a different socket connection.  The TCP layer keeps the socket semi-open so that packets arriving late are bounced off of that socket and don't magically get accepted by a different socket that's opened between the same 2 servers.  It's nothing to worry about, and it'll go away.
0
 
LVL 11

Expert Comment

by:griessh
ID: 6960634
Dear realman1

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "mnashadka"

comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: http://www.experts-exchange.com/commspt/

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 

Author Comment

by:realman1
ID: 6961604
Dear mnashadka,
  I forgot to reply you. I refer to other sources and found out your answer is the correct one. But just too busy for it until forgot to give you credit. Sorry for that and thank you for your answer. :)
  Have a nice day.
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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

943 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

4 Experts available now in Live!

Get 1:1 Help Now