status-go/vendor/github.com/libp2p/go-reuseport/control_unix.go

27 lines
483 B
Go
Raw Normal View History

2022-04-01 16:16:46 +00:00
//go:build !plan9 && !windows && !wasm
// +build !plan9,!windows,!wasm
2019-06-09 07:24:20 +00:00
package reuseport
import (
"syscall"
"golang.org/x/sys/unix"
)
func Control(network, address string, c syscall.RawConn) error {
var err error
c.Control(func(fd uintptr) {
err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1)
if err != nil {
return
}
err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
if err != nil {
return
}
})
return err
}