Documentation
¶
Overview ¶
Package reuseport provides a function that returns a net.Listener powered by a net.FileListener with a SO_REUSEPORT option set to the socket.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenPacket ¶ added in v1.2.0
func ListenPacket(proto, addr string) (l net.PacketConn, err error)
ListenPacket is an alias for NewReusablePortPacketConn.
func NewReusablePortListener ¶
NewReusablePortListener returns net.FileListener that created from a file discriptor for a socket with SO_REUSEPORT option.
Example ¶
listener, err := NewReusablePortListener("tcp", ":8881") if err != nil { panic(err) } defer listener.Close() server := &http.Server{} http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Println(os.Getgid()) fmt.Fprintf(w, "Hello, %q\n", html.EscapeString(r.URL.Path)) }) panic(server.Serve(listener))
Output:
func NewReusablePortPacketConn ¶ added in v1.2.0
func NewReusablePortPacketConn(proto, addr string) (l net.PacketConn, err error)
NewReusablePortPacketConn returns net.FilePacketConn that created from a file discriptor for a socket with SO_REUSEPORT option.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.