|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.miv.mbox.net.Receiver.IncomingBuffer
protected class Receiver.IncomingBuffer
The connection to a sender. The receiver maintains several incoming connections and demultiplexes them.
| Field Summary | |
|---|---|
protected boolean |
active
When false the socket is closed and this buffer must be removed from the active connections. |
protected int |
beg
Index in the buffer of the first byte that forms the currents message. |
protected ByteBuffer |
buf
Buffer for reading. |
protected static int |
BUFFER_INITIAL_SIZE
|
protected int |
end
Index in the buffer past the last byte that forms the current message. |
protected int |
pos
Position inside beg and end past the last byte read. |
| Constructor Summary | |
|---|---|
Receiver.IncomingBuffer()
|
|
| Method Summary | |
|---|---|
protected int |
bufferize(int at,
SocketChannel socket)
Read more data from the socket and put it in the buffer at
at. |
protected int |
compactBuffer()
Compact the buffer by removing all read data before beg. |
protected void |
decodeMessage(int limit)
Decode one message. |
protected void |
enlargeBuffer()
Not used in the current implementation, we assumes that no message will be larger than the size of the buffer. |
void |
readDataChunk(SelectionKey key)
Read the available bytes and buffers them. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int BUFFER_INITIAL_SIZE
protected ByteBuffer buf
protected int end
protected int beg
protected int pos
protected boolean active
| Constructor Detail |
|---|
public Receiver.IncomingBuffer()
| Method Detail |
|---|
public void readDataChunk(SelectionKey key)
throws IOException
IOException
protected int bufferize(int at,
SocketChannel socket)
throws IOException
socket and put it in the buffer at
at. If the read returns -1 bytes (meaning the
connection ended), the socket is closed and this buffer will be made
inactive (and therefore removed from the active connections by the
Receiver that called it).
IOException - if an I/O error occurs, in between the socket is
closed and the connection is made inactive, then the exception is
thrown.
protected void decodeMessage(int limit)
throws IOException
IOExceptionprotected int compactBuffer()
beg.
The beg, end and pos markers are
updated accordingly. Compact works only if beg is larger than four (the
size of a header).
protected void enlargeBuffer()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||