Re: Detecting socket disconnection (Async?)

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Adam Clauss (cabadam_at_tamu.edu)
Date: 04/16/04


Date: Fri, 16 Apr 2004 16:58:42 -0500

Hmm... OnReceive gets called for OnDisconnect. Well, I suppose it works, just does not seem very logical.

Thanks!

-- 
Adam Clauss
cabadam@tamu.edu
"Andreas Håkansson" <andy.h (at) telia.com> wrote in message news:uwpXkP$IEHA.3544@TK2MSFTNGP09.phx.gbl...
> 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)
  • Re: Detecting socket disconnection (Async?)
    ... connection or when the connection is lost due to a network error (connect ... When the client explicitly closes the connection, your recieve callback will ... disconnects, but all of them I have seen are Synchronous. ...
    (microsoft.public.dotnet.languages.csharp)