| org.xsocket.connection.INonBlockingConnection
All known Subclasses: org.xsocket.connection.NonBlockingConnection,
Field Summary | |
final public static int | UNLIMITED |
Method Summary | |
public void | activateSecuredMode() ad hoc activation of a secured mode (SSL). | public int | available() | public void | flush() flush the send buffer. | public String | getEncoding() | public FlushMode | getFlushmode() | public int | getPendingWriteDataSize() returns the size of the data which have already been written, but not
yet transferred to the underlying socket. | public int | getReadBufferVersion() get the version of read buffer. | public Executor | getWorkerpool() | public int | indexOf(String str) Returns the index of the first occurrence of the given string. | public int | indexOf(String str, String encoding) Returns the index of the first occurrence of the given string. | public boolean | isAutoflush() | public boolean | isOpen() return if the data source is open. | public void | markReadPosition() Marks the read position in the connection. | public void | markWritePosition() Marks the write position in the connection. | public ByteBuffer[] | readByteBufferByDelimiter(String delimiter, String encoding) read a ByteBuffer by using a delimiter. | public ByteBuffer[] | readByteBufferByDelimiter(String delimiter, String encoding, int maxLength) read a ByteBuffer by using a delimiter
For performance reasons, the ByteBuffer readByteBuffer method is
generally preferable to get bytes
Parameters: delimiter - the delimiter Parameters: encoding - the encoding of the delimiter Parameters: maxLength - the max length of bytes that should be read. | public byte[] | readBytesByDelimiter(String delimiter, String encoding) | public byte[] | readBytesByDelimiter(String delimiter, String encoding, int maxLength) read a byte array by using a delimiter
For performance reasons, the ByteBuffer readByteBuffer method is
generally preferable to get bytes
Parameters: delimiter - the delimiter Parameters: encoding - the encoding to use Parameters: maxLength - the max length of bytes that should be read. | public String | readStringByDelimiter(String delimiter, String encoding) | public String | readStringByDelimiter(String delimiter, String encoding, int maxLength) read a string by using a delimiter
Parameters: delimiter - the delimiter Parameters: encoding - the encoding to use Parameters: maxLength - the max length of bytes that should be read. | public String | readStringByLength(int length, String encoding) read a string by using a length definition
Parameters: length - the amount of bytes to read. | public void | removeReadMark() | public void | removeWriteMark() | public boolean | resetToReadMark() Resets to the marked read position. | public boolean | resetToWriteMark() Resets to the marked write position. | public void | resumeRead() | public void | setAutoflush(boolean autoflush) set autoflush. | public void | setEncoding(String encoding) | public void | setFlushmode(FlushMode flushMode) set the flush mode
By setting the flush mode with ASYNC (default is SYNC)
the data will be transferred to the underlying connection in a asynchronous way.
In most cases there are high performance improvements. | public void | setHandler(IHandler handler) | public void | setWriteTransferRate(int bytesPerSecond) set the send delay time. | public void | suspendRead() | public long | transferFrom(FileChannel source) | public int | write(String message, String encoding) write a message
Parameters: message - the message to write Parameters: encoding - the encoding which should be used th encode the chars into byte (e.g. |
UNLIMITED | final public static int UNLIMITED(Code) | | |
activateSecuredMode | public void activateSecuredMode() throws IOException(Code) | | ad hoc activation of a secured mode (SSL). By performing of this
method all remaining data to send will be flushed.
After this all data will be sent and received in the secured mode
throws: IOException - If some other I/O error occurs |
available | public int available() throws IOException(Code) | | get the number of available bytes to read
the number of available bytes, possibly zero, or -1 if the channel has reached end-of-stream |
flush | public void flush() throws ClosedChannelException, IOException, SocketTimeoutException(Code) | | flush the send buffer. The method call will block until
the outgoing data has been flushed into the underlying
os-specific send buffer.
throws: IOException - If some other I/O error occurs throws: SocketTimeoutException - If the timeout has been reached throws: ClosedChannelException - if the underlying channel is closed |
getEncoding | public String getEncoding()(Code) | | gets the encoding (used by string related methods like write(String) ...)
the encoding |
getFlushmode | public FlushMode getFlushmode()(Code) | | return the flush mode
the flush mode |
getPendingWriteDataSize | public int getPendingWriteDataSize()(Code) | | returns the size of the data which have already been written, but not
yet transferred to the underlying socket.
the size of the pending data to write |
getReadBufferVersion | public int getReadBufferVersion() throws IOException(Code) | | get the version of read buffer. The version number increases, if
the read buffer queue has been modified
the version of the read buffer throws: IOException - If some other I/O error occurs |
getWorkerpool | public Executor getWorkerpool()(Code) | | return the worker pool which is used to process the call back methods
the worker pool |
indexOf | public int indexOf(String str) throws IOException(Code) | | Returns the index of the first occurrence of the given string.
Parameters: str - any string if the string argument occurs as a substring within this object, thenthe index of the first character of the first such substring is returned;if it does not occur as a substring, -1 is returned. throws: IOException - If some other I/O error occurs |
indexOf | public int indexOf(String str, String encoding) throws IOException(Code) | | Returns the index of the first occurrence of the given string.
Parameters: str - any string Parameters: encoding - the encoding to use if the string argument occurs as a substring within this object, thenthe index of the first character of the first such substring is returned;if it does not occur as a substring, -1 is returned. throws: IOException - If some other I/O error occurs throws: MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found |
isAutoflush | public boolean isAutoflush()(Code) | | get autoflush
true, if autoflush is activated |
isOpen | public boolean isOpen()(Code) | | return if the data source is open. Default is true
true, if the data source is open |
markReadPosition | public void markReadPosition()(Code) | | Marks the read position in the connection. Subsequent calls to resetToReadMark() will attempt
to reposition the connection to this point.
|
markWritePosition | public void markWritePosition()(Code) | | Marks the write position in the connection.
|
readByteBufferByDelimiter | public ByteBuffer[] readByteBufferByDelimiter(String delimiter, String encoding) throws IOException, BufferUnderflowException(Code) | | read a ByteBuffer by using a delimiter. The default encoding will be used to decode the delimiter
For performance reasons, the ByteBuffer readByteBuffer method is
generally preferable to get bytes
Parameters: delimiter - the delimiter Parameters: encoding - the encoding to use the ByteBuffer throws: BufferUnderflowException - If not enough data is available throws: IOException - If some other I/O error occurs |
readByteBufferByDelimiter | public ByteBuffer[] readByteBufferByDelimiter(String delimiter, String encoding, int maxLength) throws IOException, BufferUnderflowException, MaxReadSizeExceededException(Code) | | read a ByteBuffer by using a delimiter
For performance reasons, the ByteBuffer readByteBuffer method is
generally preferable to get bytes
Parameters: delimiter - the delimiter Parameters: encoding - the encoding of the delimiter Parameters: maxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown the ByteBuffer throws: BufferUnderflowException - If not enough data is available throws: MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found throws: IOException - If some other I/O error occurs |
readBytesByDelimiter | public byte[] readBytesByDelimiter(String delimiter, String encoding) throws IOException, BufferUnderflowException(Code) | | read a byte array by using a delimiter
For performance reasons, the ByteBuffer readByteBuffer method is
generally preferable to get bytes
Parameters: delimiter - the delimiter Parameters: encoding - the encoding to use the read bytes throws: BufferUnderflowException - If not enough data is available throws: IOException - If some other I/O error occurs |
readBytesByDelimiter | public byte[] readBytesByDelimiter(String delimiter, String encoding, int maxLength) throws IOException, BufferUnderflowException, MaxReadSizeExceededException(Code) | | read a byte array by using a delimiter
For performance reasons, the ByteBuffer readByteBuffer method is
generally preferable to get bytes
Parameters: delimiter - the delimiter Parameters: encoding - the encoding to use Parameters: maxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown the read bytes throws: BufferUnderflowException - If not enough data is available throws: MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found throws: IOException - If some other I/O error occurs |
readStringByDelimiter | public String readStringByDelimiter(String delimiter, String encoding, int maxLength) throws IOException, BufferUnderflowException, UnsupportedEncodingException, MaxReadSizeExceededException(Code) | | read a string by using a delimiter
Parameters: delimiter - the delimiter Parameters: encoding - the encoding to use Parameters: maxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown the string throws: BufferUnderflowException - If not enough data is available throws: MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found throws: IOException - If some other I/O error occurs throws: UnsupportedEncodingException - If the given encoding is not supported |
removeReadMark | public void removeReadMark()(Code) | | remove the read mark
|
removeWriteMark | public void removeWriteMark()(Code) | | remove the write mark
|
resetToReadMark | public boolean resetToReadMark()(Code) | | Resets to the marked read position. If the connection has been marked,
then attempt to reposition it at the mark.
true, if reset was successful |
resetToWriteMark | public boolean resetToWriteMark()(Code) | | Resets to the marked write position. If the connection has been marked,
then attempt to reposition it at the mark.
true, if reset was successful |
resumeRead | public void resumeRead() throws IOException(Code) | | resume reading data from the underlying subsystem
throws: IOException - If some other I/O error occurs |
setAutoflush | public void setAutoflush(boolean autoflush)(Code) | | set autoflush. If autoflush is activated, each write call
will cause a flush.
By default the autoflush is deactivated
Parameters: autoflush - true if autoflush should be activated |
setEncoding | public void setEncoding(String encoding)(Code) | | sets the encoding (used by string related methods like write(String) ...)
Parameters: encoding - the encoding |
setFlushmode | public void setFlushmode(FlushMode flushMode)(Code) | | set the flush mode
By setting the flush mode with ASYNC (default is SYNC)
the data will be transferred to the underlying connection in a asynchronous way.
In most cases there are high performance improvements. If the
IReadWriteableConnection.write(ByteBuffer) or
IReadWriteableConnection.write(ByteBuffer[]) method will be used, the flush mode
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.
Parameters: flushMode - FlushMode.ASYNC if flush should be performed asynchronous,FlushMode.SYNC if flush should be perform synchronous |
setHandler | public void setHandler(IHandler handler) throws IOException(Code) | | set the connection handler
Parameters: handler - the handler throws: IOException - If some other I/O error occurs |
setWriteTransferRate | public void setWriteTransferRate(int bytesPerSecond) throws ClosedChannelException, IOException(Code) | | set the send delay time. WData to write will be buffered
internally and be written to the underlying subsystem
based on the given write rate.
The write methods will not block for this time.
By default the write transfer rate is set with UNLIMITED
Reduced write transfer is only supported for FlushMode.ASYNC. see
INonBlockingConnection#setFlushmode(org.xsocket.connection.IConnection.FlushMode)) Parameters: bytesPerSecond - the transfer rate of the outgoing data throws: ClosedChannelException - If the underlying socket is already closed throws: IOException - If some other I/O error occurs |
suspendRead | public void suspendRead() throws IOException(Code) | | suspend reading data from the underlying subsystem
throws: IOException - If some other I/O error occurs |
transferFrom | public long transferFrom(FileChannel source) throws IOException, BufferOverflowException(Code) | | transfer the data of the file channel to this data sink
Parameters: source - the source channel the number of transfered bytes throws: BufferOverflowException - If the no enough space is available throws: IOException - If some other I/O error occurs |
write | public int write(String message, String encoding) throws IOException, BufferOverflowException(Code) | | write a message
Parameters: message - the message to write Parameters: encoding - the encoding which should be used th encode the chars into byte (e.g. `US-ASCII` or `UTF-8`) the number of written bytes throws: BufferOverflowException - If the no enough space is available throws: IOException - If some other I/O error occurs |
|
|