Re: How to terminate a socket in CLOSE_WAIT state
From: Slava M. Usov (stripit.slough_at_gmx.net)
Date: 05/20/04
- Next message: Keith Moore: "Re: How to terminate a socket in CLOSE_WAIT state"
- Previous message: John Kirk: "Stackwalk64 problems"
- In reply to: Francois PIETTE: "Re: How to terminate a socket in CLOSE_WAIT state"
- Next in thread: Keith Moore: "Re: How to terminate a socket in CLOSE_WAIT state"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 20 May 2004 19:19:32 +0200
"Francois PIETTE" <francois.piette@overbyte.be> wrote in message
news:40acd762$0$9867$a0ced6e1@news.skynet.be...
[...]
> > CLOSE_WAIT is required by the TCP RFCs, mostly so the machine can
> > properly handle duplicate packets arriving after the connection is
> > closed.
>
> I'm perfectly aware of that.
CLOSE_WAIT is the state in which a socket may remain indefinitely -- more
exactly until the user of the socket decides to close it [in the TCP sense,
by sending a FIN to the peer]. A socket enters this state when it receives a
FIN from its peer. In short, the time spent in CLOSE_WAIT has nothing to do
with the behavior -- or misbehavior -- of the peer, and everything to do
with your software. The only exception is when some data have been sent but
not ACKed by the peer at the time of close, in which case TCP may be trying
to resend the data before sending the FIN.
It may also be that MS labels some other state as CLOSE_WAIT, but I find it
very unlikely.
[...]
> ? I mean closing after it is already gracefully closed but in CLOSE_WAIT
> state, waiting for the remote end to reply.
If you're sure that you actually call shutdown() or closesocket() on the
very socket that remains in CLOSE_WAIT, then there is no way to close it
gracefully. You can only close it ungracefully, by specifying an abortive
linger option, with zero or non-zero timeout.
Alternatively, you may avoid the situation in the first place, by disabling
the Nagle algorithm on the socket and waiting for a confirmation after each
send with a timeout. This is going to be a catastrophe in terms of
performance, though.
S
- Next message: Keith Moore: "Re: How to terminate a socket in CLOSE_WAIT state"
- Previous message: John Kirk: "Stackwalk64 problems"
- In reply to: Francois PIETTE: "Re: How to terminate a socket in CLOSE_WAIT state"
- Next in thread: Keith Moore: "Re: How to terminate a socket in CLOSE_WAIT state"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|