|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--DNet.DataConnection
This class is used to represent a connection. It manages all I/O between the client and the connection [Proxy Pattern]. The class is not synchronized - it is assumed that only one client will be using the connection.
Field Summary | |
private java.net.Socket |
connection
|
private java.io.PushbackInputStream |
input
|
private java.io.DataOutputStream |
output
|
private long |
timeOut
|
private long |
timeOutStart
|
Constructor Summary | |
DataConnection(java.net.Socket connection)
|
Method Summary | |
int |
available()
|
boolean |
close()
|
int |
getByte()
Reads one byte. |
int |
getBytes(byte[] buffer)
Read bytes into the array. |
byte[] |
getBytes(int size)
Read a number of bytes. |
Data |
getData(int size)
|
java.lang.String |
getHostAddress()
|
java.lang.String |
getIP()
|
java.lang.String |
getLine()
Read a line. |
java.lang.String |
getLine(char firstChar)
Read a line |
java.util.LinkedList |
getLines()
Read lines, terminated by an empty line. |
java.util.LinkedList |
getLines(char firstChar)
Read lines, terminated by an empty |
int |
getPort()
|
private void |
initTimeOut()
Resets timeout |
private boolean |
isTimeOut()
Has a timeout occured |
Data |
peekData(int size)
|
boolean |
peekString(java.lang.String s,
boolean ignoreCase)
|
void |
setIdleTimeout(int timeoutSecs)
|
private boolean |
waitForByte()
|
private boolean |
waitForBytes(int size)
Wait for a number of bytes to be available |
void |
write(byte[] b)
|
void |
write(byte[] b,
int offset,
int pos)
|
void |
write(int i)
|
void |
writeBytes(java.lang.String s)
|
void |
writeCRLF()
|
void |
writeLFLF()
|
void |
writeLine(java.lang.String s)
|
void |
writeLines(java.util.LinkedList lines)
|
Methods inherited from class java.lang.Object |
|
Field Detail |
private java.net.Socket connection
private java.io.PushbackInputStream input
private java.io.DataOutputStream output
private long timeOutStart
private long timeOut
Constructor Detail |
public DataConnection(java.net.Socket connection) throws java.io.IOException
Method Detail |
public void setIdleTimeout(int timeoutSecs)
public java.lang.String getHostAddress()
public boolean close()
public int available()
public java.lang.String getIP()
public int getPort()
public Data getData(int size) throws java.io.IOException
public Data peekData(int size) throws java.io.IOException
public boolean peekString(java.lang.String s, boolean ignoreCase)
public java.lang.String getLine() throws java.io.IOException
public java.lang.String getLine(char firstChar) throws java.io.IOException
firstChar
- The first of the newline delimiters. The second is assumed existing, but ignored.
The usual parameters are 0x0D (CDxx, CDLF) or 0x0A (LFxx, LFLF)public java.util.LinkedList getLines() throws java.io.IOException
public java.util.LinkedList getLines(char firstChar) throws java.io.IOException
firstChar
- The first of the newline delimiters. The second is assumed existing, but ignored.
The usual parameters are 0x0D (CDxx, CDLF) or 0x0A (LFxx, LFLF)public byte[] getBytes(int size) throws java.io.IOException
size
- The number of wanted bytespublic int getBytes(byte[] buffer) throws java.io.IOException
buffer
- The arraypublic int getByte() throws java.io.IOException
private void initTimeOut()
private boolean isTimeOut()
private boolean waitForBytes(int size)
size
- The wanted number of bytesprivate boolean waitForByte()
public void writeLines(java.util.LinkedList lines) throws java.io.IOException
public void writeLine(java.lang.String s) throws java.io.IOException
public void writeCRLF() throws java.io.IOException
public void writeLFLF() throws java.io.IOException
public void writeBytes(java.lang.String s) throws java.io.IOException
public void write(byte[] b, int offset, int pos) throws java.io.IOException
public void write(int i) throws java.io.IOException
public void write(byte[] b) throws java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |