java::net::InetSocketAddress Class Reference

Inheritance diagram for java::net::InetSocketAddress:

Inheritance graph
java::net::SocketAddressjava::lang::Object
[legend]
Collaboration diagram for java::net::InetSocketAddress:

Collaboration graph
java::net::SocketAddressjava::lang::Objectjava::lang::Stringjava::lang::Interfacejava::lang::ObjectRefjava::lang::Comparable
[legend]

List of all members.


Detailed Description

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

java.net.ServerSocket

Since:
1.4

Public Member Functions

 InetSocketAddress (jint port=0)
 Creates a socket address where the IP address is the wildcard address and the port number a specified value.
 InetSocketAddress (const Ref< InetAddress > &addr, jint port=0)
 Creates a socket address from an IP address and a port number.
 InetSocketAddress (const String &hostname, jint port=0)
 Creates a socket address from a hostname and a port number.
jint getPort () const
 Gets the port number.
Ref< InetAddressgetAddress () const
 Gets the InetAddress.
String getHostName () const
 Gets the hostname.
jboolean isUnresolved () const
 Checks wether the address has been resolved or not.
virtual String toString () const
 Constructs a string representation of this InetSocketAddress.
virtual jboolean equals (const Object &obj) const
 Compares this object against the specified object.
virtual jint hashCode () const
 Returns a hashcode for this socket address.

Constructor & Destructor Documentation

java::net::InetSocketAddress::InetSocketAddress ( jint  port = 0  ) 

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
Exceptions:
IllegalArgumentException if the port parameter is outside the specified range of valid port values.

java::net::InetSocketAddress::InetSocketAddress ( const Ref< InetAddress > &  addr,
jint  port = 0 
)

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
Exceptions:
IllegalArgumentException if the port parameter is outside the specified range of valid port values.

java::net::InetSocketAddress::InetSocketAddress ( const String hostname,
jint  port = 0 
)

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
Exceptions:
IllegalArgumentException if the port parameter is outside the range of valid port values, or if the hostname parameter is null.
See also:
isUnresolved()


Member Function Documentation

jint java::net::InetSocketAddress::getPort (  )  const

Gets the port number.

Returns:
the port number.

Ref<InetAddress> java::net::InetSocketAddress::getAddress (  )  const

Gets the InetAddress.

Returns:
the InetAdress or null if it is unresolved.

String java::net::InetSocketAddress::getHostName (  )  const

Gets the hostname.

Returns:
the hostname part of the address.

jboolean java::net::InetSocketAddress::isUnresolved (  )  const

Checks wether the address has been resolved or not.

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

virtual String java::net::InetSocketAddress::toString (  )  const [virtual]

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.

Returns:
a string representation of this object.

Reimplemented from java::lang::Object.

virtual jboolean java::net::InetSocketAddress::equals ( const Object obj  )  const [virtual]

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.
Returns:
true if the objects are the same; false otherwise.
See also:
java.net.InetAddress::equals()

Reimplemented from java::lang::Object.

virtual jint java::net::InetSocketAddress::hashCode (  )  const [virtual]

Returns a hashcode for this socket address.

Returns:
a hash code value for this socket address.

Reimplemented from java::lang::Object.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:44 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3