Get the host name of a local address, if available.

@param _ipAddress the IP address
@return the host name, or the original IP if name not available
170191
public static String getHostName(String _ipAddress) {
        try {
            InetAddress addr = InetAddress.getByName(_ipAddress);
            return addr.getHostName();
        } catch (Exception _ex) {
            return _ipAddress;
        }
    }
936137
public static String getIP(final InetAddress inetAddress)
	{
		String ip = "";
		ip = inetAddress.getHostAddress();
		if (ip.equals(""))
		{
			final byte[] ipAddressInBytes = inetAddress.getAddress();
			for (int i = 0; i < ipAddressInBytes.length; i++)
			{
				if (i > 0)
				{
					ip += ".";
				}
				ip += ipAddressInBytes[i] & 0xFF;
			}
		}
		return ip;
	}
960835
def get_host_ip(hostname, fallback=None):
    
    if is_ip(hostname):
        return hostname

    ip_addr = ns_query(hostname)
    if not ip_addr:
        try:
            ip_addr = socket.gethostbyname(hostname)
        except Exception:
            log("Failed to resolve hostname '%s'" % (hostname),
                level=WARNING)
            return fallback
    return ip_addr
1174373
public static InetAddress getIPHostAddress(String host) {
        InetAddress result = null;
        Matcher matcher = IPV4_QUADS.matcher(host);
        if (matcher == null || !matcher.matches()) {
            return result;
        }
        try {
            // Doing an Inet.getByAddress() avoids a lookup.
            result = InetAddress.getByAddress(host,
                    new byte[] {
                    (byte)(new Integer(matcher.group(1)).intValue()),
                    (byte)(new Integer(matcher.group(2)).intValue()),
                    (byte)(new Integer(matcher.group(3)).intValue()),
                    (byte)(new Integer(matcher.group(4)).intValue())});
        } catch (NumberFormatException e) {
            logger.warning(e.getMessage());
        } catch (UnknownHostException e) {
            logger.warning(e.getMessage());
        }
        return result;
    }
176872
public InetAddress getInetAddress() throws UnknownHostException{
     if(ip!=null) return ip;

     return (ip=InetAddress.getByName(host));
   }
1130949
public static String getHostName(SocketAddress socketAddress) {
        if (socketAddress == null) {
            return null;
        }

        if (socketAddress instanceof InetSocketAddress) {
            InetAddress addr = ((InetSocketAddress) socketAddress).getAddress();
            if(addr != null){
                return addr.getHostAddress();
            }
        }

        return null;
    }
1206003
public static String getLocalHostAddress() {
		try {
			InetAddress inet = InetAddress.getLocalHost();
			String hostAddress = inet.getHostAddress();
			return hostAddress;
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		return null;
	}
85801
public static IPAddressType getAddressType(String ipAddress)
    {
    	if(IPAddressUtil.isIPv4LiteralAddress(ipAddress))
    		return IPAddressType.IPV4;
    	
    	if(IPAddressUtil.isIPv6LiteralAddress(ipAddress))
    		return IPAddressType.IPV6;
    	
    	return IPAddressType.INVALID;
    }
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;
    }
952467
def get_ip_address(ifname):
    
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

    return socket.inet_ntoa(fcntl.ioctl(
        s.fileno(),
        0x8915,  # SIOCGIFADDR
        struct.pack('256s', ifname[:15])
    )[20:24])
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');
    }
1110804
public String getHost() {
		String host = getAsNullableString("host");
		host = host != null ? host : getAsNullableString("ip");
		return 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;
	}
42533
public String getHostName() {
        if( addr instanceof NbtAddress ) {
            return ((NbtAddress)addr).getHostName();
        }
        return ((InetAddress)addr).getHostName();
    }
765306
protected function getIpThrottles($ipAddress)
    {
        if (! array_key_exists($ipAddress, $this->ipThrottles)) {
            $this->ipThrottles[$ipAddress] = $this->loadIpThrottles($ipAddress);
        }

        return $this->ipThrottles[$ipAddress];
    }
1000475
function getServerIpAddress(host, port) {
  if (host) {
    return `${host}:${port}`
  }

  if (isAndroid) {
    const FINGERPRINT = android.os.Build.FINGERPRINT
    if (FINGERPRINT.includes("vbox")) {
      // running on genymotion
      return `10.0.3.2:${port}`
    } else if (FINGERPRINT.includes("generic")) {
      // running on android emulator
      return `10.0.2.2:${port}`
    }
  }

  // ios simulator uses localhost
  return `127.0.0.1:${port}`
}
1352727
public static String getFullyLocalHostName() {
		String hostName = null;
		try {
			InetAddress inet = InetAddress.getLocalHost();
			hostName = inet.getCanonicalHostName();
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		return hostName;
	}