|
|
|
@ -3,6 +3,7 @@ package internet
|
|
|
|
|
import ( |
|
|
|
|
"net" |
|
|
|
|
"syscall" |
|
|
|
|
"golang.org/x/sys/unix" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
@ -13,11 +14,14 @@ const (
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func bindAddr(fd uintptr, ip []byte, port uint32) error { |
|
|
|
|
err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1) |
|
|
|
|
if err != nil { |
|
|
|
|
if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1); err != nil { |
|
|
|
|
return newError("failed to set resuse_addr").Base(err).AtWarning() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEPORT, 1); err != nil { |
|
|
|
|
return newError("failed to set resuse_port").Base(err).AtWarning() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var sockaddr syscall.Sockaddr |
|
|
|
|
|
|
|
|
|
switch len(ip) { |
|
|
|
|