Solved

TIME_WAIT after socket is closed?

Posted on 2002-04-09
3
268 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

771 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

10 Experts available now in Live!

Get 1:1 Help Now