1
package org.jcsp.net2.tcpip;
3
import org.jcsp.net2.JCSPNetworkException;
4
import org.jcsp.net2.Link;
5
import org.jcsp.net2.LinkServer;
6
import org.jcsp.net2.NodeAddress;
7
import org.jcsp.net2.ProtocolID;
10
* A concrete implementation of a NodeAddress that is designed for TCP/IP connections.
13
* @author Kevin Chalmers
15
public final class TCPIPNodeAddress
19
* The SUID for this class
21
private static final long serialVersionUID = 1L;
24
* The IP address part of the address
29
* The port part of the address
34
* Creates a new TCPIPNodeAddress from an IP address and port
37
* The IP address part of the NodeAddress
39
* The port number part of the NodeAddress
41
public TCPIPNodeAddress(String ipAddress, int portNumber)
44
this.port = portNumber;
45
this.protocol = "tcpip";
46
this.address = ipAddress + ":" + portNumber;
50
* Creates a new TCPIPNodeAddress using the local IP address and a given port number. Allows a
53
* The port number to use
55
public TCPIPNodeAddress(int portNumber)
57
this.port = portNumber;
59
this.protocol = "tcpip";
63
* Creates a new TCPIPNodeAddress
65
public TCPIPNodeAddress()
69
this.protocol = "tcpip";
73
* Gets the port number part of this address
75
* @return The port number part of the address
77
public final int getPort()
83
* Sets the port part of the address. Used internally in JCSP
86
* The port number to use
88
void setPort(int portNumber)
90
this.port = portNumber;
94
* Gets the IP address part of the address
96
* @return The IP Address part of the address
98
public final String getIpAddress()
104
* Sets the IP address part of the NodeAddress. Used internally in JCSP
107
* The IP address to use
109
void setIpAddress(String ipAddr)
115
* Sets the address String. Used internally within JCSP
118
* The String to set as the address
120
void setAddress(String str)
126
* Creates a new TCPIPLink connected to a Node with this address
128
* @return A new TCPIPLink connected to this address
129
* @throws JCSPNetworkException
130
* Thrown if something goes wrong during the creation of the Link
132
protected Link createLink()
133
throws JCSPNetworkException
135
return new TCPIPLink(this);
139
* Creates a new TCPIPLinkServer listening on this address
141
* @return A new TCPIPLinkServer listening on this address
142
* @throws JCSPNetworkException
143
* Thrown if something goes wrong during the creation of the LinkServer
145
protected LinkServer createLinkServer()
146
throws JCSPNetworkException
148
return new TCPIPLinkServer(this);
152
* Returns the TCPIPProtocolID
154
* @return TCPIPProtocolID
156
protected ProtocolID getProtocolID()
158
return TCPIPProtocolID.getInstance();