SoMaxConnAction Class — netty Architecture
Architecture documentation for the SoMaxConnAction class in NetUtil.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 58fef720_ddf5_68f0_b476_d4114092fcab["SoMaxConnAction"] be5c82e6_a4ae_6473_ea92_9debc12b2bf9["NetUtil.java"] 58fef720_ddf5_68f0_b476_d4114092fcab -->|defined in| be5c82e6_a4ae_6473_ea92_9debc12b2bf9 6f9dbf4f_8251_66a7_a81b_07a19c04df34["Integer()"] 58fef720_ddf5_68f0_b476_d4114092fcab -->|method| 6f9dbf4f_8251_66a7_a81b_07a19c04df34
Relationship Graph
Source Code
common/src/main/java/io/netty/util/NetUtil.java lines 171–228
private static final class SoMaxConnAction implements PrivilegedAction<Integer> {
@Override
public Integer run() {
// Determine the default somaxconn (server socket backlog) value of the platform.
// The known defaults:
// - Windows NT Server 4.0+: 200
// - Mac OS X: 128
// - Linux kernel > 5.4 : 4096
int somaxconn;
if (PlatformDependent.isWindows()) {
somaxconn = 200;
} else if (PlatformDependent.isOsx()) {
somaxconn = 128;
} else {
somaxconn = 4096;
}
File file = new File("/proc/sys/net/core/somaxconn");
try {
// file.exists() may throw a SecurityException if a SecurityManager is used, so execute it in the
// try / catch block.
// See https://github.com/netty/netty/issues/4936
if (file.exists()) {
try (BufferedReader in = new BufferedReader(new InputStreamReader(
new BoundedInputStream(new FileInputStream(file))))) {
somaxconn = Integer.parseInt(in.readLine());
if (logger.isDebugEnabled()) {
logger.debug("{}: {}", file, somaxconn);
}
}
} else {
// Try to get from sysctl
Integer tmp = null;
if (SystemPropertyUtil.getBoolean("io.netty.net.somaxconn.trySysctl", false)) {
tmp = sysctlGetInt("kern.ipc.somaxconn");
if (tmp == null) {
tmp = sysctlGetInt("kern.ipc.soacceptqueue");
if (tmp != null) {
somaxconn = tmp;
}
} else {
somaxconn = tmp;
}
}
if (tmp == null) {
logger.debug("Failed to get SOMAXCONN from sysctl and file {}. Default: {}", file,
somaxconn);
}
}
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to get SOMAXCONN from sysctl and file {}. Default: {}",
file, somaxconn, e);
}
}
return somaxconn;
}
}
Source
Frequently Asked Questions
What is the SoMaxConnAction class?
SoMaxConnAction is a class in the netty codebase, defined in common/src/main/java/io/netty/util/NetUtil.java.
Where is SoMaxConnAction defined?
SoMaxConnAction is defined in common/src/main/java/io/netty/util/NetUtil.java at line 171.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free