List of utility methods to do InetAddress Check
boolean | isPubliclyRoutable(final InetAddress addrIP) Determines whether a particular IP address is publicly routable on the internet if (addrIP == null) throw new NullPointerException("isPubliclyRoutable requires an IP address be passed to it!"); return !addrIP.isSiteLocalAddress() && !addrIP.isLinkLocalAddress() && !addrIP.isLoopbackAddress(); |
boolean | isReachable(final InetAddress inetAddress, final int timeout) is Reachable return inetAddress.isReachable(timeout);
|
boolean | isReachable(InetAddress address, int port) is Reachable return isReachable(address, Arrays.asList(port));
|
boolean | isReachable(NetworkInterface iface, InetAddress address, int timeout) is Reachable try { return address.isReachable(iface, 0, timeout); } catch (IOException e) { return false; |
boolean | isReservedAddr(InetAddress inetAddr) Check if it's "local address" or "link local address" or "loopbackaddress" if (inetAddr.isAnyLocalAddress() || inetAddr.isLinkLocalAddress() || inetAddr.isLoopbackAddress()) { return true; return false; |
boolean | isServerAlive(InetAddress host, int port) Check whether a server is alive. Socket socket = null; int i = 0; while (i < RETRY_COUNT) { try { socket = new Socket(host, port); break; } catch (IOException e) { i++; ... |
boolean | isServerAlive(InetAddress host, int port) Check whether a server is alive. Socket socket = null; int i = 0; while (i < RETRY_COUNT) { try { socket = new Socket(host, port); break; } catch (IOException e) { i++; ... |
boolean | isSiteLocalAddress(InetAddress i) Check if address is in site-local range. if (i instanceof Inet6Address) { byte[] addr = i.getAddress(); assert (addr.length == 128 / 8); return ((addr[0] & (byte) 0xfe) == (byte) 0xfc ) || (addr[0] == (byte) 0xfe && (addr[1] & (byte) 0xc0) == (byte) 0xc0 ); return i.isSiteLocalAddress(); ... |
boolean | isTenDot(InetAddress adr) is Ten Dot return getOneDotPrefix(adr).equals("10"); |
boolean | isThisMyIpAddress(InetAddress addr) Check if the given address is pointing to this local machine. if (addr.isAnyLocalAddress() || addr.isLoopbackAddress()) { return true; try { return NetworkInterface.getByInetAddress(addr) != null; } catch (SocketException ex) { return false; |