get the local host ip address.

@return the local host ip address.
329588
public static InetAddress getLocalHost() {

        if (localHost == null) {
            try {
                localHost = java.net.InetAddress.getLocalHost();
            } catch (UnknownHostException e) {
                LOGGER.error("Cannot get local host address. exception is: " + e);
                localHost = null;
                hostName = "UNKNOWN";
                ipAddress = "UNKNOWN";
            }
        }

        return localHost;

    }
836477
static String getLocalIPAddress() {
        String ipAddress = "";
        try {
            List<NetworkInterface> netInterfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
            for (NetworkInterface netInterface : netInterfaces) {
                List<InetAddress> addresses = Collections.list(netInterface.getInetAddresses());
                for (InetAddress address : addresses) {
                    if (!address.isLoopbackAddress()) {
                        String ip = address.getHostAddress();
                        boolean isIPv4 = ip.indexOf(':') < 0;
                        if (isIPv4) {
                            ipAddress = ip;
                            break;
                        }
                    }
                }
            }
        } catch (Throwable ignore) {
        }

        return ipAddress;
    }
1023103
public static InetAddress getInetAddress() {
        InetAddress inetAddress = null;
        try {
            inetAddress = InetAddress.getLocalHost();
        } catch (IOException ioe) {
            logger.error("Error in getting InetAddress", ioe);
        }
        return inetAddress;
    }
435487
public static InetAddress getAddress() {
    	
        try {
        	return InetAddress.getByAddress(new byte[] {0,0,0,0});
            /*for (Enumeration e = NetworkInterface.getNetworkInterfaces();
                    e.hasMoreElements();) {

                NetworkInterface ni = (NetworkInterface) e.nextElement();
                System.out.println("NetworkInterface = " + ni.getName());
                if (!ni.getName().contains("lo")) {
                    for (Enumeration ee = ni.getInetAddresses(); ee.hasMoreElements();) {
                        InetAddress ip = (InetAddress) ee.nextElement();
                        if (ip instanceof Inet4Address && ip.getAddress() != null) {
                            return ip;
                        }
                        //System.out.println("Ip's: " + ip.getHostAddress());
                    }
                }
            }
            NetworkInterface lo = NetworkInterface.getByName("lo");
            if (lo != null) {
                for (Enumeration ee = lo.getInetAddresses(); ee.hasMoreElements();) {
                    InetAddress ip = (InetAddress) ee.nextElement();
                    if (ip instanceof Inet4Address && ip.getAddress() != null) {
                        return ip;
                    }
                }
            }
            
            NetworkInterface lo0 = NetworkInterface.getByName("lo0");
            if (lo0 != null) {
                for (Enumeration ee = lo0.getInetAddresses(); ee.hasMoreElements();) {
                    InetAddress ip = (InetAddress) ee.nextElement();
                    if (ip instanceof Inet4Address && ip.getAddress() != null) {
                        return ip;
                    }
                }
            }*/
        } catch (Exception e) {
            System.err.println("Error");
        }
        return null;
    }
504408
public String getHost()
    {
        if (_addr==null)
            return __0_0_0_0;
        
        return _addrIsHost?_addr.getHostName():_addr.getHostAddress();
    }
814852
public InetAddress getRemoteAddress() {
        final Channel channel;
        try {
            channel = strategy.getChannel();
        } catch (IOException e) {
            return null;
        }
        final Connection connection = channel.getConnection();
        final InetSocketAddress peerAddress = connection.getPeerAddress(InetSocketAddress.class);
        return peerAddress == null ? null : peerAddress.getAddress();
    }
417104
public static String getLocalhost() throws RuntimeException
	{
		String hostname = null;

		try
		{
			InetAddress addr = InetAddress.getLocalHost();

			hostname = addr.getHostName();
		}
		catch (UnknownHostException e)
		{
			throw new RuntimeException("[FileHelper] {getLocalhost}: Can't get local hostname");
		}

		return hostname;
	}
