java.net
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 portequals
in class Object
obj
- The obj to compare this address with.Object.hashCode()
public final InetAddress getAddress()
InetAddress
or
null
if its unresolvedpublic final String getHostName()
hostname
public final int getPort()
port
public final int hashCode()
InetSocketAddress
hashCode
in class Object
Object.equals(Object)
,
System.identityHashCode(Object)
public final boolean isUnresolved()
public String toString()
InetSocketAddress
as stringtoString
in class Object
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)