keepalive

package
v2.0.212+incompatible Latest Latest
Warning

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

Go to latest
Published: May 15, 2019 License: MIT Imports: 3 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Dialer = &net.Dialer{
	Timeout:   30 * time.Second,
	KeepAlive: 30 * time.Second,
}

Dialer is copied from the invocation in http.DefaultTransport: https://github.com/golang/go/blob/859cab099c5a9a9b4939960b630b78e468c8c39e/src/net/http/transport.go#L40-L44

Functions

func DialerFunc

func DialerFunc(addr string, timeout time.Duration) (net.Conn, error)

DialerFunc dials |addr| with |timeout|. It's designed to be easily used as a grpc.DialOption, eg:

option.WithGRPCDialOption(grpc.WithDialer(keepalive.DialerFunc))

Types

type TCPListener

type TCPListener struct {
	*net.TCPListener
}

TCPListener sets TCP keep-alive timeouts on accepted connections. It's used by ListenAndServe and ListenAndServeTLS so dead TCP connections (e.g. closing laptop mid-download) eventually go away.

Copied, renamed and exported from: https://github.com/golang/go/blob/d6bce32a3607222075734bf4363ca3fea02ea1e5/src/pkg/net/http/server.go#L1840-L1856 so we can use net.Listen + http.Serve.

func (TCPListener) Accept

func (ln TCPListener) Accept() (c net.Conn, err error)

Jump to

Keyboard shortcuts

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