Solved

TIME_WAIT after socket is closed?

Posted on 2002-04-09
3
275 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 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

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

696 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