?
Solved

TIME_WAIT after socket is closed?

Posted on 2002-04-09
3
Medium Priority
?
277 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 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.
Suggested Courses

764 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