The list of methods to do Socket Address Get are organized into topic(s).
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> 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
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]));