package ktimeout
import "tailscale.com/net/ktimeout"
Package ktimeout configures kernel TCP stack timeouts via the provided control functions. Platform support varies; on unsupported platforms control functions may be entirely no-ops.
Index ¶
- func SetUserTimeout(fd uintptr, timeout time.Duration) error
- func UserTimeout(timeout time.Duration) func(network, address string, c syscall.RawConn) error
Examples ¶
Functions ¶
func SetUserTimeout ¶
SetUserTimeout sets the TCP_USER_TIMEOUT option on the given file descriptor.
func UserTimeout ¶
UserTimeout returns a control function that sets the TCP user timeout
(TCP_USER_TIMEOUT on linux). A user timeout specifies the maximum age of
unacknowledged data on the connection (either in buffer, or sent but not
acknowledged) before the connection is terminated. This timer has no effect
on limiting the lifetime of idle connections. This may be entirely local to
the network stack or may also apply RFC 5482 options to packets.
Code:
Example¶
{
lc := net.ListenConfig{
Control: UserTimeout(30 * time.Second),
}
l, err := lc.Listen(context.TODO(), "tcp", "127.0.0.1:0")
if err != nil {
fmt.Printf("error: %v", err)
return
}
l.Close()
// Output:
}
Source Files ¶
ktimeout.go ktimeout_linux.go
- Version
- v1.84.0 (latest)
- Published
- May 21, 2025
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 1 day ago –
Tools for package owners.