Socket Disconnected event.

  • Thread starter Thread starter Ashwin Kambli
  • Start date Start date
A

Ashwin Kambli

Hi,
I have a simple socket application. There is a server, and there are many
TCP connections to the server.
Now, if any one of those connections is lost, is there a way of triggering
an event on the server for this.
What I need is to set up a delegate to handle this disconnection (Delegate
has some cleanup code). As soon as the socket is disconnected, the event
should call the delegate.
Thanking you,
Ashwin Kambli
 
Ashwin Kambli said:
Hi,
I have a simple socket application. There is a server, and there are many
TCP connections to the server.
Now, if any one of those connections is lost, is there a way of triggering
an event on the server for this.
What I need is to set up a delegate to handle this disconnection (Delegate
has some cleanup code). As soon as the socket is disconnected, the event
should call the delegate.
Thanking you,
Ashwin Kambli

It depends what you're using. .NET's NetworkStream.Read(), for
example, will return 0 if the connection dropped. Any other time it
will return a number greater than 0, indicating how many bytes have
just been read.
 
Back
Top