net

package
v1.0.159 Latest Latest
Warning

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

Go to latest
Published: May 1, 2021 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrListenerClosed = errListenerClosed("net: listener closed")

ErrListenerClosed is returned from Listener.Accept when the underlying listener is closed.

View Source
var INet6AToN = IPtoBigInt

INet6AToN returns the numeric value of an IPv6 address

View Source
var INet6NToA = ParseIPV6

INet6NToA returns the IPv6 address from a numeric value

View Source
var INetAToN = IP4toUInt32

INetAToN returns the numeric value of an IP address

View Source
var INetNToA = ParseIPV4

INetNToA returns the IP address from a numeric value

View Source
var Ipv4LoopbackHosts = []string{"localhost", "127.0.0.1"}
View Source
var Ipv6LoopbackHosts = []string{"localhost", "[::1]", "::1"}

Functions

func HostportOrDefault added in v0.0.67

func HostportOrDefault(hostport string, defHostport string) string

func IP4toUInt32 added in v0.0.150

func IP4toUInt32(ip net.IP) uint32

func IPtoBigInt added in v0.0.150

func IPtoBigInt(ip net.IP) *big.Int

func IsLoopbackHost

func IsLoopbackHost(host string) bool

func LoopbackListener

func LoopbackListener(ports ...string) (net.Listener, error)

LoopbackListener returns a loopback listener on a first usable port in ports or 0 if ports is empty

func OnceCloseListener

func OnceCloseListener(l net.Listener) net.Listener

OnceCloseListener wraps a net.Listener, protecting it from multiple Close calls.

func ParseIP added in v0.0.150

func ParseIP(s string) net.IP

func ParseIPV4 added in v0.0.150

func ParseIPV4(i uint32) net.IP

ParseIPV4 parses i as an IP address, returning the result. If i is not a valid integer representation of an IP address, ParseIP returns nil.

func ParseIPV6 added in v0.0.150

func ParseIPV6(s string, base int) net.IP

func RandomPort added in v0.0.67

func RandomPort(host string) (int, error)

func SplitHostPort added in v0.0.67

func SplitHostPort(hostport string) (host, port string, err error)

SplitHostPort splits a network address of the form "host:port", "host%zone:port", "[host]:port" or "[host%zone]:port" into host or host%zone and port. Different to net.SplitHostPort, host or port can be not set

A literal IPv6 address in hostport must be enclosed in square brackets, as in "[::1]:80", "[::1%lo0]:80".

See func Dial for a description of the hostport parameter, and host and port results.

func TcpKeepAliveListener

func TcpKeepAliveListener(l *net.TCPListener, d time.Duration) net.Listener

TcpKeepAliveListener 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.

Types

type IPFormat added in v0.0.150

type IPFormat net.IP

func (IPFormat) Format added in v0.0.150

func (ip IPFormat) Format(s fmt.State, verb rune)

type MultiListener

type MultiListener struct {
	*NotifyListener

	// ErrorLog specifies an optional logger for errors accepting
	// connections, unexpected behavior from handlers, and
	// underlying FileSystem errors.
	// If nil, logging is done via the log package's standard logger.
	ErrorLog *log.Logger
	// contains filtered or unexported fields
}

MultiListener is a net.Listener that accepts all the connections from all listeners.

func NewMultiListener

func NewMultiListener(listeners ...net.Listener) *MultiListener

func (*MultiListener) Accept

func (l *MultiListener) Accept() (net.Conn, error)

func (*MultiListener) Addr

func (l *MultiListener) Addr() net.Addr

Addr returns the listener's network address.

func (*MultiListener) Close

func (l *MultiListener) Close() error

type NotifyListener

type NotifyListener struct {
	C chan net.Conn
	// contains filtered or unexported fields
}

func NewNotifyListener

func NewNotifyListener() *NotifyListener

NewNotifyListener creates a new Listener that will recv conns on its channel.

func (*NotifyListener) Accept

func (l *NotifyListener) Accept() (net.Conn, error)

func (*NotifyListener) Addr

func (l *NotifyListener) Addr() net.Addr

Addr returns the listener's network address.

func (*NotifyListener) Close

func (l *NotifyListener) Close() error

Stop prevents the NotifyListener from firing. To ensure the channel is empty after a call to Close, check the return value and drain the channel.

func (*NotifyListener) DoneC

func (l *NotifyListener) DoneC() <-chan struct{}

DoneC returns whether this listener has been closed for multi producers of C

Directories

Path Synopsis
https://tools.ietf.org/html/rfc7064 https://tools.ietf.org/html/rfc7064 3.2.
https://tools.ietf.org/html/rfc7064 https://tools.ietf.org/html/rfc7064 3.2.
mux
Package mux is a library to multiplex network connections based on their payload.
Package mux is a library to multiplex network connections based on their payload.

Jump to

Keyboard shortcuts

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