FileDocCategorySizeDatePackage
AddressTests.javaAPI DocExample789Sat Sep 09 19:53:36 BST 2000None

AddressTests

public class AddressTests extends Object

Fields Summary
Constructors Summary
Methods Summary
public static chargetClass(java.net.InetAddress ia)

  
    byte[] address = ia.getAddress();
    if (address.length != 4) {
      throw new IllegalArgumentException("Do not understand IPv6 addresses!");
    }
  
    int firstByte = address[0];
    if ((firstByte & 0x80) == 0) return 'A";
    else if ((firstByte & 0xC0) == 0x80) return 'B";
    else if ((firstByte & 0xE0) == 0xC0) return 'C";    
    else if ((firstByte & 0xF0) == 0xE0) return 'D";
    else if ((firstByte & 0xF8) == 0xF0) return 'E";
    else return 'F";
    
  
public static intgetVersion(java.net.InetAddress ia)

    
    byte[] address = ia.getAddress();
    if (address.length == 4) return 4;
    else if (address.length == 16) return 6;
    else return -1;