474389
public String getHost() {
        String hostAndPort = hostAndPort();
        int indexOfMaohao = hostAndPort.indexOf(":");
        if (indexOfMaohao == -1) {
            return hostAndPort;
        } else {
            return hostAndPort.substring(0, indexOfMaohao);
        }
    }
259510
static public String getExternalIpAddress(){
		String ip = null;
		URL url = null;
		BufferedReader in = null;
		
		for (int i = 0; !isIPv4Address(ip) && i < CHECK_IP_ENDPOINTS.length; i ++, url = null, in = null){
			try{
				url = new URL(CHECK_IP_ENDPOINTS[i]);
				in = new BufferedReader(new InputStreamReader(url.openStream()));
				ip = in.readLine(); //you get the IP as a String
			}catch(Exception e){
				System.err.println("Unable to find out external IP address through end point '" + CHECK_IP_ENDPOINTS[i] + "': " + e.getMessage());
				if (in != null){
					try{
						in.close();
					}catch(Exception e2){
						// ignore
					}
				}
			}
		}
		return ip;
		
	}
687208
public static UUID getLocalHostId()
    {
        String req = "SELECT host_id FROM system.%s WHERE key='%s'";
        UntypedResultSet result = executeInternal(String.format(req, LOCAL_CF, LOCAL_KEY));

        // Look up the Host UUID (return it if found)
        if (!result.isEmpty() && result.one().has("host_id"))
            return result.one().getUUID("host_id");

        // ID not found, generate a new one, persist, and then return it.
        UUID hostId = UUID.randomUUID();
        logger.warn("No host ID found, created {} (Note: This should happen exactly once per node).", hostId);
        return setLocalHostId(hostId);
    }
737195
public static String getLocalHostName() {
        String localHostName = NetUtils.getHostName();
        return SystemPropertiesUtils.getSystemProperty(
                NaviCommonConstant.SYSTEM_PROPERTY_SERVER_HOST_FROM_ENV_4JPAAS2, localHostName);
    }
1286953
public String getHost() {
    if (this.props.containsKey(ConfigurationKeys.AZKABAN_SERVER_HOST_NAME)) {
      final String hostName = this.props
          .getString(Constants.ConfigurationKeys.AZKABAN_SERVER_HOST_NAME);
      if (!StringUtils.isEmpty(hostName)) {
        return hostName;
      }
    }

    String host = "unkownHost";
    try {
      host = InetAddress.getLocalHost().getCanonicalHostName();
    } catch (final Exception e) {
      logger.error("Failed to fetch LocalHostName");
    }
    return host;
  }
257371
public static String getHostname()
    {
        String      host = "unknown";
        try
        {
            return InetAddress.getLocalHost().getHostName();
        }
        catch ( UnknownHostException e )
        {
            // ignore
        }
        return host;
    }
476179
protected final InetSocketAddress remoteAddress() {
        if (remoteAddress == null) {
            if (server) {
                remoteAddress = new InetSocketAddress(NetUtil.LOCALHOST, randomClientPort());
            } else {
                remoteAddress = new InetSocketAddress(NetUtil.LOCALHOST,
                                                      guessServerPort(sessionProtocol, authority));
            }
        }
        return remoteAddress;
    }
479841
def get_host(self):
        
        host = self.get_as_nullable_string("host")
        host = host if host != None else self.get_as_nullable_string("ip")
        return host
1362577
public String getHostAddress() {
        if( addr instanceof NbtAddress ) {
            return ((NbtAddress)addr).getHostAddress();
        }
        return ((InetAddress)addr).getHostAddress();
    }
1286439
public InetAddress getLocalAddress() throws IOException {
        return InetAddress.getByName(
            new RqHeaders.Smart(new RqHeaders.Base(this))
                .single("X-Takes-LocalAddress")
        );
    }