Re: detecting the (brute) disconnection of a client




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 ?

.



Relevant Pages

  • The remote peer is no longer responding
    ... " Secure VPN connection terminated locally by the Client. ... RECEIVING <<< ISAKMP OAK AG, VID, VID, KE, ID, ... Crypto Active IKE SA, ...
    (comp.dcom.sys.cisco)
  • Re: question about class Socket
    ... run the following code, the client send a test string, but it doesn't ... // State object for receiving data from remote device. ... // Client socket. ...
    (microsoft.public.dotnet.framework)
  • acynchronous client and server problem using socket
    ... run the following code, the client send a test string, but it doesn't ... // State object for receiving data from remote device. ... // Client socket. ...
    (microsoft.public.dotnet.framework)
  • fax receiving problems
    ... I'm having a problem with a fax server at one of my client ... I recently installed the SBS 2003 fax server feature with a brand new ... Receiving is a little more tricky. ... see Help and Support Center at ...
    (microsoft.public.windows.server.sbs)
  • Re: [Socket] detecting the (brute) disconnection of a client
    ... When the client exits, I close the socket with a specific message ... and the thread terminate in a proper manner, ... If only receiving, it will sit and continue to try to receive indefinitely. ... The two usual approaches are to either implement a timeout, or provides a mechanism for the user to interrupt the receiver (at which point it would simply close the socket). ...
    (microsoft.public.dotnet.languages.csharp)