| |
|
| java.lang.Object java.net.SocketAddress java.net.InetSocketAddress
InetSocketAddress | public class InetSocketAddress extends SocketAddress (Code) | | This class implements an IP Socket Address (IP address + port number)
It can also be a pair (hostname + port number), in which case an attempt
will be made to resolve the hostname. If resolution fails then the address
is said to be unresolved but can still be used on some circumstances
like connecting through a proxy.
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.
See Also: java.net.Socket See Also: java.net.ServerSocket since: 1.4 |
Constructor Summary | |
public | InetSocketAddress(int port) Creates a socket address where the IP address is the wildcard address
and the port number a specified value.
A valid port value is between 0 and 65535.
A port number of zero will let the system pick up an
ephemeral port in a bind operation.
Parameters: port - The port number throws: IllegalArgumentException - if the port parameter is outside the specifiedrange of valid port values. | public | InetSocketAddress(InetAddress addr, int port) Creates a socket address from an IP address and a port number. | public | InetSocketAddress(String hostname, int port) Creates a socket address from a hostname and a port number. |
Method Summary | |
final public boolean | equals(Object obj) Compares this object against the specified object.
The result is true if and only if the argument is
not null and it represents the same address as
this object.
Two instances of InetSocketAddress represent the same
address if both the InetAddresses (or hostnames if it is unresolved) and port
numbers are equal.
If both addresses are unresolved, then the hostname & the port number
are compared.
Parameters: obj - the object to compare against. | final public InetAddress | getAddress() Gets the InetAddress . | final public String | getHostName() Gets the hostname . | final public int | getPort() Gets the port number. | final public int | hashCode() Returns a hashcode for this socket address. | final public boolean | isUnresolved() Checks wether the address has been resolved or not. | public String | toString() Constructs a string representation of this InetSocketAddress.
This String is constructed by calling toString() on the InetAddress
and concatenating the port number (with a colon). |
InetSocketAddress | public InetSocketAddress(int port)(Code) | | Creates a socket address where the IP address is the wildcard address
and the port number a specified value.
A valid port value is between 0 and 65535.
A port number of zero will let the system pick up an
ephemeral port in a bind operation.
Parameters: port - The port number throws: IllegalArgumentException - if the port parameter is outside the specifiedrange of valid port values. |
InetSocketAddress | public InetSocketAddress(InetAddress addr, int port)(Code) | | Creates a socket address from an IP address and a port number.
A valid port value is between 0 and 65535.
A port number of zero will let the system pick up an
ephemeral port in a bind operation.
A null address will assign the wildcard address.
Parameters: addr - The IP address Parameters: port - The port number throws: IllegalArgumentException - if the port parameter is outside the specifiedrange of valid port values. |
InetSocketAddress | public InetSocketAddress(String hostname, int port)(Code) | | Creates a socket address from a hostname and a port number.
An attempt will be made to resolve the hostname into an InetAddress.
If that attempt fails, the address will be flagged as unresolved.
A valid port value is between 0 and 65535.
A port number of zero will let the system pick up an
ephemeral port in a bind operation.
Parameters: hostname - the Host name Parameters: port - The port number throws: IllegalArgumentException - if the port parameter is outside the rangeof valid port values, or if the hostname parameter is null. See Also: InetSocketAddress.isUnresolved() |
equals | final public boolean equals(Object obj)(Code) | | Compares this object against the specified object.
The result is true if and only if the argument is
not null and it represents the same address as
this object.
Two instances of InetSocketAddress represent the same
address if both the InetAddresses (or hostnames if it is unresolved) and port
numbers are equal.
If both addresses are unresolved, then the hostname & the port number
are compared.
Parameters: obj - the object to compare against. true if the objects are the same;false otherwise. See Also: java.net.InetAddress.equals(java.lang.Object) |
getAddress | final public InetAddress getAddress()(Code) | | Gets the InetAddress .
the InetAdress or null if it is unresolved. |
getHostName | final public String getHostName()(Code) | | Gets the hostname .
the hostname part of the address. |
getPort | final public int getPort()(Code) | | Gets the port number.
the port number. |
hashCode | final public int hashCode()(Code) | | Returns a hashcode for this socket address.
a hash code value for this socket address. |
isUnresolved | final public boolean isUnresolved()(Code) | | Checks wether the address has been resolved or not.
true if the hostname couldn't be resolved intoan InetAddress . |
toString | public String toString()(Code) | | Constructs a string representation of this InetSocketAddress.
This String is constructed by calling toString() on the InetAddress
and concatenating the port number (with a colon). If the address
is unresolved then the part before the colon will only contain the hostname.
a string representation of this object. |
|
|
|