tnet

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Join

func Join(host string, port uint16) string

Join joins host and port.

func JoinScheme

func JoinScheme(scheme, host string, port uint16) string

JoinScheme joins scheme, hsot and port.

func Listen

func Listen(ctx context.Context, address string) (net.Listener, error)

Listen installs a listener on the specified address.

If the address string starts with "tcp:", the rest is interpreted as [address]:port on which to open a TCP listening socket. TCP keep-alive is enabled in this case.

If the address string starts with "unix:", the rest is interpreted the path to a UNIX domain socket to listen on.

If neither prefix is present, "tcp:" is assumed.

func ListenOnRandomPort

func ListenOnRandomPort(ctx context.Context, network Network) (net.Listener, error)

ListenOnRandomPort selects a random local port using specified network type and installs a listener on.

Types

type Network

type Network string

Network represents network.

const (
	// NetworkTCP represents tcp network.
	NetworkTCP Network = "tcp"

	// NetworkUnix represents unix network.
	NetworkUnix Network = "unix"
)

Jump to

Keyboard shortcuts

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