-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
In CL 542275, the implementation on Windows
has a few limitations:
TCP_KEEPCNT
is not supported.TCP_KEEPIDLE
andTCP_KEEPINTVL
cannot be set separately, they must be set together.
Lines 121 to 127 in ff4e45f
// Note that Windows doesn't support setting the KeepAliveIdle and KeepAliveInterval separately. | |
// It's recommended to set both Idle and Interval to non-negative values on Windows if you | |
// intend to customize the TCP keep-alive settings. | |
// By contrast, if only one of Idle and Interval is set to a non-negative value, the other will | |
// be set to the system default value, and ultimately, set both Idle and Interval to negative | |
// values if you want to leave them unchanged. | |
type KeepAliveConfig struct { |
These limitations come from SIO_KEEPALIVE_VALS that is used for TCP keep-alive on Windows
in Go
currently. It's a relatively old Winsock
API for setting up the TCP keep-alive mechanism. I've done some more in-depth research on Windows
and realized that we can do more things on some relatively newer versions of Windows
using setsockopt
and getsockopt
.
TCP_KEEPIDLE
and TCP_KEEPINTVL
are available starting with Windows 10, version 1709. TCP_KEEPCNT
is available starting with Windows 10, version 1703. Therefore, we can reconcile the implementation on Windows 10, version 1709
and later versions with the implementations on UNIX's.
Follows up #65809