Re: On Vista, recv function does not return when pulling out the cable
- From: "Chris Becke" <chris.becke@xxxxxxxxx>
- Date: Mon, 30 Jul 2007 11:20:51 +0200
"Paul" <Paul@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:78EE4211-0A70-45CE-BB6D-79CE731948AD@xxxxxxxxxxxxxxxx
On a Vista machine, Winsock recv function does not return when pulling out
the cable (or disabling the network connection). On a XP or 2000 machine
it
does and WSAGetLastError indicates the WSAECONNRESET error code.
This can be tested using the Microsoft client and server code from
http://msdn2.microsoft.com/en-us/library/ms737889.aspx .
Is this a bug or is there an alternate method to receive this event?
It may or may not be a bug. But its a general problem with blocking recv's.
While the local network stack in theory CAN detect the network media being
disconnected, what happens if you pull the network cable out the other side
of the local hub?
Now theres no local media disconnection event and the recv is left hanging.
If the remote host tries to send data, or closes the socket while the media
is disconnected, it will recieve an error and close its socket, so, even if
the media is reconnected, the local recv is stuck indefinately in a zombie
state.
Which is to say, your application protocol should never rely on media
disconnection events to terminate blocking recv calls. blocking recv calls
are only really safe when used for IPC on localhost. If youre talking to
another host then you MUST use a 2nd thread to close the socket should a
timeout be exceeded - OR fake a blocking socket with a non blocking socket
and use select() with a sensible timeout when waiting for data.
.
- Prev by Date: Re: LSP (Layered Service Provider) with IE
- Next by Date: How to Checking a URL :Valid or Invalid
- Previous by thread: Re: login into free hotmail using http request
- Next by thread: How to Checking a URL :Valid or Invalid
- Index(es):
Relevant Pages
|