Advertisement

In C# how do you know a socket has disconnected?

Started by March 04, 2004 02:05 PM
1 comment, last by nPawn 20 years, 11 months ago
My C# server needs to know when a player disconnects (TCP), whether it be a clean disconnect or otherwise. I seem to be able to catch most of the clean disconnects because I get a Recieve with a length of zero from this call: NumberBytesReceived = m_Socket.EndReceive(asyn); NumberBytesReceived will be zero on a clean disconnect. However there''s times when the player disconnects but I don''t get this 0 byte receive, I get no data received, so i''m hoping there''s some other way to check?
Does checking the Socket.Connected property work?
Advertisement
Yah, that''d work, but I was hoping there was a system Message or something along those lines so I don''t have to sit there and poll the Socket.Connected member to see if it has gone false.

This topic is closed to new replies.

Advertisement