public class TcpHubConnector extends java.lang.Thread implements Connector
Modifier and Type | Field and Description |
---|---|
protected java.util.List<org.arl.fjage.connectors.TcpHubConnector.ClientThread> |
clientThreads |
protected ConnectionListener |
listener |
protected java.util.logging.Logger |
log |
protected org.arl.fjage.connectors.TcpHubConnector.OutputThread |
outThread |
protected PseudoInputStream |
pin |
protected int |
port |
protected PseudoOutputStream |
pout |
protected java.net.ServerSocket |
sock |
protected boolean |
telnet |
Constructor and Description |
---|
TcpHubConnector(int port)
Creates a TCP server running on a specified port.
|
TcpHubConnector(int port,
boolean telnet)
Creates a TCP server running on a specified port.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Shutdown the TCP server.
|
java.io.InputStream |
getInputStream()
Get the input stream to read data over.
|
java.io.OutputStream |
getOutputStream()
Get the output stream to write data to.
|
int |
getPort()
Get the TCP port on which the server listens for connections.
|
boolean |
isReliable()
Check if a connection is relaible.
|
void |
run() |
void |
setConnectionListener(ConnectionListener listener)
Set a connection state listener.
|
java.lang.String |
toString() |
boolean |
waitOutputCompletion(long timeout)
Wait until the output buffer is empty.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
protected int port
protected boolean telnet
protected java.net.ServerSocket sock
protected org.arl.fjage.connectors.TcpHubConnector.OutputThread outThread
protected java.util.List<org.arl.fjage.connectors.TcpHubConnector.ClientThread> clientThreads
protected java.util.logging.Logger log
protected PseudoInputStream pin
protected PseudoOutputStream pout
protected ConnectionListener listener
public TcpHubConnector(int port, boolean telnet)
port
- TCP port number.telnet
- true to negotiate character mode using telnet protocol,
false to leave the choice to the client.public TcpHubConnector(int port)
port
- TCP port number.public int getPort()
public void close()
public boolean isReliable()
Connector
isReliable
in interface Connector
public boolean waitOutputCompletion(long timeout)
Connector
waitOutputCompletion
in interface Connector
timeout
- timeout in milliseconds.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public java.io.InputStream getInputStream()
Connector
getInputStream
in interface Connector
public java.io.OutputStream getOutputStream()
Connector
getOutputStream
in interface Connector
public void setConnectionListener(ConnectionListener listener)
Connector
setConnectionListener
in interface Connector
listener
- listener to call for connection/disconnection,
or null to disable listener.public java.lang.String toString()
toString
in class java.lang.Thread