Returns IP field of the message as IP, if the message was created
with ATYP of HOSTNAME, it will attempt to resolve the hostname,
which might fail.
@throws UnknownHostException if host can't be resolved.
176872
public InetAddress getInetAddress() throws UnknownHostException{
     if(ip!=null) return ip;

     return (ip=InetAddress.getByName(host));
   }
982389
public static final String getHostName() {
		if (cachedHostName != null) {
			return cachedHostName;
		}

		// User-defined public hostname
		String name = System.getProperty("hostname");
		if (name == null || name.isEmpty()) {
			try {
				name = InetAddress.getLocalHost().getHostName();
			} catch (Exception ignored) {
				name = null;
			}
		}
		if (name == null || name.isEmpty() || name.contains("localhost")) {
			try {
				name = System.getenv().get("COMPUTERNAME");
			} catch (Exception ignored) {
				name = null;
			}
		}
		if (name == null || name.isEmpty()) {
			cachedHostName = "localhost";
		} else {
			cachedHostName = name.toLowerCase();
		}
		return cachedHostName;
	}
893952
private void resolve(String hostname, List<InetAddress> inetAddresses) throws NamingException, UnknownHostException {

        if (preferIpv6 || (!preferIpv4 && !preferIpv6)) {

            inetAddresses.addAll(resolve(hostname, "AAAA"));
            inetAddresses.addAll(resolve(hostname, "A"));
        } else {

            inetAddresses.addAll(resolve(hostname, "A"));
            inetAddresses.addAll(resolve(hostname, "AAAA"));
        }

        if (inetAddresses.isEmpty()) {
            inetAddresses.addAll(resolveCname(hostname));
        }
    }
1256746
protected String getHostHeader() {
        if (m_hostHeader != null) {
            return m_hostHeader;
        }

        if (!httpAdminListener.m_publicIntf.isEmpty()) {
            m_hostHeader = httpAdminListener.m_publicIntf;
            return m_hostHeader;
        }

        InetAddress addr = null;
        int httpPort = VoltDB.DEFAULT_HTTP_PORT;
        try {
            String localMetadata = VoltDB.instance().getLocalMetadata();
            JSONObject jsObj = new JSONObject(localMetadata);
            JSONArray interfaces = jsObj.getJSONArray("interfaces");
            //The first interface is external interface if specified.
            String iface = interfaces.getString(0);
            addr = InetAddress.getByName(iface);
            httpPort = jsObj.getInt("httpPort");
        } catch (Exception e) {
            m_log.warn("Failed to get HTTP interface information.", e);
        }
        if (addr == null) {
            addr = org.voltcore.utils.CoreUtils.getLocalAddress();
        }
        //Make the header string.
        m_hostHeader = addr.getHostAddress() + ":" + httpPort;
        return m_hostHeader;
    }
693371
public InetAddress host() {
        try {
            return InetAddress.getByName(host.address());
        } catch (UnknownHostException e) {
            throw new IllegalStateException(e);
        }
    }
706541
@SuppressWarnings("rawtypes")
    private List<InetAddress> resolve(String hostname, String attrName) throws NamingException, UnknownHostException {

        Attributes attrs = context.getAttributes(hostname, new String[] { attrName });

        List<InetAddress> inetAddresses = new ArrayList<>();
        Attribute attr = attrs.get(attrName);

        if (attr != null && attr.size() > 0) {
            NamingEnumeration e = attr.getAll();

            while (e.hasMore()) {
                InetAddress inetAddress = InetAddress.getByName("" + e.next());
                inetAddresses.add(InetAddress.getByAddress(hostname, inetAddress.getAddress()));
            }
        }

        return inetAddresses;
    }
1082743
public BoltServerAddress resolve() throws UnknownHostException
    {
        String ipAddress = InetAddress.getByName( host ).getHostAddress();
        if ( ipAddress.equals( host ) )
        {
            return this;
        }
        else
        {
            return new BoltServerAddress( host, ipAddress, port );
        }
    }
1301693
public static InetSocketAddress getAddress (String hostname, int port)
    {
        return StringUtil.isBlank(hostname) ?
            new InetSocketAddress(port) : new InetSocketAddress(hostname, port);
    }
359973
public static String getLocalHostName() throws SocketException, UnknownHostException {
        try {
            final String canonicalHostName = InetAddress.getLocalHost().getCanonicalHostName();
            if (isFQDN(canonicalHostName)) {
                return canonicalHostName;
            } else {
                return InetAddress.getLocalHost().getHostName();
            }
        } catch (UnknownHostException e) {
            NetworkInterface networkInterface = NetworkInterface.getNetworkInterfaces().nextElement();
            if (networkInterface == null)
                throw e;
            InetAddress ipAddress = networkInterface.getInetAddresses().nextElement();
            if (ipAddress == null)
                throw e;
            return ipAddress.getHostAddress();
        }
    }
1175655
public HostName toHostName() {
		HostName host = fromHost;
		if(host == null) {
			fromHost = host = toCanonicalHostName();
		}
		return host;
	}
201307
public String getHost()
    {
        if (_address == null || _address.getAddress() == null)
            return null;
        return _address.getHostName();
    }
1165073
private static InetAddress getInetAddress(String ip) {
    if (ip == null)
      return null;

    InetAddress addr = null;
    try {
      addr = InetAddress.getByName(ip);
    } catch (UnknownHostException e) {
      Log.err(e);
      H2O.exit(-1);
    }
    return addr;
  }
