public class TCPIPAddressID extends NodeAddressID
Provides a concrete implementation of the abstract NodeAddressID
for use with the
TCP/IP link protocol. A TCP/IP node address consists of an internet host address (IP address)
and 16bit IP port number.
Constructor and Description |
---|
TCPIPAddressID(java.net.InetAddress host,
int port,
boolean isUnique)
Creates a TCPIPAddressID for a computer, given it's IP address
and port number.
|
TCPIPAddressID(java.lang.String host,
int port,
boolean isUnique)
Creates a TCPIPAddressID for a computer, given it's host name
and port number.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Compares two TCPIPAddressID for equality.
|
static NodeAddressID |
getAddressIDFromString(java.lang.String stringForm)
Constructs and returns a TCPIPv4 NodeAddressID from a String.
|
java.net.InetAddress |
getHost()
Returns the computer's IP address
|
int |
getPort()
Returns the computer's port number for incoming link requests.
|
ProtocolID |
getProtocolID()
Returns the ProtocolID for this address
|
protected java.lang.String |
getStringForm()
Returns a string representation of the address suitable for use in the
createAddressID
method of TCPIPProtocolID . |
int |
hashCode()
Returns a hashCode for this TCPIPAddressID
|
boolean |
isGloballyUnique()
Returns
true if this NodeAddressID is known to be
unique within the global org.jcsp.net domain. |
java.lang.String |
toString()
Returns a string representation of this TCPIPAddressID, in the form
"123.45.67.234:5678".
|
clone
public TCPIPAddressID(java.net.InetAddress host, int port, boolean isUnique) throws java.lang.IllegalArgumentException
host
- The computer's IP address.port
- The computer's port number, in the range 0-65535 inclusive.isUnique
- True if the address ID is globally unique, false otherwise.java.lang.IllegalArgumentException
- If the port is invalid.public TCPIPAddressID(java.lang.String host, int port, boolean isUnique) throws java.lang.IllegalArgumentException, java.net.UnknownHostException
host
- The computer's IP address, as a stringport
- The computer's port number.java.lang.IllegalArgumentException
- If the port is invalid.java.net.UnknownHostException
- If the host name cannot be resolved.public static NodeAddressID getAddressIDFromString(java.lang.String stringForm) throws java.lang.IllegalArgumentException
stringForm
- The String form representing a NodeAddressID.java.lang.IllegalArgumentException
- if the string is incorrectly formatted.protected java.lang.String getStringForm()
createAddressID
method of TCPIPProtocolID
.getStringForm
in class NodeAddressID
String
that can be passed to the static getAddressIDFromString(String)
method in order to reconstuct the object.public ProtocolID getProtocolID()
getProtocolID
in class NodeAddressID
NodeAddressID
object's ProtocolID
.public final java.net.InetAddress getHost()
public final int getPort()
public final boolean equals(java.lang.Object obj)
equals
in class NodeAddressID
obj
- another object that should be another NodeAddressID
.public final int hashCode()
hashCode
in class NodeAddressID
int
hash code.public boolean isGloballyUnique()
NodeAddressID
Returns true
if this NodeAddressID
is known to be
unique within the global org.jcsp.net domain.
A Node may have several addresses. If a Node is on an internal network that
is connected to the Internet, it may have one local address and one address
that is accessible from the Internet. The Internet address may be globally
unique whereas the local address may be duplicated in other internal networks.
The NodeAddressID
object representing the Internet address should
return true
when this method is called whereas the
NodeAddressID
representing the local address should return
false
.
isGloballyUnique
in class NodeAddressID
true
iff this NodeAddressID
is globally unique.public final java.lang.String toString()
toString
in class java.lang.Object
Submit a bug or feature to jcsp-team@kent.ac.uk
Version 1.1-rc4 of the JCSP API Specification (Copyright 1997-2008 P.D.Austin and P.H.Welch - All Rights Reserved)
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.