package tcplisten
Import Path
github.com/valyala/tcplisten (on go.dev)
Dependency Relation
imports 8 packages, and imported by one package
Involved Source Files
socket.go
socket_other.go
Package tcplisten provides customizable TCP net.Listener with various
performance-related options:
- SO_REUSEPORT. This option allows linear scaling server performance
on multi-CPU servers.
See https://www.nginx.com/blog/socket-sharding-nginx-release-1-9-1/ for details.
- TCP_DEFER_ACCEPT. This option expects the server reads from the accepted
connection before writing to them.
- TCP_FASTOPEN. See https://lwn.net/Articles/508865/ for details.
The package is derived from https://github.com/kavu/go_reuseport .
tcplisten_linux.go
Package-Level Type Names (only one)
Config provides options to enable on the returned listener.
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.
DeferAccept enables TCP_DEFER_ACCEPT.
FastOpen enables TCP_FASTOPEN.
ReusePort enables SO_REUSEPORT.
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.
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |