transport

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	manet.Conn

	Transport() Transport
}

Conn is an extension of the net.Conn interface that provides multiaddr information, and an accessor for the transport used to create the conn

type DialOpt

type DialOpt interface{}

DialOpt is an option used for configuring dialer behaviour

type Dialer

type Dialer interface {
	Dial(raddr ma.Multiaddr) (Conn, error)
	DialContext(ctx context.Context, raddr ma.Multiaddr) (Conn, error)
	Matches(ma.Multiaddr) bool
}

Dialer is an abstraction that is normally filled by an object containing information/options around how to perform the dial. An example would be setting TCP dial timeout for all dials made, or setting the local address that we dial out from.

type FallbackDialer

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

func (*FallbackDialer) Dial

func (fbd *FallbackDialer) Dial(a ma.Multiaddr) (Conn, error)

func (*FallbackDialer) DialContext

func (fbd *FallbackDialer) DialContext(ctx context.Context, a ma.Multiaddr) (Conn, error)

func (*FallbackDialer) Matches

func (fbd *FallbackDialer) Matches(a ma.Multiaddr) bool

type Listener

type Listener interface {
	Accept() (Conn, error)
	Close() error
	Addr() net.Addr
	Multiaddr() ma.Multiaddr
}

Listener is an interface closely resembling the net.Listener interface. The only real difference is that Accept() returns Conn's of the type in this package, and also exposes a Multiaddr method as opposed to a regular Addr method

type ReuseportOpt

type ReuseportOpt bool
var ReusePorts ReuseportOpt = true

type Transport

type Transport interface {
	Dialer(laddr ma.Multiaddr, opts ...DialOpt) (Dialer, error)
	Listen(laddr ma.Multiaddr) (Listener, error)
	Matches(ma.Multiaddr) bool
}

Transport represents any device by which you can connect to and accept connections from other peers. The built-in transports provided are TCP and UTP but many more can be implemented, sctp, audio signals, sneakernet, UDT, a network of drones carrying usb flash drives, and so on.

Jump to

Keyboard shortcuts

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