List of utility methods to do Socket Address Get
void | addr_to_sbuf(InetSocketAddress addr, StringBuffer buf) addtsbuf buf.append(addr.getAddress().getHostAddress());
buf.append(":");
buf.append(addr.getPort());
|
String | address2String(InetSocketAddress address) address String return address.getHostName() + ":" + address.getPort(); |
String | address2string(InetSocketAddress isa) addressstring if (isa == null) return null; return isa.getAddress().getHostAddress() + ":" + isa.getPort(); |
boolean | addressIn(SocketAddress address, String ip) address In return false;
|
String | addressLabel(SocketAddress localAddress, SocketAddress remoteAddress) address Label InetSocketAddress local = (InetSocketAddress) localAddress; InetSocketAddress remote = (InetSocketAddress) remoteAddress; String key = ""; if (local == null || local.getAddress() == null) { key += "local-"; } else { key += local.getAddress().getHostAddress() + ":" + local.getPort() + "-"; if (remote == null || remote.getAddress() == null) { key += "remote"; } else { key += remote.getAddress().getHostAddress() + ":" + remote.getPort(); return key; |
String | addressMapToString(Map Format the given map, as returned by other functions in this class, into a string suitable for debugging display. StringBuilder b = new StringBuilder(); for (Map.Entry<String, Map<String, InetSocketAddress>> entry : map.entrySet()) { String nsId = entry.getKey(); Map<String, InetSocketAddress> nnMap = entry.getValue(); b.append("Nameservice <").append(nsId).append(">:").append("\n"); for (Map.Entry<String, InetSocketAddress> e2 : nnMap.entrySet()) { b.append(" NN ID ").append(e2.getKey()).append(" => ").append(e2.getValue()).append("\n"); return b.toString(); |
String | addressToString(InetSocketAddress a) Stringize an internet address reasonably. String value; InetAddress addr = a.getAddress(); if (addr != null) { value = addr.getHostAddress(); } else { value = a.getHostName(); value += ":" + a.getPort(); ... |
String | addressToString(InetSocketAddress address, Boolean useIpAddress) address To String if (useIpAddress) { return "http://" + address.getAddress().getHostAddress() + ":" + address.getPort(); } else { return "http://" + address.getAddress().getHostName() + ":" + address.getPort(); |
String | asString(SocketAddress socketAddress) Returns a string representation of the specified socket address in the form final InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress; final InetAddress inetAddress = inetSocketAddress.getAddress(); String host = inetSocketAddress.getHostName(); if (inetAddress != null) { host = inetAddress.getHostAddress(); return host + ":" + inetSocketAddress.getPort(); |
SocketAddress | cast2SocketAddress(String addr) cast Socket Address String[] str = addr.split(":"); if (str.length != 2) throw new IllegalArgumentException(); return new InetSocketAddress(str[0], Integer.valueOf(str[1])); |