public class InetSocketAddress extends SocketAddress
Constructor and Description |
---|
InetSocketAddress(InetAddress addr,
int port)
Constructs an InetSocketAddress instance.
|
InetSocketAddress(int port)
Constructs an InetSocketAddress instance.
|
InetSocketAddress(String hostname,
int port)
Constructs an InetSocketAddress instance.
|
Modifier and Type | Method and Description |
---|---|
static InetSocketAddress |
createUnresolved(String hostname,
int port)
Creates an unresolved
InetSocketAddress object. |
boolean |
equals(Object obj)
Test if obj is a
InetSocketAddress and has the same address and
port |
InetAddress |
getAddress()
Returns the
InetAddress or null if its unresolved |
String |
getHostName()
Returns
hostname |
int |
getPort()
Returns the
port |
int |
hashCode()
Returns the hashcode of the
InetSocketAddress |
boolean |
isUnresolved()
Checks wether the address has been resolved or not
|
String |
toString()
Returns the
InetSocketAddress as string |
public InetSocketAddress(InetAddress addr, int port) throws IllegalArgumentException
addr
- Address of the socketport
- Port if the socketIllegalArgumentException
- If the port number is illegelpublic InetSocketAddress(int port) throws IllegalArgumentException
port
- Port if the socketIllegalArgumentException
- If the port number is illegalpublic InetSocketAddress(String hostname, int port)
hostname
- The hostname for the socket addressport
- The port for the socket addressIllegalArgumentException
- If the port number is illegal or the hostname argument is nullpublic static InetSocketAddress createUnresolved(String hostname, int port)
InetSocketAddress
object.hostname
- The hostname for the socket addressport
- The port for the socket addressIllegalArgumentException
- If the port number is illegal or the hostname argument is nullpublic final boolean equals(Object obj)
InetSocketAddress
and has the same address and
portpublic final InetAddress getAddress()
InetAddress
or null
if its unresolvedpublic final String getHostName()
hostname
public final int getPort()
port
public final int hashCode()
InetSocketAddress
public final boolean isUnresolved()