java.lang.Object | ||
↳ | java.net.SocketAddress | |
↳ | java.net.InetSocketAddress |
This class represents a socket endpoint described by a IP address and a port
number. It is a concrete implementation of SocketAddress
for IP.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a socket endpoint with the given port number
port and
no specified address. | |||||||||||
Creates a socket endpoint with the given port number
port and
address . | |||||||||||
Creates a socket endpoint with the given port number
port and the
hostname host . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates an
InetSocketAddress without trying to resolve the
hostname into an InetAddress . | |||||||||||
Compares two socket endpoints and returns true if they are equal.
| |||||||||||
Returns this socket address' address.
| |||||||||||
Returns the hostname, doing a reverse DNS lookup on the
InetAddress if no
hostname string was provided at construction time. | |||||||||||
Returns the hostname if known, or the result of
InetAddress.getHostAddress . | |||||||||||
Returns this socket address' port.
| |||||||||||
Returns an integer hash code for this object.
| |||||||||||
Returns whether this socket address is unresolved or not.
| |||||||||||
Returns a string containing the address (or the hostname for an
unresolved
InetSocketAddress ) and port number. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Creates a socket endpoint with the given port number port
and
no specified address. The range for valid port numbers is between 0 and
65535 inclusive.
port | the specified port number to which this socket is bound. |
---|
Creates a socket endpoint with the given port number port
and
address
. The range for valid port numbers is between 0 and 65535
inclusive. If address
is null
this socket is bound to the
IPv4 wildcard address.
address | the specified address to which this socket is bound. |
---|---|
port | the specified port number to which this socket is bound. |
Creates a socket endpoint with the given port number port
and the
hostname host
. The hostname is tried to be resolved and cannot be
null
. The range for valid port numbers is between 0 and 65535
inclusive.
host | the specified hostname to which this socket is bound. |
---|---|
port | the specified port number to which this socket is bound. |
Creates an InetSocketAddress
without trying to resolve the
hostname into an InetAddress
. The address field is marked as
unresolved.
host | the specified hostname to which this socket is bound. |
---|---|
port | the specified port number to which this socket is bound. |
IllegalArgumentException | if the hostname host is null or the port is
not in the range between 0 and 65535.
|
---|
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.
socketAddr | the object to be tested for equality. |
---|
true
if this socket and the given socket object socketAddr
are equal, false
otherwise.
Returns the hostname, doing a reverse DNS lookup on the InetAddress
if no
hostname string was provided at construction time. Use getHostString()
to
avoid the reverse DNS lookup.
Returns the hostname if known, or the result of InetAddress.getHostAddress
.
Unlike getHostName()
, this method will never cause a DNS lookup.
Returns an integer hash code for this object. By contract, any two
objects for which equals(Object)
returns true
must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode
method
if you intend implementing your own hashCode
method.
Returns whether this socket address is unresolved or not.
true
if this socket address is unresolved, false
otherwise.
Returns a string containing the address (or the hostname for an
unresolved InetSocketAddress
) and port number.
For example: "www.google.com/74.125.224.115:80"
or "/127.0.0.1:80"
.