protected class NetStreamReceiver.IncomingBuffer extends Object
Modifier and Type | Field and Description |
---|---|
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.
|
(package private) org.miv.mbox.net.PositionableByteArrayInputStream |
bin
Input stream filter on the buffer.
|
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.
|
(package private) org.miv.mbox.net.PositionableByteArrayInputStream |
in
Object input stream for reading the buffer.
|
protected int |
pos
Position inside beg and end past the last byte read.
|
Constructor and Description |
---|
IncomingBuffer() |
Modifier and Type | Method and Description |
---|---|
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 |
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.
|
protected static final int BUFFER_INITIAL_SIZE
protected ByteBuffer buf
protected int end
protected int beg
protected int pos
org.miv.mbox.net.PositionableByteArrayInputStream in
org.miv.mbox.net.PositionableByteArrayInputStream bin
protected boolean active
public IncomingBuffer()
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 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()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses