|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
org.opcfoundation.ua.utils.asyncsocket.AsyncInputStream
public abstract class AsyncInputStream
Asyncronous input stream of asynchronous socket. There are two positions properties: Bytes received (to buffer) and bytes read.
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 Summary | |
|---|---|
AsyncInputStream()
|
|
| Method Summary | |
|---|---|
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 int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from the input stream into
an array of bytes. |
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. |
| Methods inherited from class java.io.InputStream |
|---|
close, mark, markSupported, read, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AsyncInputStream()
| Method Detail |
|---|
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.
read in class InputStreamb - 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 int read(byte[] b,
int off,
int len)
len bytes of data from the input stream into
an array of bytes. An attempt is made to read as many as
len bytes, but a smaller number may be read.
The number of bytes actually read is returned as an integer.
read in class InputStreamInputStream.read()public abstract long getReceivedBytes()
public abstract long getPosition()
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 listener
public abstract int getBufferSize()
public abstract void setBufferSize(int size)
size - new buffer size valuepublic 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 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 available()
available in class InputStream
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||