This package provide 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.
24 lines
451 B
Go
24 lines
451 B
Go
// +build darwin dragonfly freebsd netbsd openbsd rumprun
|
|
|
|
package tcplisten
|
|
|
|
import (
|
|
"syscall"
|
|
)
|
|
|
|
const soReusePort = syscall.SO_REUSEPORT
|
|
|
|
func enableDeferAccept(fd int) error {
|
|
// TODO: implement SO_ACCEPTFILTER:dataready here
|
|
return nil
|
|
}
|
|
|
|
func enableFastOpen(fd int) error {
|
|
// TODO: implement TCP_FASTOPEN when it will be ready
|
|
return nil
|
|
}
|
|
|
|
func soMaxConn() (int, error) {
|
|
// TODO: properly implement it
|
|
return syscall.SOMAXCONN, nil
|
|
}
|