sockettransport

package
v0.0.0-...-c2e30b8 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: NIST-PD-fallback Imports: 8 Imported by: 2

Documentation

Overview

Package sockettransport implements a transport based on stream or datagram sockets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	l3.TransportQueueConfig

	// RxBufferLength is the packet buffer length allocated for incoming packets.
	// The default is 16384.
	// Packet larger than this length cannot be received.
	RxBufferLength int

	// RedialBackoffInitial is the initial backoff period during redialing.
	// The default is 100ms.
	RedialBackoffInitial time.Duration

	// RedialBackoffMaximum is the maximum backoff period during redialing.
	// The default is 60s.
	// The minimum is RedialBackoffInitial.
	RedialBackoffMaximum time.Duration
}

Config contains socket transport configuration.

type Counters

type Counters struct {
	// NRedials indicates how many times the socket has been redialed.
	NRedials int `json:"nRedials"`

	// RxQueueLength is the current number of packets in the RX queue.
	RxQueueLength int

	// RxQueueLength is the current number of packets in the TX queue.
	TxQueueLength int
}

Counters contains socket transport counters.

func (Counters) String

func (cnt Counters) String() string

type Dialer

type Dialer struct {
	Config
}

Dialer contains settings for Dial.

func (Dialer) Dial

func (dialer Dialer) Dial(network, local, remote string) (Transport, error)

Dial opens a socket transport, according to the configuration in the Dialer.

type Transport

type Transport interface {
	l3.Transport

	// Conn returns the underlying socket.
	// Caller may gather information from this socket, but should not close or send/receive on it.
	// The socket may be replaced during redialing.
	Conn() net.Conn

	// Counters returns current counters.
	Counters() Counters
}

Transport is an l3.Transport that communicates over a socket.

A transport has automatic error handling: if a socket error occurs, the transport automatically redials the socket. In case the socket cannot be redialed, the transport remains in "down" status.

A transport closes itself after its TX channel has been closed.

func Dial

func Dial(network, local, remote string) (Transport, error)

Dial opens a socket transport using a default Dialer.

func New

func New(conn net.Conn, cfg Config) (Transport, error)

New creates a socket transport.

func Pipe

func Pipe(cfg Config) (trA, trB Transport, e error)

Pipe creates a pair of transports connected via net.Pipe().

Jump to

Keyboard shortcuts

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