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);
16 if (addresses != null)
22 public byte[] getAddress() {
26 public static InetAddress getLocalHost() {
27 return getByName("localhost");
30 public boolean equals(InetAddress ia) {
33 if (ia.address.length!=address.length)
35 for(int i=0; i<address.length; i++)
36 if (ia.address[i]!=address[i])
41 public static InetAddress[] getAllByName(String hostname) {
42 InetAddress[] addresses;
44 byte[][] iplist = InetAddress.getHostByName(hostname.getBytes());
47 addresses = new InetAddress[iplist.length];
49 for (int i = 0; i < iplist.length; i++) {
50 addresses[i] = new InetAddress(iplist[i], hostname);
58 public static native byte[][] getHostByName(byte[] hostname);
60 public String toString() {
61 String h=hostname+" ";
62 for (int i=0; i<address.length; i++) {