tcp

package
v3.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 4, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package tcp provides various TCP-related utilities. The TCP mux code provided by this package originated with InfluxDB.

Index

Constants

View Source
const (
	// DefaultTimeout is the default length of time to wait for first byte.
	DefaultTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

func Dial

func Dial(network, address string, header byte) (net.Conn, error)

Dial connects to a remote mux listener with a given header byte.

Types

type Layer

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

Layer represents the connection between nodes.

func (*Layer) Accept

func (l *Layer) Accept() (net.Conn, error)

Accept waits for the next connection.

func (*Layer) Addr

func (l *Layer) Addr() net.Addr

Addr returns the local address for the layer.

func (*Layer) Close

func (l *Layer) Close() error

Close closes the layer.

func (*Layer) Dial

func (l *Layer) Dial(addr string, timeout time.Duration) (net.Conn, error)

Dial creates a new network connection.

type Mux

type Mux struct {

	// The amount of time to wait for the first header byte.
	Timeout time.Duration

	// Out-of-band error logger
	Logger *log.Logger
	// contains filtered or unexported fields
}

Mux multiplexes a network connection.

func NewMux

func NewMux(ln net.Listener, adv net.Addr) *Mux

NewMux returns a new instance of Mux for ln. If adv is nil, then the addr of ln is used.

func (*Mux) Listen

func (mux *Mux) Listen(header byte) *Layer

Listen returns a listener identified by header. Any connection accepted by mux is multiplexed based on the initial header byte.

func (*Mux) Serve

func (mux *Mux) Serve() error

Serve handles connections from ln and multiplexes then across registered listener.

Jump to

Keyboard shortcuts

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