09-08-2012, 08:25 PM
Its because in my language the function for receiving data doesn't return 0 when its empty. As I code my threads to loop on checking if data is received from that that socket until something is received. Once it receives data it breaks and goes into parsing the data received. At the moment it returns -1 on error, and -1 when no data is received. So its hard to know if the client disconnected, or is just idling.
You can just put a timeout for the the last packet received(30 seconds I think its enough), plus it will disconnect those who have the client opened with a debugger.
Or you could use WSAGetLastError_() to get the error code and compare it with some of this:
2
The most necessary are:
WSAECONNRESET 10054 ->means the application either was closed or it lost connection
WSAEDISCON 10101 ->client disconnected(like receiving 0)
There are other like timeout, etc

