Friday, 9 October 2015

Find IP address is IPV6 or IPV4

public static int getVersion(InetAddress ia) {
  byte[] address = ia.getAddress();
  if (address.length == 4)
    return 4;
  else if (address.length == 16)
    return 6;
  else
    return -1;
}

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment