Source file
src/net/sock_bsd.go
1
2
3
4
5
6
7 package net
8
9 import (
10 "runtime"
11 "syscall"
12 )
13
14 func maxListenerBacklog() int {
15 var (
16 n uint32
17 err error
18 )
19 switch runtime.GOOS {
20 case "darwin", "ios":
21 n, err = syscall.SysctlUint32("kern.ipc.somaxconn")
22 case "freebsd":
23 n, err = syscall.SysctlUint32("kern.ipc.soacceptqueue")
24 case "netbsd":
25
26 case "openbsd":
27 n, err = syscall.SysctlUint32("kern.somaxconn")
28 }
29 if n == 0 || err != nil {
30 return syscall.SOMAXCONN
31 }
32
33
34
35 if n > 1<<16-1 {
36 n = 1<<16 - 1
37 }
38 return int(n)
39 }
40
View as plain text