Re: detecting the (brute) disconnection of a client
- From: timor.super@xxxxxxxxx
- Date: 3 Apr 2007 12:03:21 -0700
Peter Duniho a écrit :
On Tue, 03 Apr 2007 08:57:59 -0700, <timor.super@xxxxxxxxx> wrote:
[...]
When the client exits, I close the socket with a specific message
(like "end") and the thread terminate in a proper manner, but If my
client crashes, the server is still waiting for receiving data, and
the thread is blocked.
How can I detect that the client is out ? (then, if I can detect it,
maybe I can terminate the thread brutally (or if there's a better
way ...))
Generally (as you've found) TCP/IP won't detect a broken connection until
the detecting end attempts some actual i/o. That is, tries to send and
fails. If only receiving, it will sit and continue to try to receive
indefinitely. This allows TCP/IP to be able to transparently deal with
the situation where both endpoints are fine, but something in between is
temporarily interrupted.
The two usual approaches are to either implement a timeout (when the
receiver knows it should receive some data within a certain amount of
time), or provides a mechanism for the user to interrupt the receiver (at
which point it would simply close the socket). Sometimes these are both
used.
Pete
Thanks for your answer,
so i think i have to try to send something to the client that has
crashed, and if an exception occurs, then the client is deconnected.
Or maybe, i have to use the timeout, the if timed out, i try to send
something to check if the client is still here
do you think it is a good idea ?
Should I use the SendTimeout property with the Send() method ?
.
- Follow-Ups:
- Re: detecting the (brute) disconnection of a client
- From: Peter Duniho
- Re: detecting the (brute) disconnection of a client
- References:
- [Socket] detecting the (brute) disconnection of a client
- From: timor . super
- Re: [Socket] detecting the (brute) disconnection of a client
- From: Peter Duniho
- [Socket] detecting the (brute) disconnection of a client
- Prev by Date: Re: multiple threads writing to WebBrowser, getting deadlocked
- Next by Date: Re: Total confused and need help with small encryption and decryption methods
- Previous by thread: Re: [Socket] detecting the (brute) disconnection of a client
- Next by thread: Re: detecting the (brute) disconnection of a client
- Index(es):
Relevant Pages
|