How do I properly determine if my client is still connected to the server with C sockets?
问题 I have a client connected to a server via C Berkeley sockets. I (try to) periodically check to see if the connection is still valid by calling recv() on the socket with MSG_DONTWAIT and MSG_PEEK. However, I'm finding that this call returns EAGAIN both when the connection is down in some cases (e.g., after the connection's interface is shut down) and when there is simply no data to read. Hence, there is no way for me to distinguish whether the connection is still valid or not using this method