summaryrefslogtreecommitdiff
path: root/util/network.go
diff options
context:
space:
mode:
Diffstat (limited to 'util/network.go')
-rw-r--r--util/network.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/util/network.go b/util/network.go
index b9066de7..54d29519 100644
--- a/util/network.go
+++ b/util/network.go
@@ -1,8 +1,11 @@
+// +build linux
+
package util
import (
"errors"
"fmt"
+ "github.com/valyala/tcplisten"
"net"
"os"
"strings"
@@ -27,6 +30,18 @@ func CreateListener(address string) (net.Listener, error) {
}
}
+ cfg := tcplisten.Config{
+ ReusePort: true,
+ DeferAccept: true,
+ FastOpen: true,
+ Backlog: 0,
+ }
+
+ // tcp4 is currently supported
+ if dsn[0] == "tcp" {
+ return cfg.NewListener("tcp4", dsn[1])
+ }
+
return net.Listen(dsn[0], dsn[1])
}