Socket Disconnected Notification

  • Thread starter Thread starter Vladimir Lushnikov
  • Start date Start date
V

Vladimir Lushnikov

Hi,

I know there exist asynchronous socket methods for connecting,
receiving/sending data and disconnecting - but how do you know when the
socket has been terminated - can you assign an event handler or a
delegate as to when the socket is disconnected - either gracefully from
remote or shut down by "brute force"?

In short, something like this:

MySocket.Close += new EventHandler(MySocket_OnClosed);


Anyone?

Regards,
Vladimir Lushnikov
 
Unfortunately, no, there is no "direct" event for Closing.

When a socket is closed, you will get a receive notification. When you then
try to read from the socket, you will get 0 bytes received. THIS 0 bytes
received is the notification when a socket gets closed.
 
Yes.
There is no "direct" event for Closing
and if you worry about the socket is closed or not . You have to check it by
yourself.

Best Regards,
Vuong
Tran Xuan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top