sockettransport

package
v0.0.0-...-6c4fd92 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: NIST-PD-fallback Imports: 11 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 {
	// MTU is maximum outgoing packet size.
	// The default is 16384.
	MTU 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"`
}

Counters contains socket transport counters.

func (Counters) String

func (cnt Counters) String() string

type Transport

type Transport interface {
	l3.Transport

	// Context returns a Context that is canceled when the transport is closed.
	Context() context.Context

	// 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.

func Dial

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

Dial opens a socket transport, according to the configuration in the 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