mihomo/common/net/tcp_keepalive_go123.go
wwqgtxx f20f371a61
Some checks are pending
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run
chore: better keepalive handle
2024-08-14 13:01:06 +08:00

20 lines
482 B
Go

//go:build go1.23
package net
import "net"
func tcpKeepAlive(tcp *net.TCPConn) {
config := net.KeepAliveConfig{
Enable: true,
Idle: KeepAliveIdle,
Interval: KeepAliveInterval,
}
if !SupportTCPKeepAliveCount() {
// it's recommended to set both Idle and Interval to non-negative values in conjunction with a -1
// for Count on those old Windows if you intend to customize the TCP keep-alive settings.
config.Count = -1
}
_ = tcp.SetKeepAliveConfig(config)
}