diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/keepalive_dummy.go | 11 | ||||
-rw-r--r-- | lib/keepalive_linux.go | 17 |
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/keepalive_dummy.go b/lib/keepalive_dummy.go new file mode 100644 index 0000000..205b577 --- /dev/null +++ b/lib/keepalive_dummy.go @@ -0,0 +1,11 @@ +//+build !linux + +package lib + +func SetTcpKeepaliveProbes(fd, count int) error { + return nil +} + +func SetTcpKeepaliveInterval(fd, interval int) error { + return nil +} diff --git a/lib/keepalive_linux.go b/lib/keepalive_linux.go new file mode 100644 index 0000000..0dc3285 --- /dev/null +++ b/lib/keepalive_linux.go @@ -0,0 +1,17 @@ +//+build linux + +package lib + +import ( + "syscall" +) + +func SetTcpKeepaliveProbes(fd, count int) error { + return syscall.SetsockoptInt( + fd, syscall.IPPROTO_TCP, syscall.TCP_KEEPCNT, count) +} + +func SetTcpKeepaliveInterval(fd, interval int) error { + return syscall.SetsockoptInt( + fd, syscall.IPPROTO_TCP, syscall.TCP_KEEPINTVL, interval) +} |