diff options
Diffstat (limited to 'util/network.go')
-rw-r--r-- | util/network.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/util/network.go b/util/network.go index b9066de7..f8f8fb36 100644 --- a/util/network.go +++ b/util/network.go @@ -1,3 +1,5 @@ +// +build !windows + package util import ( @@ -27,7 +29,15 @@ func CreateListener(address string) (net.Listener, error) { } } - return net.Listen(dsn[0], dsn[1]) + ls := net.ListenConfig{ + Control: func(network, address string, c syscall.RawConn) error { + return c.Control(func(descriptor uintptr) { + syscall.SetsockoptInt(int(descriptor), syscall.SOL_SOCKET, syscall.SO_REUSEPORT, 1) + }) + }, + } + + return ls.Listen(dsn[0], dsn[1]) } // fileExists checks if a file exists and is not a directory before we |