com.kenmccrary.jtella
Class BaseConnection
java.lang.Object
|
+--com.kenmccrary.jtella.BaseConnection
- All Implemented Interfaces:
- java.lang.Runnable
- public class BaseConnection
- extends java.lang.Object
- implements java.lang.Runnable
Represents a connection to a computer on the network
Constructor Summary |
BaseConnection(java.lang.String host,
int port)
Construct the Connection; |
Method Summary |
void |
run()
Connection monitoring thread |
void |
send(com.kenmccrary.jtella.Message m)
Sends a Message through this connection |
void |
sendAndReceive(com.kenmccrary.jtella.Message m,
MessageReceiver receiver)
Sends a message down the connection and sends any response
to MessageReceiver |
boolean |
start()
Starts a connection to a node on the network,
does initial handshaking |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
BaseConnection
public BaseConnection(java.lang.String host,
int port)
throws java.net.UnknownHostException,
java.io.IOException
- Construct the Connection;
- Parameters:
host
- can be a machine name or IP addressport
- port to use
start
public boolean start()
- Starts a connection to a node on the network,
does initial handshaking
- Returns:
- true for a good start, false for failure
send
public void send(com.kenmccrary.jtella.Message m)
throws java.io.IOException
- Sends a Message through this connection
- Parameters:
m
- message
sendAndReceive
public void sendAndReceive(com.kenmccrary.jtella.Message m,
MessageReceiver receiver)
throws java.io.IOException
- Sends a message down the connection and sends any response
to
MessageReceiver
run
public void run()
- Connection monitoring thread
- Specified by:
- run in interface java.lang.Runnable