package tcplisten

import "github.com/valyala/fasthttp/tcplisten"

Package tcplisten provides customizable TCP net.Listener with various performance-related options:

The package is derived from https://github.com/valyala/tcplisten

Index

Types

type Config

type Config struct {
	// ReusePort enables SO_REUSEPORT.
	ReusePort bool

	// DeferAccept enables TCP_DEFER_ACCEPT.
	DeferAccept bool

	// FastOpen enables TCP_FASTOPEN.
	FastOpen bool

	// Backlog is the maximum number of pending TCP connections the listener
	// may queue before passing them to Accept.
	// See man 2 listen for details.
	//
	// By default system-level backlog value is used.
	Backlog int
}

Config provides options to enable on the returned listener.

func (*Config) NewListener

func (cfg *Config) NewListener(network, addr string) (net.Listener, error)

NewListener returns TCP listener with options set in the Config.

The function may be called many times for creating distinct listeners with the given config.

Only tcp4 and tcp6 networks are supported.

Source Files

socket.go socket_other.go tcplisten.go tcplisten_linux.go

Version
v1.62.0 (latest)
Published
May 7, 2025
Platform
linux/amd64
Imports
9 packages
Last checked
3 weeks ago

Tools for package owners.