From 07aa486d431dd7e5c5150bd2b251904490de6ef4 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Sun, 30 Sep 2018 19:37:08 +0200 Subject: [PATCH] fix bind address in linux --- transport/internet/sockopt_linux.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/transport/internet/sockopt_linux.go b/transport/internet/sockopt_linux.go index 35063c3f..a6db0ed4 100644 --- a/transport/internet/sockopt_linux.go +++ b/transport/internet/sockopt_linux.go @@ -14,6 +14,11 @@ const ( ) func bindAddr(fd uintptr, address net.Address, port net.Port) error { + err = syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1) + if err != nil { + return newError("failed to set resuse_addr").Base(err).AtWarning() + } + var sockaddr syscall.Sockaddr switch address.Family() {