A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pkg.go.dev/github.com/valyala/fasthttp/reuseport below:

reuseport package - github.com/valyala/fasthttp/reuseport - Go Packages

Package reuseport provides TCP net.Listener with SO_REUSEPORT support.

SO_REUSEPORT allows linear scaling server performance on multi-CPU servers. See https://www.nginx.com/blog/socket-sharding-nginx-release-1-9-1/ for more details :)

The package is based on https://github.com/kavu/go_reuseport .

This section is empty.

This section is empty.

Listen returns TCP listener with SO_REUSEPORT option set.

The returned listener tries enabling the following TCP options, which usually have positive impact on performance:

Only tcp4 and tcp6 networks are supported.

ErrNoReusePort error is returned if the system doesn't support SO_REUSEPORT.

package main

import (
	"fmt"
	"log"

	"github.com/valyala/fasthttp"
	"github.com/valyala/fasthttp/reuseport"
)

func main() {
	ln, err := reuseport.Listen("tcp4", "localhost:12345")
	if err != nil {
		log.Fatalf("error in reuseport listener: %v", err)
	}

	if err = fasthttp.Serve(ln, requestHandler); err != nil {
		log.Fatalf("error in fasthttp Server: %v", err)
	}
}

func requestHandler(ctx *fasthttp.RequestCtx) {
	fmt.Fprintf(ctx, "Hello, world!")
}
type ErrNoReusePort struct {
	
}

ErrNoReusePort is returned if the OS doesn't support SO_REUSEPORT.

Error implements error interface.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4