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.lang.String[] |
connections()
Gets a list of all known active connections
|
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, yieldprotected int port
protected boolean telnet
protected java.net.ServerSocket sock
protected org.arl.fjage.connectors.TcpHubConnector.OutputThread outThread
protected final 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 (0 to autoselect).telnet - true to negotiate character mode using telnet protocol,
false to leave the choice to the client.java.io.UncheckedIOException - if the port cannot be bound (e.g. already in use).public TcpHubConnector(int port)
port - TCP port number (0 to autoselect).java.io.UncheckedIOException - if the port cannot be bound (e.g. already in use).public int getPort()
public void close()
public boolean isReliable()
ConnectorisReliable in interface Connectorpublic boolean waitOutputCompletion(long timeout)
ConnectorwaitOutputCompletion in interface Connectortimeout - timeout in milliseconds.public void run()
run in interface java.lang.Runnablerun in class java.lang.Threadpublic java.io.InputStream getInputStream()
ConnectorgetInputStream in interface Connectorpublic java.io.OutputStream getOutputStream()
ConnectorgetOutputStream in interface Connectorpublic void setConnectionListener(ConnectionListener listener)
ConnectorsetConnectionListener in interface Connectorlistener - listener to call for connection/disconnection,
or null to disable listener.public java.lang.String[] connections()
Connectorconnections in interface Connectorpublic java.lang.String toString()
toString in class java.lang.Thread