List of utility methods to do Local Address Get
InetAddress | getLocalAddress() from: http://www.java2s.com/Code/Java/Network-Protocol/FindsalocalnonloopbackIPv4address.htm Finds a local, non-loopback, IPv4 address try { Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces(); while (ifaces.hasMoreElements()) { NetworkInterface iface = ifaces.nextElement(); Enumeration<InetAddress> addresses = iface.getInetAddresses(); while (addresses.hasMoreElements()) { InetAddress addr = addresses.nextElement(); if (addr instanceof Inet4Address && !addr.isLoopbackAddress()) { ... |
byte[] | getLocalAddress() get Local Address if (localAddress == null) { try { InetAddress inetAddress = InetAddress.getLocalHost(); localAddress = inetAddress.getAddress(); } catch (Exception e) { return localAddress; ... |
InetAddress | getLocalAddress() Get the IP Address by which the rest of the world knows us. if (localAddress != null) { return localAddress; InetAddress addr = null; try { addr = InetAddress.getByName(InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException e) { addr = null; ... |
InetAddress | getLocalAddress() get Local Address if (localInetAddress_ == null) localInetAddress_ = InetAddress.getLocalHost(); return localInetAddress_; |
String | getLocalAddress() Gets the local address. Enumeration<NetworkInterface> allNetInterfaces; try { allNetInterfaces = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { e.printStackTrace(); return "NO"; InetAddress ip = null; ... |
InetAddress | getLocalAddress() Look for a usable network interface address to use for tests. return InetAddress.getByName("127.0.0.1"); |
InetAddress | getLocalAddress() get Local Address InetAddress localAddress = null; try { localAddress = InetAddress.getLocalHost(); if (isValidAddress(localAddress)) { return localAddress; } catch (Throwable e) { e.printStackTrace(); ... |
InetAddress | getLocalAddress() Get a local, IP4 Address, preferable a non-loopback address which is bound to an interface. InetAddress addr = InetAddress.getLocalHost(); NetworkInterface nif = NetworkInterface.getByInetAddress(addr); if (addr.isLoopbackAddress() || addr instanceof Inet6Address || nif == null) { InetAddress lookedUpAddr = findLocalAddressViaNetworkInterface(); addr = lookedUpAddr != null ? lookedUpAddr : InetAddress.getByName("127.0.0.1"); return addr; |
String | getLocalAddress() get Local Address InetAddress inetAddress = null; try { inetAddress = InetAddress.getLocalHost(); } catch (UnknownHostException e) { e.printStackTrace(); return inetAddress.getHostAddress(); |
InetAddress | getLocalAddress() get Local Address try { final InetAddress addr = InetAddress.getLocalHost(); return addr; } catch (UnknownHostException e) { try { Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); if (interfaces == null) { return null; ... |