Home / Function/ Integer() — netty Function Reference

Integer() — netty Function Reference

Architecture documentation for the Integer() function in NetUtil.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  6f9dbf4f_8251_66a7_a81b_07a19c04df34["Integer()"]
  58fef720_ddf5_68f0_b476_d4114092fcab["SoMaxConnAction"]
  6f9dbf4f_8251_66a7_a81b_07a19c04df34 -->|defined in| 58fef720_ddf5_68f0_b476_d4114092fcab
  style 6f9dbf4f_8251_66a7_a81b_07a19c04df34 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

common/src/main/java/io/netty/util/NetUtil.java lines 172–227

        @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;
        }

Domain

Subdomains

Frequently Asked Questions

What does Integer() do?
Integer() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/NetUtil.java.
Where is Integer() defined?
Integer() is defined in common/src/main/java/io/netty/util/NetUtil.java at line 172.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free