github.com/laof/lite-speed-test@v0.0.0-20230930011949-1f39b7037845/transport/dialer/sockopt_linux.go (about)

     1  //go:build linux
     2  // +build linux
     3  
     4  package dialer
     5  
     6  import (
     7  	"syscall"
     8  
     9  	"github.com/laof/lite-speed-test/common"
    10  	"golang.org/x/sys/unix"
    11  )
    12  
    13  func setReusePort(fd uintptr) error {
    14  	if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEPORT, 1); err != nil {
    15  		return common.NewError("failed to set SO_REUSEPORT").Base(err)
    16  	}
    17  	return nil
    18  }