Home / Function/ InetAddress() — netty Function Reference

InetAddress() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  cc85d9b2_7b73_14a5_b35e_ad071f8fc178["InetAddress()"]
  40fb3f7d_c2dd_316b_f965_bdef8e0dad94["NetUtil"]
  cc85d9b2_7b73_14a5_b35e_ad071f8fc178 -->|defined in| 40fb3f7d_c2dd_316b_f965_bdef8e0dad94
  f5782167_2420_ff99_4480_b2d1e67eedd2["isValidIpV4Address()"]
  cc85d9b2_7b73_14a5_b35e_ad071f8fc178 -->|calls| f5782167_2420_ff99_4480_b2d1e67eedd2
  42de1372_5ffc_33b5_49ba_958b59b48626["validIpV4ToBytes()"]
  cc85d9b2_7b73_14a5_b35e_ad071f8fc178 -->|calls| 42de1372_5ffc_33b5_49ba_958b59b48626
  18d4d9ec_e642_8239_767f_3cf0665429c5["isValidIpV6Address()"]
  cc85d9b2_7b73_14a5_b35e_ad071f8fc178 -->|calls| 18d4d9ec_e642_8239_767f_3cf0665429c5
  b30e6fa5_6204_a80f_b331_d6314fb87ddb["getIPv6ByName()"]
  cc85d9b2_7b73_14a5_b35e_ad071f8fc178 -->|calls| b30e6fa5_6204_a80f_b331_d6314fb87ddb
  style cc85d9b2_7b73_14a5_b35e_ad071f8fc178 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

common/src/main/java/io/netty/util/NetUtil.java lines 310–357

    public static InetAddress createInetAddressFromIpAddressString(String ipAddressString) {
        if (isValidIpV4Address(ipAddressString)) {
            byte[] bytes = validIpV4ToBytes(ipAddressString);
            try {
                return InetAddress.getByAddress(bytes);
            } catch (UnknownHostException e) {
                // Should never happen!
                throw new IllegalStateException(e);
            }
        }

        if (isValidIpV6Address(ipAddressString)) {
            if (ipAddressString.charAt(0) == '[') {
                ipAddressString = ipAddressString.substring(1, ipAddressString.length() - 1);
            }

            int percentPos = ipAddressString.indexOf('%');
            if (percentPos >= 0) {
                try {
                    int scopeId = Integer.parseInt(ipAddressString.substring(percentPos + 1));
                    ipAddressString = ipAddressString.substring(0, percentPos);
                    byte[] bytes = getIPv6ByName(ipAddressString, true);
                    if (bytes == null) {
                        return null;
                    }
                    try {
                        return Inet6Address.getByAddress(null, bytes, scopeId);
                    } catch (UnknownHostException e) {
                        // Should never happen!
                        throw new IllegalStateException(e);
                    }
                } catch (NumberFormatException e) {
                    return null;
                }
            }
            byte[] bytes = getIPv6ByName(ipAddressString, true);
            if (bytes == null) {
                return null;
            }
            try {
                return InetAddress.getByAddress(bytes);
            } catch (UnknownHostException e) {
                // Should never happen!
                throw new IllegalStateException(e);
            }
        }
        return null;
    }

Domain

Subdomains

Frequently Asked Questions

What does InetAddress() do?
InetAddress() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/NetUtil.java.
Where is InetAddress() defined?
InetAddress() is defined in common/src/main/java/io/netty/util/NetUtil.java at line 310.
What does InetAddress() call?
InetAddress() calls 4 function(s): getIPv6ByName, isValidIpV4Address, isValidIpV6Address, validIpV4ToBytes.

Analyze Your Own Codebase

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

Try Supermodel Free