p2p

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTransport = Transport{
	DialContext: (&net.Dialer{
		Timeout:   30 * time.Second,
		KeepAlive: 30 * time.Second,
		DualStack: true,
	}).DialContext,
}

DefaultTransport implements the default dialing strategy

View Source
var ErrUnknownMessage = errors.New("unknown message")

Functions

This section is empty.

Types

type Conn

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

Conn is a connection between two waves nodes

func NewConn

func NewConn(options ...ConnOption) (*Conn, error)

NewConn creates a new connection

func (*Conn) Close added in v0.2.0

func (c *Conn) Close()

func (*Conn) Dial

func (c *Conn) Dial(network, addr string) error

Dial is a wrapper around DialContext

func (*Conn) DialContext

func (c *Conn) DialContext(ctx context.Context, network, addr string) error

DialContext dials a remote andpoint

func (*Conn) ReadMessage added in v0.2.0

func (c *Conn) ReadMessage() (interface{}, error)

func (*Conn) ReadWithDeadline added in v0.2.0

func (c *Conn) ReadWithDeadline(deadLine time.Time) (interface{}, error)

ReadWithDeadline reads a message with a deadline

func (*Conn) RemoteAddr added in v0.2.0

func (c *Conn) RemoteAddr() net.Addr

func (*Conn) SendMessage added in v0.2.0

func (c *Conn) SendMessage(m interface{}) error

type ConnOption

type ConnOption func(*Conn) error

ConnOption is a connection creation option

func WithContext added in v0.2.0

func WithContext(ctx context.Context) ConnOption

WithContext is an option to add a context to the connection

func WithNetConn added in v0.2.0

func WithNetConn(conn net.Conn) ConnOption

func WithRemote

func WithRemote(network, addr string) ConnOption

WithRemote is an option for remote endpoint

func WithTransport

func WithTransport(t *Transport) ConnOption

WithTransport is an option for custom transport of the connection

type Transport

type Transport struct {
	DialContext func(ctx context.Context, network, addr string) (net.Conn, error)
}

Transport allows one to reimplement the way we dial a peer

Jump to

Keyboard shortcuts

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