List of utility methods to do InetAddress Check
boolean | IsBusy(final InetAddress remote, int port) Is Busy try { Socket s = new Socket(remote, port); s.close(); return true; } catch (Exception e) { return false; |
boolean | isClassicAddress(InetAddress address) Returns true if the given InetAddress is an IPv4 address return address instanceof Inet4Address; |
boolean | isCommonSubnet(InetAddress address1, InetAddress address2) Checks if two IP addresses belong to the same subnet byte[] address1data = address1.getAddress(); byte[] address2data = address2.getAddress(); return address1data[0] == address2data[0] && address1data[1] == address2data[1] && address1data[2] == address2data[2]; |
boolean | isGlobalAddressV6(InetAddress addr) checks if the provided address is a global-scope ipv6 unicast address return addr instanceof Inet6Address && !addr.isAnyLocalAddress() && !addr.isLinkLocalAddress() && !addr.isLoopbackAddress() && !addr.isMulticastAddress() && !addr.isSiteLocalAddress() && !((Inet6Address) addr).isIPv4CompatibleAddress(); |
boolean | isHostLocalHost(InetAddress host) is Host Local Host try { return getLocalAddress().equals(host); } catch (UnknownHostException e) { return false; |
boolean | isInet6Compatible(InetAddress address, Inet6Address inet6Address) is Inet Compatible if (!(address instanceof Inet6Address)) { return false; if (!Arrays.equals(address.getAddress(), inet6Address.getAddress())) { return false; return true; |
boolean | isInRage(InetAddress check, InetAddress bcast, int netmask) is In Rage int byts = netmask / 8; byte mask = (byte) ~(0xff >>> (netmask % 8)); byte[] b1 = check.getAddress(); byte[] b2 = bcast.getAddress(); int i; for (i = 0; i < byts; i++) { if (b1[i] != b2[i]) { return false; ... |
boolean | isIpAddressInRange(InetAddress ipStart, InetAddress ipEnd, InetAddress ipToCheck) is Ip Address In Range long ipLo = inetAddressToLong(ipStart); long ipHi = inetAddressToLong(ipEnd); long ipToTest = inetAddressToLong(ipToCheck); return (ipToTest >= ipLo && ipToTest <= ipHi); |
boolean | isIPLocal(final InetAddress adr) is IP Local return adr.isLinkLocalAddress() || adr.isLoopbackAddress() || adr.isSiteLocalAddress();
|
boolean | isIPv6(final InetAddress ip) True if this InetAddress is a raw IPv6 in dotted quad notation. return ip instanceof Inet6Address && ip.getHostName().equals(ip.getHostAddress()); |