6

Can I change/add the KeepAliveTime and related registry variables to make a Windows machine send TCP keepalive packets on an idle connection?

I want to know if anyone has successfully got this working. Specifically, when the application idling on the TCP connection is doing nothing particular (setsockopt) to keepalive the connection.

This Microsoft TechNet details on Configuring system wide Keep-Alives with the KeepAliveTime and related registry variables.

HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\KeepAliveTime

It seems like the Linux system wide configuration for using keep-alive.
But, that requires programs to use the setsockopt() and request keep-alive (right?).

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...

nik
  • 7,040
  • 2
  • 24
  • 30

1 Answers1

6

Your assessment of the TCP keepalive functionality in Windows being like Linux is correct.

You can manipulate the registry parameters related to TCP keepalives all you want, but unless the application uses setsockopt() to request keepalives none will be sent by default.

If you want to actually see keepalives in action on Windows and don't want to write code, tick the "Enable TCP keepalives (SO_KEEPALIVE)" in the "Connection" properties in the PuTTY SSH/TELNET/etc client, initiate a connection, allow it to sit idle, and sniff the traffic. (It's the first app I could think of that I knew could be consciouly configured to use SO_KEEPALIVE...)

Evan Anderson
  • 141,071
  • 19
  • 191
  • 328
  • 1
    I have seen keepalives in action and yes, PuTTY is actually quite good about them. But, my interest is in making a non-standard application (that I cannot recompile due to lack of source) use them during its extended communication hiatus -- the app can go silent for days (not just hours). The best way I can think of is a global keepalive on either the client or the server machine. – nik Jul 01 '10 at 02:47
  • @nik You can pipe its traffic through a locally-running TCP proxy which is configured to use keep-alives. – Aleksandr Dubinsky May 29 '19 at 07:42