1 public class InetAddress {
5 public InetAddress(byte[] addr, String hostname) {
6 this.hostname=hostname;
10 public static InetAddress getByAddress(String host, byte[] addr) {
11 return new InetAddress(addr, host);
14 public static InetAddress getByName(String hostname) {
15 InetAddress[] addresses=getAllByName(hostname);
19 public byte[] getAddress() {
23 public static InetAddress getLocalHost() {
24 return getByName("localhost");
27 public boolean equals(InetAddress ia) {
30 if (ia.address.length!=address.length)
32 for(int i=0; i<address.length; i++)
33 if (ia.address[i]!=address[i])
38 public static InetAddress[] getAllByName(String hostname) {
39 InetAddress[] addresses;
41 byte[][] iplist = InetAddress.getHostByName(hostname.getBytes());
43 addresses = new InetAddress[iplist.length];
45 for (int i = 0; i < iplist.length; i++) {
46 addresses[i] = new InetAddress(iplist[i], hostname);
51 public static native byte[][] getHostByName(byte[] hostname);
53 public String toString() {
54 String h=hostname+" ";
55 for (int i=0; i<address.length; i++) {