|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface INonBlockingConnection
A connection which uses the underlying channel in a non-blocking manner.
Nested Class Summary | |
---|---|
static class |
INonBlockingConnection.TransferResult
|
Nested classes/interfaces inherited from interface org.xsocket.stream.IConnection |
---|
IConnection.FlushMode |
Field Summary | |
---|---|
static IConnection.FlushMode |
INITIAL_FLUSH_MODE
|
static int |
UNLIMITED
|
Fields inherited from interface org.xsocket.stream.IConnection |
---|
INITIAL_AUTOFLUSH, INITIAL_DEFAULT_ENCODING, SO_KEEPALIVE, SO_LINGER, SO_RCVBUF, SO_REUSEADDR, SO_SNDBUF, TCP_NODELAY |
Method Summary | |
---|---|
void |
flush()
flush the send buffer. |
IConnection.FlushMode |
getFlushmode()
return the flushmode |
int |
getIndexOf(java.lang.String str)
Returns the index of the first occurrence of the given string. |
int |
getIndexOf(java.lang.String str,
int maxLength)
Returns the index of the first occurrence of the given string. |
int |
getNumberOfAvailableBytes()
get the number of available bytes to read |
int |
indexOf(java.lang.String str)
Deprecated. uses getIndexOf instead |
java.nio.ByteBuffer[] |
readAvailable()
read all received bytes |
boolean |
readAvailableByDelimiter(java.lang.String delimiter,
java.lang.String encoding,
java.nio.channels.WritableByteChannel outputChannel)
Deprecated. use transferToAvailableByDelimiter(String, String, WritableByteChannel) instead |
boolean |
readAvailableByDelimiter(java.lang.String delimiter,
java.nio.channels.WritableByteChannel outputChannel)
Deprecated. use transferToAvailableByDelimiter(String, WritableByteChannel) instead |
byte |
readByte()
read a byte |
java.nio.ByteBuffer[] |
readByteBufferByDelimiter(java.lang.String delimiter)
read a ByteBuffer by using a delimiter To avoid memory leaks the readByteBufferByDelimiter(String, int) method is generally preferable
For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes |
java.nio.ByteBuffer[] |
readByteBufferByDelimiter(java.lang.String delimiter,
int maxLength)
read a ByteBuffer by using a delimiter For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes |
java.nio.ByteBuffer[] |
readByteBufferByLength(int length)
read a ByteBuffer by using a length defintion For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes |
byte[] |
readBytesByDelimiter(java.lang.String delimiter)
read a byte array by using a delimiter To avoid memory leaks the readBytesByDelimiter(String, int) method is generally preferable
For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes |
byte[] |
readBytesByDelimiter(java.lang.String delimiter,
int maxLength)
read a byte array by using a delimiter For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes |
byte[] |
readBytesByLength(int length)
read bytes by using a length defintion For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes |
double |
readDouble()
read a double |
int |
readInt()
read an int |
long |
readLong()
read a long |
java.lang.String |
readStringByDelimiter(java.lang.String delimiter)
read a string by using a delimiter and the connection default encoding To avoid memory leaks the readStringByDelimiter(String, int) method is generally preferable |
java.lang.String |
readStringByDelimiter(java.lang.String delimiter,
int maxLength)
read a string by using a delimiter and the connection default encoding |
java.lang.String |
readStringByDelimiter(java.lang.String delimiter,
java.lang.String encoding)
read a string by using a delimiter To avoid memory leaks the readStringByDelimiter(String, String, int) method is generally preferable |
java.lang.String |
readStringByDelimiter(java.lang.String delimiter,
java.lang.String encoding,
int maxLength)
read a string by using a delimiter |
java.lang.String |
readStringByLength(int length)
read a string by using a length definition and the connection default encoding |
java.lang.String |
readStringByLength(int length,
java.lang.String encoding)
read a string by using a length definition |
void |
setFlushmode(IConnection.FlushMode flushMode)
set the flush mode By setting the flushmode with ASYNC (default is SYNC) the data will be transferred to the underlying connection in a asynchronous way. |
INonBlockingConnection |
setOption(java.lang.String name,
java.lang.Object value)
sets the value of a option |
void |
setWriteTransferRate(int bytesPerSecond)
set the send delay time. |
INonBlockingConnection.TransferResult |
transferToAvailableByDelimiter(java.lang.String delimiter,
java.lang.String encoding,
java.nio.channels.WritableByteChannel outputChannel)
transfers bytes from this connection to the given writable byte channel. |
INonBlockingConnection.TransferResult |
transferToAvailableByDelimiter(java.lang.String delimiter,
java.nio.channels.WritableByteChannel outputChannel)
transfers bytes from this connection to the given writable byte channel. |
int |
write(java.nio.ByteBuffer buffer)
sends a byte buffer to the remote endpoint. |
long |
write(java.nio.ByteBuffer[] buffers)
sends an array of byte buffer to the remote endpoint. |
Methods inherited from interface org.xsocket.stream.IConnection |
---|
activateSecuredMode, attach, attachment, getAttachment, getAutoflush, getConnectionTimeoutSec, getDefaultEncoding, getId, getIdleTimeoutSec, getIndexOf, getLocalAddress, getLocalPort, getOption, getOptions, getPendingWriteDataSize, getRemoteAddress, getRemotePort, isOpen, markReadPosition, markWritePosition, readByteBufferByDelimiter, readBytesByDelimiter, removeReadMark, removeWriteMark, resetToReadMark, resetToWriteMark, resumeRead, setAttachment, setAutoflush, setConnectionTimeoutSec, setDefaultEncoding, setIdleTimeoutSec, suspendRead, write, write, write, write, write, write, write, write |
Methods inherited from interface org.xsocket.IDataSource |
---|
readShort |
Methods inherited from interface org.xsocket.IDataSink |
---|
write |
Methods inherited from interface java.nio.channels.GatheringByteChannel |
---|
write |
Methods inherited from interface java.nio.channels.Channel |
---|
close |
Methods inherited from interface java.nio.channels.ReadableByteChannel |
---|
read |
Field Detail |
---|
static final int UNLIMITED
static final IConnection.FlushMode INITIAL_FLUSH_MODE
Method Detail |
---|
int getNumberOfAvailableBytes()
int indexOf(java.lang.String str)
str
- any string
int getIndexOf(java.lang.String str) throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException
getIndexOf
in interface IConnection
str
- any string
ClosedConnectionException
- If the underlying socket is already closed
java.io.IOException
- If some other I/O error occurs
java.nio.BufferUnderflowException
- if the given string has not been foundint getIndexOf(java.lang.String str, int maxLength) throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException, MaxReadSizeExceededException
getIndexOf
in interface IConnection
str
- any stringmaxLength
- the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
ClosedConnectionException
- If the underlying socket is already closed
java.io.IOException
- If some other I/O error occurs
MaxReadSizeExceededException
- If the max read length has been exceeded and the delimiter hasn’t been found
java.nio.BufferUnderflowException
- if the given string has not been foundjava.nio.ByteBuffer[] readAvailable() throws java.io.IOException, ClosedConnectionException
ClosedConnectionException
- If the underlying socket is already closed
java.io.IOException
- If some other I/O error occursboolean readAvailableByDelimiter(java.lang.String delimiter, java.nio.channels.WritableByteChannel outputChannel) throws java.io.IOException, ClosedConnectionException
transferToAvailableByDelimiter(String, WritableByteChannel)
instead
java.io.IOException
ClosedConnectionException
boolean readAvailableByDelimiter(java.lang.String delimiter, java.lang.String encoding, java.nio.channels.WritableByteChannel outputChannel) throws java.io.IOException, ClosedConnectionException
transferToAvailableByDelimiter(String, String, WritableByteChannel)
instead
java.io.IOException
ClosedConnectionException
INonBlockingConnection.TransferResult transferToAvailableByDelimiter(java.lang.String delimiter, java.nio.channels.WritableByteChannel outputChannel) throws ClosedConnectionException, java.io.IOException, java.net.SocketTimeoutException
INonBlockingConnection.TransferResult.delimiterFound
is
set with true. The INonBlockingConnection.TransferResult.written
contains the The number of bytes,
possibly zero, that were actually transferred
delimiter
- the delimiter to useoutputChannel
- the output channel to write the available bytes
java.io.IOException
- If some other I/O error occurs
java.net.SocketTimeoutException
- If the receive timeout has been reached (will only been thrown if autoflush = true)
ClosedConnectionException
- if the underlying channel is closedINonBlockingConnection.TransferResult transferToAvailableByDelimiter(java.lang.String delimiter, java.lang.String encoding, java.nio.channels.WritableByteChannel outputChannel) throws ClosedConnectionException, java.io.IOException, java.net.SocketTimeoutException
INonBlockingConnection.TransferResult.delimiterFound
is
set with true. The INonBlockingConnection.TransferResult.written
contains the The number of bytes,
possibly zero, that were actually transferred
delimiter
- the delimiter to useencoding
- the encoding of the delimiteroutputChannel
- the output channel to write the available bytes
java.io.IOException
- If some other I/O error occurs
java.net.SocketTimeoutException
- If the receive timeout has been reached (will only been thrown if autoflush = true)
ClosedConnectionException
- if the underlying channel is closedjava.nio.ByteBuffer[] readByteBufferByDelimiter(java.lang.String delimiter) throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException
readByteBufferByDelimiter(String, int)
method is generally preferable
readByteBufferByDelimiter
in interface IConnection
delimiter
- the delimiter
java.io.IOException
- If some other I/O error occurs
java.nio.BufferUnderflowException
- if the delimiter has not been found
ClosedConnectionException
- If the underlying socket is already closedjava.nio.ByteBuffer[] readByteBufferByDelimiter(java.lang.String delimiter, int maxLength) throws java.io.IOException, ClosedConnectionException, MaxReadSizeExceededException, java.nio.BufferUnderflowException
readByteBufferByDelimiter
in interface IConnection
delimiter
- the delimitermaxLength
- the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
MaxReadSizeExceededException
- If the max read length has been exceeded and the delimiter hasn’t been found * @throws ClosedConnectionException If the underlying socket is already closed
java.io.IOException
- If some other I/O error occurs
java.nio.BufferUnderflowException
- if the delimiter has not been found
ClosedConnectionException
- If the underlying socket is already closedjava.nio.ByteBuffer[] readByteBufferByLength(int length) throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException
readByteBufferByLength
in interface IConnection
length
- the amount of bytes to read
ClosedConnectionException
- If the underlying socket is already closed
java.nio.BufferUnderflowException
- if the buffer`s limit has been reached
java.io.IOException
- If some other I/O error occursbyte[] readBytesByDelimiter(java.lang.String delimiter) throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException
readBytesByDelimiter(String, int)
method is generally preferable
readBytesByDelimiter
in interface IConnection
delimiter
- the delimiter
ClosedConnectionException
- If the underlying socket is already closed
java.nio.BufferUnderflowException
- if the delimiter has not been found
java.io.IOException
- If some other I/O error occursbyte[] readBytesByDelimiter(java.lang.String delimiter, int maxLength) throws java.io.IOException, ClosedConnectionException, MaxReadSizeExceededException, java.nio.BufferUnderflowException
readBytesByDelimiter
in interface IConnection
readBytesByDelimiter
in interface IDataSource
delimiter
- the delimitermaxLength
- the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
MaxReadSizeExceededException
- If the max read length has been exceeded and the delimiter hasn’t been found * @throws ClosedConnectionException If the underlying socket is already closed
java.nio.BufferUnderflowException
- if the delimiter has not been found
java.io.IOException
- If some other I/O error occurs
ClosedConnectionException
- If the underlying socket is already closedbyte[] readBytesByLength(int length) throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException
readBytesByLength
in interface IConnection
readBytesByLength
in interface IDataSource
length
- the amount of bytes to read
ClosedConnectionException
- If the underlying socket is already closed
java.nio.BufferUnderflowException
- if the buffer`s limit has been reached
java.io.IOException
- If some other I/O error occursjava.lang.String readStringByDelimiter(java.lang.String delimiter) throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException, java.io.UnsupportedEncodingException
readStringByDelimiter(String, int)
method is generally preferable
readStringByDelimiter
in interface IConnection
readStringByDelimiter
in interface IDataSource
delimiter
- the delimiter
ClosedConnectionException
- If the underlying socket is already closed
java.io.IOException
- If some other I/O error occurs
java.nio.BufferUnderflowException
- if the delimiter has not been found
java.io.UnsupportedEncodingException
- if the default encoding is not supportedjava.lang.String readStringByDelimiter(java.lang.String delimiter, int maxLength) throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException, java.io.UnsupportedEncodingException, MaxReadSizeExceededException
readStringByDelimiter
in interface IConnection
readStringByDelimiter
in interface IDataSource
delimiter
- the delimitermaxLength
- the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
MaxReadSizeExceededException
- If the max read length has been exceeded and the delimiter hasn’t been found
ClosedConnectionException
- If the underlying socket is already closed
java.io.IOException
- If some other I/O error occurs
java.nio.BufferUnderflowException
- if the delimiter has not been found
java.io.UnsupportedEncodingException
- if the default encoding is not supportedjava.lang.String readStringByLength(int length) throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException, java.io.UnsupportedEncodingException
readStringByLength
in interface IConnection
readStringByLength
in interface IDataSource
length
- the amount of bytes to read
ClosedConnectionException
- If the underlying socket is already closed
java.nio.BufferUnderflowException
- if the buffer`s limit has been reached
java.io.IOException
- If some other I/O error occurs
java.io.UnsupportedEncodingException
- if the given encoding is not supportedjava.lang.String readStringByDelimiter(java.lang.String delimiter, java.lang.String encoding) throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException, java.io.UnsupportedEncodingException
readStringByDelimiter(String, String, int)
method is generally preferable
readStringByDelimiter
in interface IConnection
delimiter
- the delimiterencoding
- the encodin to use
java.io.IOException
- If some other I/O error occurs
java.nio.BufferUnderflowException
- if the buffer`s limit has been reached
java.io.UnsupportedEncodingException
- If the given encoding is not supported
ClosedConnectionException
- If the underlying socket is already closedjava.lang.String readStringByDelimiter(java.lang.String delimiter, java.lang.String encoding, int maxLength) throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException, java.io.UnsupportedEncodingException, MaxReadSizeExceededException
readStringByDelimiter
in interface IConnection
readStringByDelimiter
in interface IDataSource
delimiter
- the delimiterencoding
- the encodin to usemaxLength
- the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
MaxReadSizeExceededException
- If the max read length has been exceeded and the delimiter hasn’t been found * @throws ClosedConnectionException If the underlying socket is already closed
java.io.IOException
- If some other I/O error occurs
java.nio.BufferUnderflowException
- if the buffer`s limit has been reached
java.io.UnsupportedEncodingException
- If the given encoding is not supported
ClosedConnectionException
- If the underlying socket is already closedjava.lang.String readStringByLength(int length, java.lang.String encoding) throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException, java.io.UnsupportedEncodingException
readStringByLength
in interface IConnection
readStringByLength
in interface IDataSource
length
- the amount of bytes to readencoding
- the encodin to use
ClosedConnectionException
- If the underlying socket is already closed
java.nio.BufferUnderflowException
- if the buffer`s limit has been reached
java.io.IOException
- If some other I/O error occurs
java.io.UnsupportedEncodingException
- if the given encoding is not supportedint readInt() throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException
readInt
in interface IConnection
readInt
in interface IDataSource
ClosedConnectionException
- If the underlying socket is already closed
java.nio.BufferUnderflowException
- if the buffer`s limit has been reached
java.io.IOException
- If some other I/O error occurslong readLong() throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException
readLong
in interface IConnection
readLong
in interface IDataSource
ClosedConnectionException
- If the underlying socket is already closed
java.nio.BufferUnderflowException
- if the buffer`s limit has been reached
java.io.IOException
- If some other I/O error occursdouble readDouble() throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException
readDouble
in interface IConnection
readDouble
in interface IDataSource
ClosedConnectionException
- If the underlying socket is already closed
java.nio.BufferUnderflowException
- if the buffer`s limit has been reached
java.io.IOException
- If some other I/O error occursbyte readByte() throws java.io.IOException, ClosedConnectionException, java.nio.BufferUnderflowException
readByte
in interface IConnection
readByte
in interface IDataSource
ClosedConnectionException
- If the underlying socket is already closed
java.nio.BufferUnderflowException
- if the buffer`s limit has been reached
java.io.IOException
- If some other I/O error occursvoid setWriteTransferRate(int bytesPerSecond) throws ClosedConnectionException, java.io.IOException
setFlushmode(org.xsocket.stream.IConnection.FlushMode)
bytesPerSecond
- the transfer rate of the outgoing data
ClosedConnectionException
- If the underlying socket is already closed
java.io.IOException
- If some other I/O error occursvoid flush() throws ClosedConnectionException, java.io.IOException
flush
in interface java.io.Flushable
flush
in interface IConnection
java.io.IOException
- If some other I/O error occurs
ClosedConnectionException
- if the underlying channel is closedint write(java.nio.ByteBuffer buffer) throws ClosedConnectionException, java.io.IOException
IConnection.INITIAL_AUTOFLUSH
) and flushmode SYNC
(for default see INITIAL_FLUSH_MODE
the behaviour is
according to the WritableByteChannel
specification.
write
in interface IConnection
write
in interface IDataSink
write
in interface java.nio.channels.WritableByteChannel
buffer
- the bytes to send
java.io.IOException
- If some other I/O error occurs
ClosedConnectionException
- if the underlying channel is closedIConnection.setAutoflush(boolean)
,
setFlushmode(org.xsocket.stream.IConnection.FlushMode)
long write(java.nio.ByteBuffer[] buffers) throws ClosedConnectionException, java.io.IOException
IConnection.INITIAL_AUTOFLUSH
) and flushmode SYNC
(for default see INITIAL_FLUSH_MODE
the behaviour is
according to the WritableByteChannel
specification.
write
in interface java.nio.channels.GatheringByteChannel
write
in interface IConnection
write
in interface IDataSink
buffers
- the bytes to send
java.io.IOException
- If some other I/O error occurs
ClosedConnectionException
- if the underlying channel is closedIConnection.setAutoflush(boolean)
,
setFlushmode(org.xsocket.stream.IConnection.FlushMode)
void setFlushmode(IConnection.FlushMode flushMode)
IConnection.write(ByteBuffer)
or IConnection.write(ByteBuffer[])
method will be used, the flushmode
FlushMode#ASYNC
could have side-effects. Because the buffer will be
written asynchronous, it could occur, that the passed-over buffers are not already
written by returning from the write call.
flushMode
- FlushMode#ASYNC
if flush should be performed asynchronous,
FlushMode#SYNC
if flush should be perform synchronousIConnection.FlushMode getFlushmode()
INonBlockingConnection setOption(java.lang.String name, java.lang.Object value) throws java.io.IOException
setOption
in interface IConnection
name
- the name of the optionvalue
- the value of the option
java.io.IOException
- In an I/O error occurs
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |