0

If the client is waiting on recv() and the connection times out due to keepalive timeout , what will be the return value of recv() and is there any specific error code set for connection termination due to keepalive timeout ?

I can see we have a specific error code for keepalive on windows. WSAENETRESET For a connection-oriented socket, this error indicates that the connection has been broken due to keep-alive activity that detected a failure while the operation was in progress. For a datagram socket, this error indicates that the time to live has expired.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms740121(v=vs.85).aspx

Please let me know.

yaniv135
  • 21
  • 2

1 Answers1

0

If a keepalive timeout occurs you will receive a SIGPIPE if you try to read() or write() on the socket.

See also: How to use SO_KEEPALIVE option properly to detect that the client at the other end is down?

Community
  • 1
  • 1
scai
  • 20,297
  • 4
  • 56
  • 72
  • I believe SIGPIPE can be returned due to keepalive and if the connection is reset by the server. Is there a way to differentiate between the two cases ? WSAECONNRESET 10054 Connection reset by peer. An existing connection was forcibly closed by the remote host. This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see setsockopt for more information on the SO_LINGER option on the remote socket). – yaniv135 Aug 07 '12 at 09:06
  • This error may also result if a connection was broken due to keep-alive activity detecting a failure while one or more operations are in progress. Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET. – yaniv135 Aug 07 '12 at 09:06