tcpkeepalive

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2023 License: Apache-2.0, MIT Imports: 5 Imported by: 0

README

tcpkeepalive

Known Issues: Some problems with the implementation were reported, I'll try to fix them when I get a chance, or if somebody sends a PR.

Package tcpkeepalive implements additional TCP keepalive control beyond what is currently offered by the net pkg.

Only Linux >= 2.4, DragonFly, FreeBSD, NetBSD and OS X >= 10.8 are supported at this point, but patches for additional platforms are welcome.

See also: http://felixge.de/2014/08/26/tcp-keepalive-with-golang.html

License: MIT

Docs: http://godoc.org/github.com/felixge/tcpkeepalive

Documentation

Overview

Package tcpkeepalive implements additional TCP keepalive control beyond what is currently offered by the net pkg.

Only Linux >= 2.4, DragonFly, FreeBSD, NetBSD and OS X >= 10.8 are supported at this point, but patches for additional platforms are welcome.

See also: http://felixge.de/2014/08/26/tcp-keepalive-with-golang.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetKeepAlive

func SetKeepAlive(c net.Conn, idleTime time.Duration, count int, interval time.Duration) (err error)

Enable TCP keepalive in non-blocking mode with given settings for the connection, which must be a *tcp.TCPConn.

Types

type Conn

type Conn struct {
	*net.TCPConn
	// contains filtered or unexported fields
}

Conn adds additional TCP keepalive control to a *net.TCPConn.

func EnableKeepAlive

func EnableKeepAlive(conn net.Conn) (*Conn, error)

EnableKeepAlive enables TCP keepalive for the given conn, which must be a *tcp.TCPConn. The returned Conn allows overwriting the default keepalive parameters used by the operating system.

func (*Conn) SetKeepAliveCount

func (c *Conn) SetKeepAliveCount(n int) error

SetKeepAliveCount sets the maximum number of keepalive probes TCP should send before dropping the connection.

func (*Conn) SetKeepAliveIdle

func (c *Conn) SetKeepAliveIdle(d time.Duration) error

SetKeepAliveIdle sets the time (in seconds) the connection needs to remain idle before TCP starts sending keepalive probes.

func (*Conn) SetKeepAliveInterval

func (c *Conn) SetKeepAliveInterval(d time.Duration) error

SetKeepAliveInterval sets the time (in seconds) between individual keepalive probes.

Jump to

Keyboard shortcuts

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