package net
import (
"runtime"
"syscall"
"time"
)
func setKeepAliveIdle(fd *netFD , d time .Duration ) error {
if d == 0 {
d = defaultTCPKeepAliveIdle
} else if d < 0 {
return nil
}
secs := int (roundDurationUp (d , time .Second ))
err := fd .pfd .SetsockoptInt (syscall .IPPROTO_TCP , syscall .TCP_KEEPIDLE , secs )
runtime .KeepAlive (fd )
return wrapSyscallError ("setsockopt" , err )
}
func setKeepAliveInterval(fd *netFD , d time .Duration ) error {
if d == 0 {
d = defaultTCPKeepAliveInterval
} else if d < 0 {
return nil
}
secs := int (roundDurationUp (d , time .Second ))
err := fd .pfd .SetsockoptInt (syscall .IPPROTO_TCP , syscall .TCP_KEEPINTVL , secs )
runtime .KeepAlive (fd )
return wrapSyscallError ("setsockopt" , err )
}
func setKeepAliveCount(fd *netFD , n int ) error {
if n == 0 {
n = defaultTCPKeepAliveCount
} else if n < 0 {
return nil
}
err := fd .pfd .SetsockoptInt (syscall .IPPROTO_TCP , syscall .TCP_KEEPCNT , n )
runtime .KeepAlive (fd )
return wrapSyscallError ("setsockopt" , err )
}
The pages are generated with Golds v0.7.0-preview . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .