← All projects

darvaza.org/x/net

Generic network helpers — port binding with retry, reconnecting TCP clients.

Network helpers extending Go's standard net package. Top-level utilities validate and split host/port pairs, and define a Dialer interface compatible with *net.Dialer.

The bind sub-package provides advanced port binding — multi-interface and multi-address listening, automatic port retry with configurable attempts, SO_REUSEADDR/SO_REUSEPORT control, and a context-aware ListenConfig that creates TCP listeners and UDP connections in bulk.

The reconnect sub-package implements a generic reconnecting client for TCP and Unix domain sockets. Lifecycle callbacks (OnConnect, OnSession, OnDisconnect, OnError) drive application logic, while configurable backoff and context-based cancellation manage retries. A generic StreamSession[Input, Output] adds message-oriented I/O with pluggable codecs and stampede-safe send/receive channels.

See also§