Methods Summary |
---|
public static java.net.InetSocketAddress | createUnresolved(java.lang.String host, int port)Creates an {@code InetSocketAddress} without trying to resolve the
hostname into an {@code InetAddress}. The address field is marked as
unresolved.
return new InetSocketAddress(host, port, false);
|
public final boolean | equals(java.lang.Object socketAddr)Compares two socket endpoints and returns true if they are equal. Two
socket endpoints are equal if the IP address or the hostname of both are
equal and they are bound to the same port.
if (this == socketAddr) {
return true;
}
if (!(socketAddr instanceof InetSocketAddress)) {
return false;
}
InetSocketAddress iSockAddr = (InetSocketAddress) socketAddr;
// check the ports as we always need to do this
if (port != iSockAddr.port) {
return false;
}
// we only use the hostnames in the comparison if the addrs were not
// resolved
if ((addr == null) && (iSockAddr.addr == null)) {
return hostname.equals(iSockAddr.hostname);
}
// addrs were resolved so use them for the comparison
if (addr == null) {
// if we are here we know iSockAddr is not null so just return
// false
return false;
}
return addr.equals(iSockAddr.addr);
|
public final java.net.InetAddress | getAddress()Gets the address of this socket.
return addr;
|
public final java.lang.String | getHostName()Gets the hostname of this socket.
return (null != addr) ? addr.getHostName() : hostname;
|
public final int | getPort()Gets the port number of this socket.
return port;
|
public final int | hashCode()Gets the hashcode of this socket.
if (addr == null) {
return hostname.hashCode() + port;
}
return addr.hashCode() + port;
|
public final boolean | isUnresolved()Returns whether this socket address is unresolved or not.
return addr == null;
|
private void | readObject(java.io.ObjectInputStream stream)
stream.defaultReadObject();
|
public java.lang.String | toString()Gets a string representation of this socket included the address and the
port number.
String host;
if (addr != null) {
host = addr.toString();
} else {
host = hostname;
}
return host + ":" + port; //$NON-NLS-1$
|