Modifier and Type | Class and Description |
---|---|
private class |
TCPIPLink.CreateRxStream
The process which creates rxStream.
|
private class |
TCPIPLink.CreateTxStream
The process which creates txStream.
|
private class |
TCPIPLink.RxId
The process which recieves the remote Id.
|
private class |
TCPIPLink.RxLoop
The process which recieves from a socket.
|
private class |
TCPIPLink.TxId
The process which sends our Id.
|
private class |
TCPIPLink.TxLoop
The process which does transmission to a socket.
|
private class |
TCPIPLink.TxLoopPoison
An object of this type is used by RxLoop to poison TxLoop.
|
Modifier and Type | Field and Description |
---|---|
private static int |
BUFFER_SIZE
Size of Java buffers.
|
private static java.lang.String |
PROTOCOL_IDENTIFIER
Handshaking string.
|
private TCPIPAddressID |
remoteTCPIPAddress
The other computer's IP address and port.
|
private java.io.ObjectInputStream |
rxStream
The stream for reading from the socket.
|
private java.net.Socket |
socket
The actual socket.
|
private java.io.ObjectOutputStream |
txStream
The stream for reading from the socket.
|
remoteNodeID, sendNodeID, txChannel
Constructor and Description |
---|
TCPIPLink(java.net.Socket socket)
Constructor for using an existing socket.
|
TCPIPLink(java.net.Socket socket,
boolean client)
Constructor for using an existing socket.
|
TCPIPLink(TCPIPAddressID remoteTCPIPAddress)
Constructor for connecting to a remote computer.
|
Modifier and Type | Method and Description |
---|---|
private void |
closeRx()
Closes the Rx stream and the socket, if needed.
|
private void |
closeSocket()
Closes the socket, if needed.
|
private void |
closeTx()
Closes the Tx stream and the socket, if needed.
|
protected boolean |
connect()
Connect to remote host.
|
protected boolean |
createResources()
Create the object streams used to communicate with the peer system.
|
protected void |
destroyResources()
Closes the streams and the socket, if needed.
|
protected boolean |
exchangeNodeIDs()
Performs the node exchange part of the handshaking process.
|
protected boolean |
readLinkDecision()
Reads a boolean link decision from the input stream.
|
protected java.lang.Object |
readTestObject()
Reads a test object from the input stream.
|
protected void |
runTxRxLoop()
Run the send and receive threads to marshall and unmarshall objects.
|
protected void |
start(boolean newProcess)
Start this Link but allow the caller to continue in parallel.
|
protected void |
waitForReplies(int numRepliesOutstanding)
Waits for
numRepliesOutstanding instances of LinkLost
to arrive from the txChannel . |
protected void |
writeLinkDecision(boolean use)
Writes a boolean link decision value to the output stream.
|
protected void |
writeTestObject(java.lang.Object obj)
Writes a test object to the output stream, flushing and resetting the stream afterwards.
|
deliverReceivedObject, equals, getPingTime, getProtocolID, getReadSequence, getRemoteNodeID, getTxChannel, hashCode, obtainNodeID, performedPingTest, ping, run
private TCPIPAddressID remoteTCPIPAddress
private java.net.Socket socket
private java.io.ObjectInputStream rxStream
private java.io.ObjectOutputStream txStream
private static java.lang.String PROTOCOL_IDENTIFIER
private static final int BUFFER_SIZE
Socket.setReceiveBufferSize(int)
and
Socket.setSendBufferSize(int)
.TCPIPLink(java.net.Socket socket)
socket
- The socket to the remote computer, which must already be
open and active. You must not have transmitted anything
over the socket.TCPIPLink(java.net.Socket socket, boolean client)
socket
- The socket to the remote computer, which must already be
open and active. You must not have transmitted anything
over the socket.client
- Tells the link whether to act as a client or a server
during the handshake processTCPIPLink(TCPIPAddressID remoteTCPIPAddress)
remoteTCPIPAddress
- The remote computer to connect to.protected void runTxRxLoop()
runTxRxLoop
in class Link
protected void waitForReplies(int numRepliesOutstanding)
numRepliesOutstanding
instances of LinkLost
to arrive from the txChannel
.waitForReplies
in class Link
numRepliesOutstanding
- LinkLost
instances to wait for.protected void start(boolean newProcess)
protected boolean connect()
protected boolean createResources()
createResources
in class Link
protected boolean exchangeNodeIDs()
NodeID
and a process to receive the peer node ID. Called internally
by the superclass.exchangeNodeIDs
in class Link
protected void writeTestObject(java.lang.Object obj) throws java.lang.Exception
readTestObject
method at the peer
node.writeTestObject
in class Link
obj
- Object to be sentjava.lang.Exception
protected java.lang.Object readTestObject() throws java.lang.Exception
writeTestObject
at the
peer node.readTestObject
in class Link
java.lang.Exception
protected void writeLinkDecision(boolean use) throws java.lang.Exception
readLinkDecision
method at the peer node.writeLinkDecision
in class Link
use
- boolean decision value to send.java.lang.Exception
protected boolean readLinkDecision() throws java.lang.Exception
writeLinkDecision
at the peer node.readLinkDecision
in class Link
java.lang.Exception
protected void destroyResources()
destroyResources
in class Link
private void closeRx()
private void closeTx()
private void closeSocket()