org.littleshoot.proxy.impl
Class NetworkUtils

java.lang.Object
  extended by org.littleshoot.proxy.impl.NetworkUtils

public class NetworkUtils
extends Object

Network utilities methods.


Constructor Summary
NetworkUtils()
           
 
Method Summary
static InetAddress firstLocalNonLoopbackIpv4Address()
          Go through our network interfaces and find the first bound address for an up interface that's in the IPv4 address space and is not the loopback address.
static InetAddress getLocalHost()
          Many Linux systems typically return 127.0.0.1 as the localhost address instead of the address assigned on the local network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetworkUtils

public NetworkUtils()
Method Detail

getLocalHost

public static InetAddress getLocalHost()
                                throws UnknownHostException
Many Linux systems typically return 127.0.0.1 as the localhost address instead of the address assigned on the local network. It has to do with how localhost is defined in /etc/hosts. This method creates a quick UDP socket and gets the local address for the socket on Linux systems to get around the problem.

Returns:
The local network address in a cross-platform manner.
Throws:
UnknownHostException - If the host is considered unknown for any reason.

firstLocalNonLoopbackIpv4Address

public static InetAddress firstLocalNonLoopbackIpv4Address()
Go through our network interfaces and find the first bound address for an up interface that's in the IPv4 address space and is not the loopback address.

Returns:


Copyright © 2009-2014 LittleShoot. All Rights Reserved.