Socket Disconnected event.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ashwin Kambli

    Socket Disconnected event.

    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


  • C# Learner

    #2
    Re: Socket Disconnected event.

    "Ashwin Kambli" <ashwin@voiceno w.com> wrote:
    [color=blue]
    >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[/color]

    It depends what you're using. .NET's NetworkStream.R ead(), 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.

    Comment

    Working...