Hello. How do you detect when the remote end of a connection has disconnected? I get alot of timeouts, but that doesnt tell me that ive disconnected absolutely. Any suggestions? Is there anything besides a timeout error that can be used?
Hello. How do you detect when the remote end of a connection has disconnected? I get alot of timeouts, but that doesnt tell me that ive disconnected absolutely. Any suggestions? Is there anything besides a timeout error that can be used?
When the program shuts down, have it send a disconnect message...If it doesn't send a message saying it's quitting, you can only tell by timeouts.
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
http://www.opengroup.org/onlinepubs/...ions/recv.html
Upon successful completion, recv() shall return the length of the message in bytes. If no messages are available to be received and the peer has performed an orderly shutdown, recv() shall return 0. Otherwise, -1 shall be returned and errno set to indicate the error.
If remote end of a connection is in Asynchronous mode, you wud receive FD_CLOSE notification message provided u set it in the call to WSAAsyncselect().
Hope this helps
dp_76
In a separate "receiver" thread you could simply select() for readability then peek at the incoming message and check if the peek errors out. If it does, the connection was closed.
See my socket library (http://www.geocities.com/lucky760/mtsocket) for an example.