public abstract class AsyncInputStream extends Object
Synchronous reads can be made with use of alarm, e.g. BufferMonitor a = is.createBufferMonitor(is.getPosition() + 1000, null); a.waitForState(AlarmState.FINAL_STATES); byte[] data = new byte[1000]; is.read(data);
Note there is a limit (40kb) how much data is buffered. To up the limit set an alarm. Creating an alarm to position Long.MAX_VALUE removes any limits of the buffer.
AsyncSocketImpl,
BufferMonitor| Constructor and Description |
|---|
AsyncInputStream() |
| Modifier and Type | Method and Description |
|---|---|
abstract int |
available()
Return the number of bytes available in the buffer.
|
abstract BufferMonitor |
createMonitor(long position,
MonitorListener listener)
Create an object that monitors the position input stream.
|
abstract int |
getBufferSize()
Get the number of bytes the stream buffers from TCP stack.
|
abstract long |
getPosition()
Get stream position.
|
abstract long |
getReceivedBytes()
Get the number of bytes received to this stream
|
abstract void |
peek(byte[] buf)
Peek ahead into buffered content.
|
abstract void |
peek(byte[] buf,
int off,
int len)
Peek bytes to buffer
|
abstract ByteBuffer |
peek(int len)
Peek bytes to returned buffer
|
abstract ByteBuffer[] |
peekChunks(int len)
Peek bytes to byte chunks.
|
abstract int |
read(byte[] b)
Reads some number of bytes from the input stream and stores them into the buffer array
b. |
abstract void |
read(ByteBuffer dst)
Read to byte buffer
|
abstract void |
read(ByteBuffer dst,
int length)
Read the given number of bytes to byte buffer.
|
abstract ByteBuffer |
read(int len)
Read from the stream.
|
abstract ByteBuffer[] |
readChunks(int len)
Read from the input stream.
|
abstract void |
setBufferSize(int size)
Set a hint number for buffering.
|
public abstract int available()
public abstract BufferMonitor createMonitor(long position, MonitorListener listener)
The buffer size is enlarged when a monitor with a position outside the buffer range is created. For instance, there is an input stream. Its position is 5, buffer size is 5. It received data to 10 and stops. If monitor at position 20 is created, the stream received 10 more additional bytes.
position - position at which to trigger an alarmlistener - alarm listenerpublic abstract int getBufferSize()
public abstract long getPosition()
public abstract long getReceivedBytes()
public abstract void peek(byte[] buf)
buf - an array of byte.public abstract void peek(byte[] buf,
int off,
int len)
buf - an array of byte.off - a int.len - a int.public abstract ByteBuffer peek(int len)
len - a int.public abstract ByteBuffer[] peekChunks(int len)
len - a int.public abstract int read(byte[] b)
b. The number of bytes actually read is returned as an integer. This method blocks
until input data is available, end of file is detected, or an exception is thrown.b - the buffer into which the data is read.-1 is there is no more
data because the end of the stream has been reached.InputStream.read(byte[], int, int)public abstract void read(ByteBuffer dst)
dst - a ByteBuffer object.public abstract void read(ByteBuffer dst, int length)
dst - a ByteBuffer object.length - a int.public abstract ByteBuffer read(int len)
len - a int.public abstract ByteBuffer[] readChunks(int len)
len - a int.public abstract void setBufferSize(int size)
size - new buffer size valueCopyright © 2026. All rights reserved.