What exactly does SO_KEEPALIVE do?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What's the difference between a socket and a port?

458


Where is the socket located?

478


What is a socket file?

512


What is the function of socket?

516


Why do we need socket programming?

500






What is the difference between SO_REUSEADDR and SO_REUSEPORT?

1356


What is the difference between read() and recv()?

1598


Can multiple clients connect to same socket?

518


What is a sae socket?

518


What exactly is a socket?

526


Can a single socket port be used for multiple applications?

458


What is af_inet in socket?

478


What is difference between socket () and serversocket () class?

495


Why does the sockets buffer fill up sooner than expected?

999


How does a socket work?

493