tcp

package
v0.0.0-...-40e4417 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package tcp provides a simple multiplexer over TCP. implemented by influxdb: https://github.com/influxdata/influxdb/tree/master/tcp

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.

func DialWithTimeout

func DialWithTimeout(network, address string, timeout time.Duration, header byte) (net.Conn, error)

DialWithTimeout connects to a remote mux listener with a given header byte and timeout

Types

type Mux

type Mux struct {

	// The amount of time to wait for the first header byte.
	Timeout time.Duration
	// contains filtered or unexported fields
}

Mux multiplexes a network connection.

func NewMux

func NewMux(ln net.Listener) *Mux

NewMux returns a new instance of Mux.

func (*Mux) Close

func (mux *Mux) Close() error

Close should directly close the original net listener

func (*Mux) DefaultListener

func (mux *Mux) DefaultListener() net.Listener

DefaultListener will return a net.Listener that will pass-through any connections with non-registered values for the first byte of the connection. The connections returned from this listener's Accept() method will replay the first byte of the connection as a short first Read().

This can be used to pass to an HTTP server, so long as there are no conflicts with registered listener bytes and the first character of the HTTP request: 71 ('G') for GET, etc.

func (*Mux) Listen

func (mux *Mux) Listen(header byte) net.Listener

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

func (*Mux) Start

func (mux *Mux) Start() error

Start handles connections from ln and multiplexes then across registered listeners.

func (*Mux) WithLogger

func (mux *Mux) WithLogger(logger *zap.Logger)

WithLogger use customed logger

Jump to

Keyboard shortcuts

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