about summary refs log tree commit diff stats
path: root/lib/keepalive_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/keepalive_linux.go')
-rw-r--r--lib/keepalive_linux.go17
1 files changed, 17 insertions, 0 deletions
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)
+}