Is there a way an application can explicitly send a TCP/IP Keepalive
packet? If so, how would I do this?
Hello Philip,
Is there a way an application can explicitly send a TCP/IP Keepalive
packet? If so, how would I do this?
If you mean the keepalives generated when the SO_KEEPALIVE socket
option is set, then the answer is no. The generation of keepalives
is done by the operating system’s IP stack in response to a
keepalive timer expiring for an idle connection. There are
generally some configuration parameters to control keepalives
(keepalive time interval, maximum number of keepalives to send
before giving up, etc.), but these are system-wide parameters, not
per socket. It is usually not a good idea to change them for this
reason. See RFC 1122.
If you need more control, you will probably need to implement
keepalives in your application-level protocol. Examples of this
usage are routing daemons and the OpenSSH client ssh (see the
ProtocolKeepAlives config option).
Best regards,