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.
| |||||||||||
Gets the address of this socket.
| |||||||||||
Gets the hostname of this socket.
| |||||||||||
Gets the port number of this socket.
| |||||||||||
Returns an integer hash code for this object.
| |||||||||||
Returns whether this socket address is unresolved or not.
| |||||||||||
Gets a string representation of this socket included the address and the
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. |
SecurityException | if a SecurityManager is installed and its checkConnect() method does not allow the resolving of the
host name.
|
---|
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.
Gets the address of this socket.
Gets the hostname of this socket.
Gets the port number of this socket.
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.
Gets a string representation of this socket included the address and the port number.