simple

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2020 License: Apache-2.0 Imports: 9 Imported by: 11

Documentation

Overview

Package simple contains simplistic implementation for the wire.Dialer and wire.Listener interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialer

type Dialer struct {
	pkgsync.Closer
	// contains filtered or unexported fields
}

Dialer is a simple lookup-table based dialer that can dial known peers. New peer addresses can be added via Register().

func NewNetDialer

func NewNetDialer(network string, defaultTimeout time.Duration) *Dialer

NewNetDialer creates a new dialer with a preset default timeout for dial attempts. Leaving the timeout as 0 will result in no timeouts. Standard OS timeouts may still apply even when no timeout is selected. The network string controls the type of connection that the dialer can dial.

func NewTCPDialer

func NewTCPDialer(defaultTimeout time.Duration) *Dialer

NewTCPDialer is a short-hand version of NewNetDialer for creating TCP dialers.

func NewUnixDialer

func NewUnixDialer(defaultTimeout time.Duration) *Dialer

NewUnixDialer is a short-hand version of NewNetDialer for creating Unix dialers.

func (*Dialer) Dial

func (d *Dialer) Dial(ctx context.Context, addr wire.Address) (wirenet.Conn, error)

Dial implements Dialer.Dial().

func (*Dialer) Register

func (d *Dialer) Register(addr wire.Address, address string)

Register registers a network address for a peer address.

type Listener

type Listener struct {
	net.Listener
}

Listener is a TCP Listener.

func NewNetListener

func NewNetListener(network string, address string) (*Listener, error)

NewNetListener creates a listener reachable under the requested address.

func NewTCPListener

func NewTCPListener(address string) (*Listener, error)

NewTCPListener is a short-hand version of NewNetListener for TCP listeners.

func NewUnixListener

func NewUnixListener(address string) (*Listener, error)

NewUnixListener is a short-hand version of NewNetListener for Unix listeners.

func (*Listener) Accept

func (l *Listener) Accept() (wirenet.Conn, error)

Accept implements peer.Dialer.Accept().

Jump to

Keyboard shortcuts

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