multidial

package module
v0.0.0-...-b982b1e Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Error         = errs.Class("multidial")
	ErrConnClosed = errs.Class("conn closed")
)

Functions

This section is empty.

Types

type DialFunc

type DialFunc func(ctx context.Context, network, address string) (net.Conn, error)

type Multidialer

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

Multidialer is a wrapper type that wraps two other dialers. It is intended to support finding the fastest dialing approach (which may be 0-RTT) by simply dialing both connections simultaneously. Because the fastest dialing approach might be 0-RTT, the first packet may have some written data in it. So, Multidialer's Dial method is actually a no-op, and the dialing happens on the first Write call to the returned Conn. Write calls to returned Conns will duplicate writes to both underlying connections until the first Read or when an error is received, whichever is first. It is expected that this type would be used with something like github.com/jtolio/noiseconn/debounce on the server side.

func NewMultidialer

func NewMultidialer(dialer1, dialer2 DialFunc) *Multidialer

func (*Multidialer) Dial

func (m *Multidialer) Dial(network, address string) (net.Conn, error)

func (*Multidialer) DialContext

func (m *Multidialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

Jump to

Keyboard shortcuts

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