1

In the event a user closes the application I have the following:

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
    client.Shutdown(SocketShutdown.Both);
}

When this happens my server triggers my Receive Callback routine. But there is no data.

Is there an existing method such as OnDisconnect() or OnShutdown() I can call in order for me to update my server and other clients?

Or should I add my own disconnect message prior to the shutdown command on the client?

Richard Pike
  • 679
  • 1
  • 8
  • 22

1 Answers1

0

Receive returns zero when the connection was gracefully shut down. This is normal and must be deal with. Simply do nothing in the callback and clean up all resources.

usr
  • 168,620
  • 35
  • 240
  • 369