public class InetSocketAddress extends SocketAddress
It provides an immutable object used by sockets for binding, connecting, or as returned values.
The wildcard is a special local IP address. It usually means "any"
and can only be used for bind
operations.
Socket
,
ServerSocket
,
Serialized FormConstructor | Description |
---|---|
InetSocketAddress(InetAddress addr,
int port) |
Creates a socket address from an IP address and a port number.
|
InetSocketAddress(int port) |
Creates a socket address where the IP address is the wildcard address
and the port number a specified value.
|
InetSocketAddress(String hostname,
int port) |
Creates a socket address from a hostname and a port number.
|
Modifier and Type | Method | Description |
---|---|---|
static InetSocketAddress |
createUnresolved(String host,
int port) |
Creates an unresolved socket address from a hostname and a port number.
|
boolean |
equals(Object obj) |
Compares this object against the specified object.
|
InetAddress |
getAddress() |
Gets the
InetAddress . |
String |
getHostName() |
Gets the
hostname . |
String |
getHostString() |
Returns the hostname, or the String form of the address if it
doesn't have a hostname (it was created using a literal).
|
int |
getPort() |
Gets the port number.
|
int |
hashCode() |
Returns a hashcode for this socket address.
|
boolean |
isUnresolved() |
Checks whether the address has been resolved or not.
|
String |
toString() |
Constructs a string representation of this InetSocketAddress.
|