1

According to http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/index.html , the kernel keepalive function occurs at the OS level, and doesn't require an application to explicitly call it. However I also read about how an application must call it (using SO_KEEPALIVE) to actually make use of the kernel feature.

Here > Keep-alive options not working on Linux for an outgoing connection

Could someone please clarify?

Thanks!

Davis
  • 13
  • 3

1 Answers1

3

It doesn't occur for application sockets unless being explicitly turned on on them. Moreover, it's clearly stated in the TCP Keepalive HOWTO you referred to:

Remember that keepalive support, even if configured in the kernel, is not the default behavior in Linux. Programs must request keepalive control for their sockets using the setsockopt interface. There are relatively few programs implementing keepalive, but you can easily add keepalive support for most of them following the instructions explained later in this document.

poige
  • 9,171
  • 2
  • 24
  • 50
  • Obviously, it helps to read the entire document. Thank you for explaining this! – Davis Apr 08 '13 at 03:50
  • I have one more question. While running netstat -tno, if it shows 'off' under timer, does that mean that the particular program has not implemented keepalive? – Davis Apr 08 '13 at 04:04
  • Yeah, `keepalive` is explicitly indicated. – poige Apr 08 '13 at 04:27
  • I found the section on [libkeepalive](http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/addsupport.html#libkeepalive) to be particular useful while waiting for developers to add keepalive support to an application. – kasperd Apr 15 '16 at 17:12