Documentation ¶
Index ¶
- Constants
- Variables
- func DialContext(ctx context.Context, network, address string) (net.Conn, error)
- func DialContextWithOptions(ctx context.Context, network, address string, opts *Options) (net.Conn, error)
- func DialHappyEyeballs(ctx context.Context, ips []*net.TCPAddr) (net.Conn, error)
- func DialParallel(ctx context.Context, primaries []*net.TCPAddr, fallbacks []*net.TCPAddr) (net.Conn, error)
- func DialSerial(ctx context.Context, ras []*net.TCPAddr) (net.Conn, error)
- func LinuxMarkSymbol(fd int32, mark int) error
- func ListenContext(ctx context.Context, network string, address string) (net.Listener, error)
- func ListenContextWithOptions(ctx context.Context, network string, address string, opts *Options) (net.Listener, error)
- func ListenPacket(network, address string) (net.PacketConn, error)
- func ListenPacketWithOptions(network, address string, opts *Options) (net.PacketConn, error)
- func PartialDeadline(now, deadline time.Time, addrsRemaining int) (time.Time, error)
- func PartialDeadlineCtx(ctx context.Context, addrsRemaining int) (context.Context, context.CancelFunc, error)
- type Options
Constants ¶
const SocketBufferSize = 7 << 20
UDP socket read/write buffer size (7MB). The value of 7MB is chosen as it is the max supported by a default configuration of macOS. Some platforms will silently clamp the value to other maximums, such as linux clamping to net.core.{r,w}mem_max (see _linux.go for additional implementation that works around this limitation)
Variables ¶
var ( DefaultInterfaceName = "" DefaultInterfaceIndex = 0 DefaultRoutingMark = 0 // maybe need root permission DefaultMarkSymbol func(socket int32) bool )
Functions ¶
func DialContextWithOptions ¶
func DialHappyEyeballs ¶ added in v0.3.5
DialHappyEyeballs is a function that implements Happy Eyeballs algorithm for IPv4 and IPv6 addresses. It divides given TCP addresses into primaries and fallbacks and then calls DialParallel function.
It takes a context and a slice of TCP addresses as input and returns a net.Conn and an error.
func DialParallel ¶ added in v0.3.5
func DialParallel(ctx context.Context, primaries []*net.TCPAddr, fallbacks []*net.TCPAddr) (net.Conn, error)
https://github.com/golang/go/blob/315b6ae682a2a4e7718924a45b8b311a0fe10043/src/net/dial.go#L534
dialParallel races two copies of dialSerial, giving the first a head start. It returns the first established connection and closes the others. Otherwise it returns an error from the first primary address.
func DialSerial ¶ added in v0.3.5
DialSerial connects to a list of addresses in sequence, returning either the first successful connection, or the first error.
func LinuxMarkSymbol ¶
func ListenContext ¶
func ListenPacket ¶
func ListenPacket(network, address string) (net.PacketConn, error)
func ListenPacketWithOptions ¶
func ListenPacketWithOptions(network, address string, opts *Options) (net.PacketConn, error)
func PartialDeadline ¶ added in v0.3.5
PartialDeadline returns the deadline to use for a single address, when multiple addresses are pending.
func PartialDeadlineCtx ¶ added in v0.3.5
Types ¶
type Options ¶
type Options struct { // InterfaceName is the name of interface/device to bind. // If a socket is bound to an interface, only packets received // from that particular interface are processed by the socket. InterfaceName string // InterfaceIndex is the index of interface/device to bind. // It is almost the same as InterfaceName except it uses the // index of the interface instead of the name. InterfaceIndex int // RoutingMark is the mark for each packet sent through this // socket. Changing the mark can be used for mark-based routing // without netfilter or for packet filtering. MarkSymbol func(socket int32) bool // contains filtered or unexported fields }