List of utility methods to do Socket Address Get
String | getHostString(InetSocketAddress socketAddress) Returns the hostname or IP address of java.net.InetSocketAddress . InetAddress address = socketAddress.getAddress(); return (address != null && address.toString().startsWith("/")) ? address.getHostAddress() : socketAddress.getHostName(); |
String | getHostString(InetSocketAddress socketAddress) Figure out the host string of a given socket address, similar to the Java 7 InetSocketAddress.getHostString(). if (socketAddress.isUnresolved()) { return socketAddress.getHostName(); } else { return socketAddress.getAddress().getHostAddress(); |
String | getHostStringFromInetSocketAddress(InetSocketAddress addr) get Host String From Inet Socket Address return addr.getHostString();
|
String | getHostStringWithoutNameLookup(InetSocketAddress inetSocketAddress) A Java 6/7 safe way of looking up a host name from an InetSocketAddress without tickling a name lookup. String newHost; if (inetSocketAddress.isUnresolved()) { newHost = inetSocketAddress.getHostName(); } else { newHost = inetSocketAddress.getAddress().getHostAddress(); return newHost; |
InetSocketAddress | getInetSocketAddress(long addrAsInt32, int port) get Inet Socket Address return new InetSocketAddress(getAddressFromInt32(addrAsInt32), port); |
InetSocketAddress | getInetSocketAddress(String addressPortStr, int defaultPort) Get an InetSocketAddress from the String format ": if (addressPortStr == null || addressPortStr.isEmpty()) { return null; String addressStr; int port; if (addressPortStr.charAt(0) == '[') { int i = addressPortStr.indexOf(']'); if (i <= 0) { ... |
InetSocketAddress | getInetSocketAddress(String arg) Get the InetSocketAddress corresponding to the FTP format of address String[] elements = arg.split(","); if (elements.length != 6) { return null; byte[] address = new byte[4]; int[] iElements = new int[6]; for (int i = 0; i < 6; i++) { try { ... |
InetSocketAddress | getInetSocketAddress(String endpoint) Convert an endpoint from String (host:port) to InetSocketAddress String[] array = endpoint.split(":"); return new InetSocketAddress(array[0], Integer.parseInt(array[1])); |
InetSocketAddress | getInetSocketAddress(String endpointURI, int defaultPort) get Inet Socket Address final int pos = endpointURI.indexOf(':'); if (pos == -1) { InetAddress addr = getInetAddress(endpointURI); return new InetSocketAddress(addr, defaultPort); } else { String host = endpointURI.substring(0, pos); InetAddress addr = getInetAddress(host); String portStr = endpointURI.substring(pos + 1); ... |
InetSocketAddress | getInetSocketAddress(String s, String mainHost) get Inet Socket Address int finalColon = mainHost.lastIndexOf(':'); if (finalColon < 1) { throw new IllegalArgumentException("Invalid server ``" + mainHost + "'' in list: " + s); String hostPart = mainHost.substring(0, finalColon).trim(); String portNum = mainHost.substring(finalColon + 1).trim(); InetSocketAddress mainAddress = new InetSocketAddress(hostPart, Integer.parseInt(portNum)); return mainAddress; ... |