Re: Detecting socket disconnection (Async?)

From: Andreas Håkansson ("Andreas)
Date: 04/16/04


Date: Fri, 16 Apr 2004 22:46:25 +0200

Adam,

    There are two types of disconnects; when the client explicitly closes
the
connection or when the connection is lost due to a network error (connect
went down, etc).

When the client explicitly closes the connection, your recieve callback will
be called and your will recieve zero bytes - when this happens you know that
the client is question has disconnected. To check for network errors you
will
have to catch the SocketException which you will be getting :)

HTH,

//Andreas

"Adam Clauss" <cabadam@tamu.edu> skrev i meddelandet
news:exjXkM$IEHA.2556@TK2MSFTNGP11.phx.gbl...
> There seems to be various methods to determine when the remote client
disconnects, but all of them I have seen are Synchronous.
> AKA: Right before you try to send or receive data, check.
>
> Is there no way to do raise an event for this? That way you know as soon
as the client disconnects?
>
> There are events for Accepting, Connecting, Receiving, Sending... why not
one for disconnecting?
>
> --
> Adam Clauss
> cabadam@tamu.edu
>
>



Relevant Pages

  • Re: $100 reward for socket disconnection help
    ... > I'm running Java 1.4.1 as an applet on the client side, under Windows 98, ... > with a DSL connection through a Linksys Wireless-B Router. ... > disconnects at the same time my application does ("AOL Instant Messenger ... > still trying to reconnect, IM is always able to immediately reconnect, and ...
    (comp.lang.java.programmer)
  • Re: Able to detect disconnect, except one weird case...
    ... Only problem is when my client sits silent with no data being ... at that point the server knows the connection has ... FD_READ) like it does when the server disconnects. ... On other projects I've sent keep-alive packets (just small packets ...
    (microsoft.public.win32.programmer.networks)
  • Re: Mac suddenly disconnected from Windows 2003 Server
    ... Connections can be slept on a per connection basis - the Mac client may or ... monitor tool on the server and looking at the time stamps of the traffic ... >> Most likely the client is sleeping the connection and the server> disconnects>> after not hearing from the client for 2 minutes. ...
    (microsoft.public.win2000.macintosh)
  • Re: $100 reward for socket disconnection help
    ... I'm running Java 1.4.1 as an applet on the client side, under Windows 98, ... with a DSL connection through a Linksys Wireless-B Router. ... client-server disconnects while I run my application are very rare. ... still trying to reconnect, IM is always able to immediately reconnect, and ...
    (comp.lang.java.programmer)
  • [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #3]
    ... These patches together supply secure client-side RxRPC connectivity as a Linux ... kernel socket family. ... presentation side is left to the client. ... Each connection goes to a particular "service". ...
    (Linux-Kernel)