| Server IP : 217.160.0.212 / Your IP : 216.73.216.141 Web Server : Apache System : Linux www 6.18.51-i1-ampere #1196 SMP Fri Sep 11 20:43:55 CEST 2026 aarch64 User : sws1073854427 ( 1073854427) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/share/go-1.23/src/net/ |
Upload File : |
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build aix || dragonfly || freebsd || illumos || linux || netbsd
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
}
// The kernel expects seconds so round to next highest second.
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
}
// The kernel expects seconds so round to next highest second.
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)
}