Java Utililty Methods Socket Address Get

List of utility methods to do Socket Address Get

Description

The list of methods to do Socket Address Get are organized into topic(s).

Method

voidaddr_to_sbuf(InetSocketAddress addr, StringBuffer buf)
addtsbuf
buf.append(addr.getAddress().getHostAddress());
buf.append(":");
buf.append(addr.getPort());
Stringaddress2String(InetSocketAddress address)
address String
return address.getHostName() + ":" + address.getPort();
Stringaddress2string(InetSocketAddress isa)
addressstring
if (isa == null)
    return null;
return isa.getAddress().getHostAddress() + ":" + isa.getPort();
booleanaddressIn(SocketAddress address, String ip)
address In
return false;
StringaddressLabel(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;
StringaddressMapToString(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();
StringaddressToString(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();
...
StringaddressToString(InetSocketAddress address, Boolean useIpAddress)
address To String
if (useIpAddress) {
    return "http://" + address.getAddress().getHostAddress() + ":" + address.getPort();
} else {
    return "http://" + address.getAddress().getHostName() + ":" + address.getPort();
StringasString(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();
SocketAddresscast2SocketAddress(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]));