Linux TCP Keepalive – Is It Application Dependent?

keep-alivekeepalivekernellinuxtcp

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!

Best Answer

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.