952943
protected final Endpoint endpoint() throws UnknownHostException {
        final Set<InetSocketAddress> hosts = hosts();
        checkState(!hosts.isEmpty(), "no hosts were added.");

        final InetSocketAddress firstHost = Iterables.getFirst(hosts, null);
        final Endpoint endpoint;
        if (hosts.size() == 1 && !firstHost.isUnresolved()) {
            endpoint = toResolvedHostEndpoint(firstHost);
        } else {
            final String groupName;
            if (selectedProfile() != null) {
                // Generate a group name from profile name.
                groupName = "centraldogma-profile-" + selectedProfile();
            } else {
                // Generate an anonymous group name with an arbitrary integer.
                groupName = "centraldogma-anonymous-" + nextAnonymousGroupId.getAndIncrement();
            }

            final List<Endpoint> staticEndpoints = new ArrayList<>();
            final List<EndpointGroup> groups = new ArrayList<>();
            for (final InetSocketAddress addr : hosts) {
                if (addr.isUnresolved()) {
                    groups.add(new DnsAddressEndpointGroupBuilder(addr.getHostString())
                            .eventLoop(clientFactory.eventLoopGroup().next())
                            .port(addr.getPort())
                            .build());
                } else {
                    staticEndpoints.add(toResolvedHostEndpoint(addr));
                }
            }

            if (!staticEndpoints.isEmpty()) {
                groups.add(new StaticEndpointGroup(staticEndpoints));
            }

            EndpointGroup group;
            if (groups.size() == 1) {
                group = groups.get(0);
            } else {
                group = new CompositeEndpointGroup(groups);
            }

            if (group instanceof DynamicEndpointGroup) {
                // Wait until the initial endpoint list is ready.
                try {
                    ((DynamicEndpointGroup) group).awaitInitialEndpoints(10, TimeUnit.SECONDS);
                } catch (Exception e) {
                    final UnknownHostException cause = new UnknownHostException(
                            "failed to resolve any of: " + hosts);
                    cause.initCause(e);
                    throw cause;
                }
            }

            if (!healthCheckInterval.isZero()) {
                group = new HttpHealthCheckedEndpointGroupBuilder(group, HttpApiV1Constants.HEALTH_CHECK_PATH)
                        .clientFactory(clientFactory)
                        .protocol(isUseTls() ? SessionProtocol.HTTPS : SessionProtocol.HTTP)
                        .retryInterval(healthCheckInterval)
                        .build();
            }

            EndpointGroupRegistry.register(groupName, group, EndpointSelectionStrategy.ROUND_ROBIN);
            endpoint = Endpoint.ofGroup(groupName);
        }
        return endpoint;
    }
1271116
public function getHostname(): HostnameInterface
    {
        if ($this->myHostname !== null) {
            return $this->myHostname;
        }

        // If no hostname is present, create a standard "in-addr.arpa" hostname from IP address.
        $ipAddressParts = $this->myIpAddress->getParts();

        return Hostname::fromParts([
            strval($ipAddressParts[3]),
            strval($ipAddressParts[2]),
            strval($ipAddressParts[1]),
            strval($ipAddressParts[0]),
            'in-addr',
        ], 'arpa');
    }
510543
private String resolveHostName(InetSocketAddress remoteAddress) {
        String hostString = null;
        try {
            hostString = (String) getHostMethod.invoke(remoteAddress, new Object[]{});
        } catch (InvocationTargetException ite) {
            throw new RuntimeException("Expecting InetSocketAddress to have a package scoped \"getHostString\" method which returns a String and takes no input");
        } catch (IllegalAccessException iae) {
            throw new RuntimeException("Expecting InetSocketAddress to have a package scoped \"getHostString\" method which returns a String and takes no input");
        }
        return hostString;
    }
85457
@Override
  public InetSocketAddress ipRemote()
  {
    if (_ipRemote == null) {
      try {
        _ipRemote = InetSocketAddress.createUnresolved(getLocalHost(),
                                                      portLocal());
      } catch (Exception e) {
        log.log(Level.FINE, e.toString(), e);
      }
    }

    return _ipLocal;
  }
470647
@Nullable
    public static String determineIpAddress() throws SocketException {
        SocketException caughtException = null;
        for (final Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); networkInterfaces.hasMoreElements();) {
            try {
                final NetworkInterface nextInterface = networkInterfaces.nextElement();
                if (! nextInterface.isLoopback() && ! nextInterface.isVirtual() && ! nextInterface.isPointToPoint()) {
                    for (final Enumeration<InetAddress> addresses = nextInterface.getInetAddresses(); addresses.hasMoreElements(); ) {
                        final InetAddress inetAddress = addresses.nextElement();
                        final byte[] address = inetAddress.getAddress();
                        if ((address.length == 4) //  we don't need no steenking IPv6
                                && ((address[0] != 127) || (address[1] != 0))) {    //  don't want localhost IP
                            return inetAddress.getHostAddress();
                        }
                    }
                }
            } catch (SocketException ex) {
                // We're not going to extract an IP address from this interface, so move on to the next one.
                // If we find a qualifying interface, we won't care that some other interface gave us problems.
                // If we don't find one, this exception might be informative.
                caughtException = ex;
            }
        }

        if (caughtException != null) {
            throw caughtException;
        }
        return null;
    }