Source File
sock_linux.go
Belonging Package
net
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package net
import (
)
// Linux stores the backlog as:
//
// - uint16 in kernel version < 4.1,
// - uint32 in kernel version >= 4.1
//
// Truncate number to avoid wrapping.
//
// See issue 5030 and 41470.
func maxAckBacklog( int) int {
, := unix.KernelVersion()
:= 16
if > 4 || ( == 4 && >= 1) {
= 32
}
var uint = 1<< - 1
if uint() > {
= int()
}
return
}
func maxListenerBacklog() int {
, := open("/proc/sys/net/core/somaxconn")
if != nil {
return syscall.SOMAXCONN
}
defer .close()
, := .readLine()
if ! {
return syscall.SOMAXCONN
}
:= getFields()
, , := dtoi([0])
if == 0 || ! {
return syscall.SOMAXCONN
}
if > 1<<16-1 {
return maxAckBacklog()
}
return
}
The pages are generated with Golds v0.7.0-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |