List of utility methods to do Socket Address Get
String | getAddress(InetSocketAddress address) Return the Address in the format compatible with FTP argument InetAddress servAddr = address.getAddress(); int servPort = address.getPort(); return servAddr.getHostAddress().replace('.', ',') + ',' + (servPort >> 8) + ',' + (servPort & 0xFF); |
String | getAddress(SocketAddress address) get Address if (address == null) { return null; if (address instanceof InetSocketAddress) { InetSocketAddress isa = (InetSocketAddress) address; return isa.getAddress().getHostAddress() + ":" + isa.getPort(); } else { return address.toString(); ... |
InetAddress | getAddress(SocketAddress address) An utility method to get the InetAddress from the SocketAddress . return getResolved(address).getAddress();
|
String | getAddressFirst(InetSocketAddress inetSocketAddress) Returns the String form of the IP address of the given InetSocketAddress , or the hostname if it has not been resolved. if (inetSocketAddress == null) { return null; InetAddress inetAddress = inetSocketAddress.getAddress(); if (inetAddress != null) { return inetAddress.getHostAddress(); return inetSocketAddress.getHostName(); ... |
String | getAddressRepresentation(final SocketAddress address) Represents the address as string final InetSocketAddress inetAddr = (InetSocketAddress) address; return inetAddr.getAddress().getHostAddress() + "@" + inetAddr.getPort(); |
String | getAddrString(final SocketAddress address) get Addr String if (address == null) { return null; if (address instanceof InetSocketAddress) { final InetSocketAddress socketAddr = (InetSocketAddress) address; final InetAddress inetAddr = socketAddr.getAddress(); return (inetAddr != null ? inetAddr.getHostAddress() : socketAddr.getHostName()) + ":" + socketAddr.getPort(); ... |
ServerSocket | getAlreadyBoundServerSocket(String address, int port, boolean ssl, boolean useChannels) get Already Bound Server Socket String key = makeKey(address, port, ssl, useChannels);
ServerSocket serverSocket = mBoundSockets.get(key);
return serverSocket;
|
InetSocketAddress | getBestAddress(InetSocketAddress addr) get Best Address Enumeration<NetworkInterface> networkIfs = NetworkInterface.getNetworkInterfaces(); while (networkIfs.hasMoreElements()) { NetworkInterface networkIf = networkIfs.nextElement(); if (!networkIf.isLoopback() && networkIf.isUp()) { boolean found = false; for (InterfaceAddress a : networkIf.getInterfaceAddresses()) { if (a.getAddress().getClass().equals(addr.getAddress().getClass())) { addr = new InetSocketAddress(a.getAddress(), addr.getPort()); ... |
String | getCanonicalConnectionAddress(InetSocketAddress address) get Canonical Connection Address return "tcp://" + address.getAddress().getCanonicalHostName() + ":" + address.getPort(); |
Integer | getClientPort(SocketAddress socketAddress) get Client Port if (!(socketAddress instanceof InetSocketAddress)) { return null; InetSocketAddress remoteAddress = (InetSocketAddress) socketAddress; return remoteAddress.getPort(); |