tcpreuse

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2020 License: AGPL-3.0, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWrongProto = errors.New("can only dial TCP over IPv4 or IPv6")

ErrWrongProto is returned when dialing a protocol other than tcp.

Functions

This section is empty.

Types

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

Transport is a TCP reuse transport that reuses listener ports.

func (*Transport) Dial

func (t *Transport) Dial(raddr ma.Multiaddr) (manet.Conn, error)

Dial dials the given multiaddr, reusing ports we're currently listening on if possible.

Dial attempts to be smart about choosing the source port. For example, If we're dialing a loopback address and we're listening on one or more loopback ports, Dial will randomly choose one of the loopback ports and addresses and reuse it.

func (*Transport) DialContext

func (t *Transport) DialContext(ctx context.Context, raddr ma.Multiaddr) (manet.Conn, error)

DialContext is like Dial but takes a context.

func (*Transport) Listen

func (t *Transport) Listen(laddr ma.Multiaddr) (manet.Listener, error)

Listen listens on the given multiaddr.

If reuseport is supported, it will be enabled for this listener and future dials from this transport may reuse the port.

Note: You can listen on the same multiaddr as many times as you want (although only *one* listener will end up handling the inbound connection).

Jump to

Keyboard shortcuts

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