Thank you very much for this information. I had the same problem. In client code:

instead of:

curMsg = "Disconnecting...";
clientSock.Close();

I have used:

curMsg = "Disconnecting...";