tcplisten

package module
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: MIT Imports: 8 Imported by: 130

README

Build Status GoDoc Go Report

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

Documentation.

The package is derived from go_reuseport.

Documentation

Overview

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 .

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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.

Jump to

Keyboard shortcuts

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