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