[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

TIME_WAIT after socket is closed?

Posted on 2002-04-09
3
Medium Priority
?
278 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 30 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

650 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