java.net
Class InetSocketAddress

java.lang.Object
  |
  +--java.net.SocketAddress
        |
        +--java.net.InetSocketAddress
All Implemented Interfaces:
Serializable

public class InetSocketAddress
extends SocketAddress

Untamed:

See Also:
Serialized Form

Field Summary
private  InetAddress addr
           
private  String hostname
           
private  int port
           
 
Constructor Summary
InetSocketAddress(InetAddress addr, int port)
          Enabled: Creates a socket address from an IP address and a port number.
InetSocketAddress(int port)
          Enabled: Creates a socket address where the IP address is the wildcard address and the port number a specified value.
InetSocketAddress(String hostname, int port)
          Enabled: Creates a socket address from a hostname and a port number.
 
Method Summary
 boolean equals(Object obj)
          Suppressed: Compares this object against the specified object.
 InetAddress getAddress()
          Enabled: Gets the InetAddress.
 String getHostName()
          Enabled: Gets the hostname.
 int getPort()
          Enabled: Gets the port number.
 int hashCode()
          Suppressed: Returns a hashcode for this socket address.
 boolean isUnresolved()
          Enabled: Checks wether the address has been resolved or not.
 String toString()
          Suppressed: Constructs a string representation of this InetSocketAddress.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

hostname

private String hostname

addr

private InetAddress addr

port

private int port
Constructor Detail

InetSocketAddress

public InetSocketAddress(int port)
Enabled: 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 specified range of valid port values.

InetSocketAddress

public InetSocketAddress(InetAddress addr,
                         int port)
Enabled: 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
port - The port number
Throws:
IllegalArgumentException - if the port parameter is outside the specified range of valid port values.

InetSocketAddress

public InetSocketAddress(String hostname,
                         int port)
Enabled: 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
port - The port number
Throws:
IllegalArgumentException - if the port parameter is outside the range of valid port values, or if the hostname parameter is null.
See Also:
isUnresolved()
Method Detail

getPort

public final int getPort()
Enabled: Gets the port number.

Returns:
the port number.

getAddress

public final InetAddress getAddress()
Enabled: Gets the InetAddress.

Returns:
the InetAdress or null if it is unresolved.

getHostName

public final String getHostName()
Enabled: Gets the hostname.

Returns:
the hostname part of the address.

isUnresolved

public final boolean isUnresolved()
Enabled: Checks wether the address has been resolved or not.

Returns:
true if the hostname couldn't be resolved into an InetAddress.

toString

public String toString()
Suppressed: 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.

Overrides:
toString in class Object
Returns:
a string representation of this object.

equals

public final boolean equals(Object obj)
Suppressed: 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.

Overrides:
equals in class Object
Parameters:
obj - the object to compare against.
Returns:
true if the objects are the same; false otherwise.
See Also:
java.net.InetAddress#equals(java.lang.Object)

hashCode

public final int hashCode()
Suppressed: Returns a hashcode for this socket address.

Overrides:
hashCode in class Object
Returns:
a hash code value for this socket address.
See Also:
java.lang.Object#equals(java.lang.Object), java.util.Hashtable


comments?