|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.msi.network.connection.TCPConnection
TCPConnection - a TCP/IP socket connection.
Supports connection timeouts (with a default value) and reads with individual read timeouts.
| Field Summary | |
private java.net.InetAddress |
clientAddress
|
private int |
clientPort
|
protected java.net.Socket |
conn
conn - Socket that is connected to the client. |
private long |
connTO
|
protected java.io.BufferedInputStream |
instream
instream - |
private TCPInterface |
interfaceController
|
private int |
serverPort
|
| Constructor Summary | |
TCPConnection(java.net.ServerSocket sock,
TCPInterface ioif)
Creates a new TCPConnection instance. |
|
TCPConnection(java.net.ServerSocket sock,
TCPInterface ioif,
long cTO)
Creates a new TCPConnection instance. |
|
| Method Summary | |
void |
close()
Close the connection freeing any system resources. |
private boolean |
endsWith(java.lang.String s,
java.lang.String suf)
Check in a case insensitive manner that the supplied string ends with the suffix. |
java.net.InetAddress |
getClientAddress()
Describe getClientAddress method here. |
int |
getClientPort()
Describe getClientPort method here. |
long |
getConnTO()
Get the value of connTO. |
java.lang.String |
getLine()
Read what the client has to write, stripping any leading whitespace and dropping the eol marker(s). |
java.lang.String |
getLine(long TO)
Read what the client has to write, stripping any leading whitespace and dropping the eol marker(s). |
int |
getServerPort()
Describe getServerPort method here. |
void |
init()
Create a connection and set up the input stream |
void |
putLine(java.lang.String line)
Send information back to the client one line at a time. |
void |
putLine(java.lang.String ln,
java.net.InetAddress cAddress,
int cPort)
This supports external submission of the recipient address, which allows us to send datagrams to multiple clients across a single port. |
int |
read(byte[] data)
Reads all the client input regardless of line breaks. |
int |
read(byte[] data,
long TO)
Reads all the client input regardless of line breaks. |
void |
reset()
reset - |
void |
setConnTO(long v)
Set the value of connTO. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private java.net.InetAddress clientAddress
private int clientPort
private int serverPort
private long connTO
protected java.io.BufferedInputStream instream
instream -
protected java.net.Socket conn
conn - Socket that is connected to the client.
private TCPInterface interfaceController
| Constructor Detail |
public TCPConnection(java.net.ServerSocket sock,
TCPInterface ioif)
TCPConnection instance.
sock - a ServerSocket valueioif - the TCPInterface that manages this connection.
public TCPConnection(java.net.ServerSocket sock,
TCPInterface ioif,
long cTO)
TCPConnection instance.
sock - a ServerSocket valueioif - the TCPInterface that manages this connection.cTO - the new connection time out value.| Method Detail |
public java.lang.String getLine()
throws ConnectionException
getLine in interface ConnectionString value
ConnectionException - if an error occurs
public java.lang.String getLine(long TO)
throws ConnectionException
getLine in interface ConnectionTO - timeout in milliseconds
String value
ConnectionException - if an error occurs
public int read(byte[] data,
long TO)
throws ConnectionException,
java.io.IOException
read bytes in a loop until byte buffer is full, or low-level read times out. Any bytes read before the timeout are returned and if it is the end of communications, the caller will find out on the next call. No bytes read indicates the client is gone missing.
read in interface Connectiondata - buffer for input.TO - timeout in milliseconds, 0 is forever
ConnectionException - if an error occurs
java.io.IOException
public int read(byte[] data)
throws ConnectionException,
java.io.IOException
read in interface Connectiondata - buffer for input.
ConnectionException - if an error occurs
java.io.IOException
private boolean endsWith(java.lang.String s,
java.lang.String suf)
s - string checked for endingsuf - suffix searched for
public void putLine(java.lang.String line)
throws ConnectionException
putLine in interface Connectionline - a String value
ConnectionException - if an error occurs
public void putLine(java.lang.String ln,
java.net.InetAddress cAddress,
int cPort)
throws ConnectionException
putLine in interface Connectionln - a String valuecAddress - an InetAddress valuecPort - an int value
ConnectionException - if an error occurs
public void init()
throws java.io.IOException
init in interface Connectionjava.io.IOException - if an error occurspublic void close()
close in interface Connection
public void reset()
throws java.io.IOException
reset -
reset in interface Connectionjava.io.IOException - if an error occurspublic java.net.InetAddress getClientAddress()
getClientAddress method here.
getClientAddress in interface ConnectionInetAddress valuepublic int getClientPort()
getClientPort method here.
getClientPort in interface Connectionint valuepublic int getServerPort()
getServerPort method here.
getServerPort in interface Connectionint valuepublic long getConnTO()
public void setConnTO(long v)
v - Value to assign to connTO.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||