1 52 53 package com.go.trove.net; 54 55 import java.net.*; 56 57 63 public class InetAddressAndPort { 64 67 public static final InetAddressAndPort UNKNOWN; 68 69 static { 70 InetAddress addr; 71 try { 72 addr = InetAddress.getByName("0.0.0.0"); 73 } 74 catch (UnknownHostException e) { 75 addr = null; 77 } 78 79 UNKNOWN = new InetAddressAndPort(addr, -1); 80 } 81 82 private final InetAddress mAddr; 83 private final int mPort; 84 85 public InetAddressAndPort(InetAddress addr, int port) { 86 mAddr = addr; 87 mPort = port; 88 } 89 90 public InetAddress getInetAddress() { 91 return mAddr; 92 } 93 94 public int getPort() { 95 return mPort; 96 } 97 98 public String toString() { 99 return mAddr + ":" + mPort; 100 } 101 } 102 | Popular Tags |