What exactly does SO_KEEPALIVE do?
Answer / chaitanya
The SO_KEEPALIVE option causes a packet (called a 'keepalive probe') to be sent to the remote system if a long time (by default, more than 2 hours) passes with no other data being sent or received. This packet is designed to provoke an ACK response from the peer. This enables detection of a peer which has become unreachable (e.g. powered off or disconnected from the net).
Note that the figure of 2 hours comes from RFC1122, "Requirements for Internet Hosts". The precise value should be configurable, but I've often found this to be difficult. The only implementation I know of that allows the keepalive interval to be set per-connection is SVR4.2.
| Is This Answer Correct ? | 0 Yes | 0 No |
How can I force a socket to send the data in its buffer?
What pieces of information make up a socket?
What are the pros/cons of select(), non-blocking I/O and SIGIO?
How can I set the timeout for the connect() system call?
When will my application receive SIGPIPE?
What is the purpose of socket?
What is the difference between connected and unconnected sockets?
How can I bind() to a port number < 1024?
Why does it take so long to detect that the peer died?
How can my client work through a firewall/proxy server?
Is a socket a file?
What is a socket file?