Modifier and Type | Field and Description |
---|---|
protected java.io.OutputStream |
out |
protected java.net.Socket |
sock |
Constructor and Description |
---|
TcpConnector(java.net.Socket sock)
Create a TCP connector object with an already open socket.
|
TcpConnector(java.lang.String hostname,
int port)
Open a TCP client connection to a TCP server.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the connection.
|
java.io.InputStream |
getInputStream()
Get the input stream to read data over.
|
java.lang.String |
getName()
Get a string representation of the connection.
|
java.io.OutputStream |
getOutputStream()
Get the output stream to write data to.
|
boolean |
isReliable()
Check if a connection is relaible.
|
void |
setConnectionListener(ConnectionListener listener)
Set a connection state listener.
|
java.lang.String |
toString() |
boolean |
waitOutputCompletion(long timeout)
Wait until the output buffer is empty.
|
public TcpConnector(java.lang.String hostname, int port) throws java.io.IOException
java.io.IOException
public TcpConnector(java.net.Socket sock) throws java.io.IOException
java.io.IOException
public java.lang.String getName()
Connector
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 void close()
Connector
public boolean isReliable()
Connector
isReliable
in interface Connector
public boolean waitOutputCompletion(long timeout)
Connector
waitOutputCompletion
in interface Connector
timeout
- timeout in milliseconds.public java.lang.String toString()
toString
in class java.lang.Object