ktimeout

package
v1.74.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

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

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetUserTimeout

func SetUserTimeout(fd uintptr, timeout time.Duration) error

SetUserTimeout sets the TCP_USER_TIMEOUT option on the given file descriptor.

func UserTimeout

func UserTimeout(timeout time.Duration) func(network, address string, c syscall.RawConn) error

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.

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:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL