| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

java.lang.Objectorg.xsocket.stream.NonBlockingConnection
public final class NonBlockingConnection
Implementation of the INonBlockingConnection interface. 
 A newly created connection is in the open state. Write or rad methods can be called immediately
 The methods of this class are not thread-safe.
| Nested Class Summary | 
|---|
| Nested classes/interfaces inherited from interface org.xsocket.stream.INonBlockingConnection | 
|---|
INonBlockingConnection.TransferResult | 
| Nested classes/interfaces inherited from interface org.xsocket.stream.IConnection | 
|---|
IConnection.FlushMode | 
| Field Summary | 
|---|
| Fields inherited from interface org.xsocket.stream.INonBlockingConnection | 
|---|
INITIAL_FLUSH_MODE, 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 | 
| Constructor Summary | |
|---|---|
NonBlockingConnection(java.net.InetAddress address,
                      int port)
constructor.  | 
|
NonBlockingConnection(java.net.InetAddress address,
                      int port,
                      IHandler appHandler)
constructor.  | 
|
NonBlockingConnection(java.net.InetAddress address,
                      int port,
                      IHandler appHandler,
                      java.util.concurrent.Executor workerPool)
constructor.  | 
|
NonBlockingConnection(java.net.InetAddress address,
                      int port,
                      IHandler appHandler,
                      java.util.concurrent.Executor workerPool,
                      int preallocationMemorySize)
Deprecated.  | 
|
NonBlockingConnection(java.net.InetAddress address,
                      int port,
                      java.util.Map<java.lang.String,java.lang.Object> options)
constructor.  | 
|
NonBlockingConnection(java.net.InetAddress address,
                      int port,
                      java.util.Map<java.lang.String,java.lang.Object> options,
                      IHandler appHandler)
constructor.  | 
|
NonBlockingConnection(java.net.InetAddress address,
                      int port,
                      java.util.Map<java.lang.String,java.lang.Object> options,
                      javax.net.ssl.SSLContext sslContext,
                      boolean sslOn)
constructor.  | 
|
NonBlockingConnection(java.net.InetAddress address,
                      int port,
                      javax.net.ssl.SSLContext sslContext,
                      boolean sslOn)
constructor.  | 
|
NonBlockingConnection(java.net.InetAddress address,
                      int port,
                      StreamSocketConfiguration socketConfiguration)
Deprecated.  | 
|
NonBlockingConnection(java.net.InetAddress address,
                      int port,
                      StreamSocketConfiguration socketConfiguration,
                      IHandler appHandler)
Deprecated.  | 
|
NonBlockingConnection(java.net.InetAddress address,
                      int port,
                      StreamSocketConfiguration socketConfiguration,
                      IHandler appHandler,
                      int preallocationMemorySize)
Deprecated.  | 
|
NonBlockingConnection(java.net.InetAddress address,
                      int port,
                      StreamSocketConfiguration socketConfiguration,
                      javax.net.ssl.SSLContext sslContext,
                      boolean sslOn)
Deprecated.  | 
|
NonBlockingConnection(java.lang.String hostname,
                      int port)
constructor.  | 
|
NonBlockingConnection(java.lang.String hostname,
                      int port,
                      IHandler appHandler)
constructor constructor.  | 
|
NonBlockingConnection(java.lang.String hostname,
                      int port,
                      java.util.Map<java.lang.String,java.lang.Object> options,
                      IHandler appHandler)
constructor constructor.  | 
|
NonBlockingConnection(java.lang.String hostname,
                      int port,
                      java.util.Map<java.lang.String,java.lang.Object> options,
                      javax.net.ssl.SSLContext sslContext,
                      boolean sslOn)
constructor.  | 
|
NonBlockingConnection(java.lang.String hostname,
                      int port,
                      javax.net.ssl.SSLContext sslContext,
                      boolean sslOn)
constructor.  | 
|
NonBlockingConnection(java.lang.String hostname,
                      int port,
                      StreamSocketConfiguration socketConfiguration)
Deprecated.  | 
|
NonBlockingConnection(java.lang.String hostname,
                      int port,
                      StreamSocketConfiguration socketConfiguration,
                      IHandler appHandler)
 | 
|
NonBlockingConnection(java.lang.String hostname,
                      int port,
                      StreamSocketConfiguration socketConfiguration,
                      IHandler appHandler,
                      int preallocationMemorySize)
 | 
|
NonBlockingConnection(java.lang.String hostname,
                      int port,
                      StreamSocketConfiguration socketConfiguration,
                      javax.net.ssl.SSLContext sslContext,
                      boolean sslOn)
Deprecated.  | 
|
| Method Summary | |
|---|---|
 void | 
activateSecuredMode()
ad hoc activation of a secured mode (SSL).  | 
 java.lang.Object | 
attach(java.lang.Object obj)
 | 
 java.lang.Object | 
attachment()
 | 
 void | 
close()
 | 
 void | 
flush()
flush the send buffer.  | 
 java.lang.Object | 
getAttachment()
Retrieves the current attachment.  | 
 boolean | 
getAutoflush()
get autoflush  | 
 int | 
getConnectionTimeoutSec()
gets the connection timeout  | 
 java.lang.String | 
getDefaultEncoding()
gets the default encoding for this connection (used by string related methods like readString...)  | 
 IConnection.FlushMode | 
getFlushmode()
get the flushmode  | 
 java.lang.String | 
getId()
returns the id  | 
 int | 
getIdleTimeoutSec()
returns the idle timeout in sec.  | 
 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 | 
getIndexOf(java.lang.String str,
           java.lang.String encoding,
           int maxLength)
Returns the index of the first occurrence of the given string.  | 
 java.net.InetAddress | 
getLocalAddress()
returns the local address  | 
 int | 
getLocalPort()
returns the local port  | 
 int | 
getNumberOfAvailableBytes()
get the number of available bytes to read  | 
 java.lang.Object | 
getOption(java.lang.String name)
returns the value of a option  | 
 java.util.Map<java.lang.String,java.lang.Class> | 
getOptions()
Returns an unmodifiable map of the options supported by this endpoint.  | 
 int | 
getPendingWriteDataSize()
returns the size of the data which have already been written, but not yet transferred to the underlying socket.  | 
 java.net.InetAddress | 
getRemoteAddress()
returns the remote address  | 
 int | 
getRemotePort()
returns the port of the remote endpoint  | 
 int | 
indexOf(java.lang.String str)
Deprecated. uses getIndexOf instead  | 
 boolean | 
isOpen()
returns, if the connection is open.  | 
 void | 
markReadPosition()
Marks the present read position in the connection.  | 
 void | 
markWritePosition()
Marks the present write position in the connection.  | 
 void | 
onWriteException(java.io.IOException ioException)
 | 
 void | 
onWritten()
 | 
 int | 
read(java.nio.ByteBuffer buffer)
 | 
 java.nio.ByteBuffer[] | 
readAvailable()
read all received bytes  | 
 boolean | 
readAvailableByDelimiter(java.lang.String delimiter,
                         java.lang.String encoding,
                         java.nio.channels.WritableByteChannel outputChannel)
 | 
 boolean | 
readAvailableByDelimiter(java.lang.String delimiter,
                         java.nio.channels.WritableByteChannel outputChannel)
 | 
 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 INonBlockingConnection.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[] | 
readByteBufferByDelimiter(java.lang.String delimiter,
                          java.lang.String encoding,
                          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 INonBlockingConnection.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[] | 
readBytesByDelimiter(java.lang.String delimiter,
                     java.lang.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  | 
 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  | 
 short | 
readShort()
read a short value  | 
 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 INonBlockingConnection.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 INonBlockingConnection.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 | 
removeReadMark()
remove the mark the present read position in the connection.  | 
 void | 
removeWriteMark()
remove the mark the present write position in the connection.  | 
 boolean | 
resetToReadMark()
Resets to the marked read position.  | 
 boolean | 
resetToWriteMark()
Resets to the marked write position.  | 
 void | 
resumeRead()
resume reading data from the underlying subsystem  | 
 void | 
setAttachment(java.lang.Object obj)
Attaches the given object to this connection  | 
 void | 
setAutoflush(boolean autoflush)
set autoflush.  | 
 void | 
setConnectionTimeoutSec(int timeoutSec)
sets the max time for a connections.  | 
 void | 
setDefaultEncoding(java.lang.String defaultEncoding)
sets the default encoding for this connection (used by string related methods like readString...)  | 
 void | 
setFlushmode(IConnection.FlushMode flushMode)
set the flushmode  | 
 void | 
setIdleTimeoutSec(int timeoutInSec)
sets the idle timeout in sec  | 
 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.  | 
 void | 
suspendRead()
suspend reading data from the underlying subsystem  | 
 java.lang.String | 
toString()
 | 
 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(byte... bytes)
sends bytes to the remote endpoint  | 
 int | 
write(byte b)
sends a byte to the remote endpoint  | 
 int | 
write(byte[] bytes,
      int offset,
      int length)
sends bytes to the remote endpoint  | 
 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.  | 
 long | 
write(java.nio.ByteBuffer[] srcs,
      int offset,
      int length)
 | 
 int | 
write(double d)
sends a double to the remote endpoint  | 
 int | 
write(int i)
sends an int to the remote endpoint  | 
 int | 
write(long l)
sends a long to the remote endpoint  | 
 int | 
write(short s)
writes a short to the data sink  | 
 int | 
write(java.lang.String s)
sends a message to the remote endpoint by using the connection default encoding  | 
 int | 
write(java.lang.String s,
      java.lang.String encoding)
sends a message to the remote endpoint  | 
| Methods inherited from class java.lang.Object | 
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Methods inherited from interface org.xsocket.stream.INonBlockingConnection | 
|---|
flush, getFlushmode, indexOf, setFlushmode, write, write | 
| Methods inherited from interface org.xsocket.stream.IConnection | 
|---|
activateSecuredMode, attach, attachment, getAttachment, getAutoflush, getConnectionTimeoutSec, getDefaultEncoding, getId, getIdleTimeoutSec, getLocalAddress, getLocalPort, getOption, getOptions, getPendingWriteDataSize, getRemoteAddress, getRemotePort, isOpen, markReadPosition, markWritePosition, 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.IDataSink | 
|---|
write | 
| Methods inherited from interface java.nio.channels.GatheringByteChannel | 
|---|
write | 
| Methods inherited from interface java.nio.channels.Channel | 
|---|
close | 
| Constructor Detail | 
|---|
public NonBlockingConnection(java.lang.String hostname,
                             int port)
                      throws java.io.IOException
NonBlockingConnection(InetAddress, int, IHandler, Executor).
hostname - the remote hostport - the port of the remote host to connect
java.io.IOException - If some other I/O error occurs
public NonBlockingConnection(java.lang.String hostname,
                             int port,
                             StreamSocketConfiguration socketConfiguration)
                      throws java.io.IOException
java.io.IOException
public NonBlockingConnection(java.net.InetAddress address,
                             int port)
                      throws java.io.IOException
NonBlockingConnection(InetAddress, int, IHandler, Executor).
address - the remote hostport - the port of the remote host to connect
java.io.IOException - If some other I/O error occurs
public NonBlockingConnection(java.net.InetAddress address,
                             int port,
                             StreamSocketConfiguration socketConfiguration)
                      throws java.io.IOException
java.io.IOException
public NonBlockingConnection(java.net.InetAddress address,
                             int port,
                             java.util.Map<java.lang.String,java.lang.Object> options)
                      throws java.io.IOException
NonBlockingConnection(InetAddress, int, IHandler, Executor).
address - the remote hostport - the port of the remote host to connectoptions - the socket options
java.io.IOException - If some other I/O error occurs
public NonBlockingConnection(java.net.InetAddress address,
                             int port,
                             IHandler appHandler)
                      throws java.io.IOException
NonBlockingConnection(InetAddress, int, IHandler, Executor).
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler and ITimeoutHandler)
java.io.IOException - If some other I/O error occurs
public NonBlockingConnection(java.net.InetAddress address,
                             int port,
                             StreamSocketConfiguration socketConfiguration,
                             IHandler appHandler)
                      throws java.io.IOException
java.io.IOException
public NonBlockingConnection(java.net.InetAddress address,
                             int port,
                             StreamSocketConfiguration socketConfiguration,
                             IHandler appHandler,
                             int preallocationMemorySize)
                      throws java.io.IOException
java.io.IOException
public NonBlockingConnection(java.net.InetAddress address,
                             int port,
                             java.util.Map<java.lang.String,java.lang.Object> options,
                             IHandler appHandler)
                      throws java.io.IOException
NonBlockingConnection(InetAddress, int, IHandler, Executor).
address - the remote addressport - the remote portoptions - the socket optionsappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler and ITimeoutHandler)
java.io.IOException - If some other I/O error occurs
public NonBlockingConnection(java.lang.String hostname,
                             int port,
                             IHandler appHandler)
                      throws java.io.IOException
NonBlockingConnection(InetAddress, int, IHandler, Executor).
hostname - the remote hostport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler and ITimeoutHandler)
java.io.IOException - If some other I/O error occurs
public NonBlockingConnection(java.lang.String hostname,
                             int port,
                             StreamSocketConfiguration socketConfiguration,
                             IHandler appHandler)
                      throws java.io.IOException
java.io.IOException
public NonBlockingConnection(java.lang.String hostname,
                             int port,
                             StreamSocketConfiguration socketConfiguration,
                             IHandler appHandler,
                             int preallocationMemorySize)
                      throws java.io.IOException
java.io.IOException
public NonBlockingConnection(java.lang.String hostname,
                             int port,
                             java.util.Map<java.lang.String,java.lang.Object> options,
                             IHandler appHandler)
                      throws java.io.IOException
NonBlockingConnection(InetAddress, int, IHandler, Executor).
hostname - the remote hostport - the remote portoptions - the socket optionsappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler and ITimeoutHandler)
java.io.IOException - If some other I/O error occurs
public NonBlockingConnection(java.net.InetAddress address,
                             int port,
                             javax.net.ssl.SSLContext sslContext,
                             boolean sslOn)
                      throws java.io.IOException
NonBlockingConnection(InetAddress, int, IHandler, Executor).
address - the remote addressport - the remote portsslContext - the ssl context to usesslOn - true, activate SSL mode. false, ssl can be activated by user (see IConnection.activateSecuredMode())
java.io.IOException - If some other I/O error occurs
public NonBlockingConnection(java.net.InetAddress address,
                             int port,
                             StreamSocketConfiguration socketConfiguration,
                             javax.net.ssl.SSLContext sslContext,
                             boolean sslOn)
                      throws java.io.IOException
java.io.IOException
public NonBlockingConnection(java.net.InetAddress address,
                             int port,
                             java.util.Map<java.lang.String,java.lang.Object> options,
                             javax.net.ssl.SSLContext sslContext,
                             boolean sslOn)
                      throws java.io.IOException
NonBlockingConnection(InetAddress, int, IHandler, Executor).
address - the remote addressport - the remote portoptions - the socket optionssslContext - the ssl context to usesslOn - true, activate SSL mode. false, ssl can be activated by user (see IConnection.activateSecuredMode())
java.io.IOException - If some other I/O error occurs
public NonBlockingConnection(java.lang.String hostname,
                             int port,
                             javax.net.ssl.SSLContext sslContext,
                             boolean sslOn)
                      throws java.io.IOException
NonBlockingConnection(InetAddress, int, IHandler, Executor).
hostname - the remote hostport - the remote portsslContext - the ssl context to usesslOn - true, activate SSL mode. false, ssl can be activated by user (see IConnection.activateSecuredMode())
java.io.IOException - If some other I/O error occurs
public NonBlockingConnection(java.lang.String hostname,
                             int port,
                             StreamSocketConfiguration socketConfiguration,
                             javax.net.ssl.SSLContext sslContext,
                             boolean sslOn)
                      throws java.io.IOException
java.io.IOException
public NonBlockingConnection(java.lang.String hostname,
                             int port,
                             java.util.Map<java.lang.String,java.lang.Object> options,
                             javax.net.ssl.SSLContext sslContext,
                             boolean sslOn)
                      throws java.io.IOException
NonBlockingConnection(InetAddress, int, IHandler, Executor).
hostname - the remote hostport - the remote portoptions - the socket optionssslContext - the ssl context to usesslOn - true, activate SSL mode. false, ssl can be activated by user (see IConnection.activateSecuredMode())
java.io.IOException - If some other I/O error occurs
public NonBlockingConnection(java.net.InetAddress address,
                             int port,
                             IHandler appHandler,
                             java.util.concurrent.Executor workerPool)
                      throws java.io.IOException
Executors.newCachedThreadPool() will be used. null, the multithreading is "switched off". This means the call back methods will
 be executed by the central dispatcher thread. The workerPool can also be shared with a server, which runs in the same process. E.g.
 ... // create a new server instance (a associated WorkerPool will be created automatically) IMultithreadedServer server = new MultithreadedServer(new TestHandler()); StreamUtils.start(server); ... INonBlockingConnection connection = new NonBlockingConnection(host, port, clientHandler, server.getWorkerpool()); ...
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler and ITimeoutHandler)workerPool - the worker pool to use or java.io.IOException - If some other I/O error occurs
public NonBlockingConnection(java.net.InetAddress address,
                             int port,
                             IHandler appHandler,
                             java.util.concurrent.Executor workerPool,
                             int preallocationMemorySize)
                      throws java.io.IOException
java.io.IOException| Method Detail | 
|---|
public void setWriteTransferRate(int bytesPerSecond)
                          throws ClosedConnectionException,
                                 java.io.IOException
INonBlockingConnection.setFlushmode(org.xsocket.stream.IConnection.FlushMode)
setWriteTransferRate in interface INonBlockingConnectionbytesPerSecond - the transfer rate of the outgoing data
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurspublic int getNumberOfAvailableBytes()
getNumberOfAvailableBytes in interface INonBlockingConnection
public java.nio.ByteBuffer[] readAvailable()
                                    throws java.io.IOException,
                                           ClosedConnectionException
readAvailable in interface INonBlockingConnectionClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
public boolean readAvailableByDelimiter(java.lang.String delimiter,
                                        java.nio.channels.WritableByteChannel outputChannel)
                                 throws java.io.IOException,
                                        ClosedConnectionException
readAvailableByDelimiter in interface INonBlockingConnectionjava.io.IOException
ClosedConnectionException
public boolean readAvailableByDelimiter(java.lang.String delimiter,
                                        java.lang.String encoding,
                                        java.nio.channels.WritableByteChannel outputChannel)
                                 throws java.io.IOException,
                                        ClosedConnectionException
readAvailableByDelimiter in interface INonBlockingConnectionjava.io.IOException
ClosedConnectionException
public final INonBlockingConnection.TransferResult transferToAvailableByDelimiter(java.lang.String delimiter,
                                                                                  java.nio.channels.WritableByteChannel outputChannel)
                                                                           throws java.io.IOException,
                                                                                  ClosedConnectionException
INonBlockingConnection.TransferResult.delimiterFound is
 set with true. The INonBlockingConnection.TransferResult.written contains the The number of bytes,
 possibly zero, that were actually transferred  
transferToAvailableByDelimiter in interface INonBlockingConnectiondelimiter - 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 closed
public final INonBlockingConnection.TransferResult transferToAvailableByDelimiter(java.lang.String delimiter,
                                                                                  java.lang.String encoding,
                                                                                  java.nio.channels.WritableByteChannel outputChannel)
                                                                           throws java.io.IOException,
                                                                                  ClosedConnectionException
INonBlockingConnection.TransferResult.delimiterFound is
 set with true. The INonBlockingConnection.TransferResult.written contains the The number of bytes,
 possibly zero, that were actually transferred
transferToAvailableByDelimiter in interface INonBlockingConnectiondelimiter - 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 closed
public int read(java.nio.ByteBuffer buffer)
         throws java.io.IOException
read in interface java.nio.channels.ReadableByteChanneljava.io.IOException
public byte readByte()
              throws java.io.IOException,
                     ClosedConnectionException,
                     java.nio.BufferUnderflowException
readByte in interface IDataSourcereadByte in interface IConnectionreadByte in interface INonBlockingConnectionClosedConnectionException - 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
public java.nio.ByteBuffer[] readByteBufferByDelimiter(java.lang.String delimiter)
                                                throws java.io.IOException,
                                                       ClosedConnectionException,
                                                       java.nio.BufferUnderflowException
INonBlockingConnection.readByteBufferByDelimiter(String, int) method is generally preferable  
 
readByteBufferByDelimiter in interface IConnectionreadByteBufferByDelimiter in interface INonBlockingConnectiondelimiter - the delimiter
java.io.IOException - If some other I/O error occurs
ClosedConnectionException - If the underlying socket is already closed
java.nio.BufferUnderflowException - if the delimiter has not been found
public java.nio.ByteBuffer[] readByteBufferByDelimiter(java.lang.String delimiter,
                                                       int maxLength)
                                                throws java.io.IOException,
                                                       ClosedConnectionException,
                                                       MaxReadSizeExceededException,
                                                       java.nio.BufferUnderflowException
readByteBufferByDelimiter in interface IConnectionreadByteBufferByDelimiter in interface INonBlockingConnectiondelimiter - the delimitermaxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
java.io.IOException - If some other I/O error occurs
ClosedConnectionException - If the underlying socket is already closed
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
public java.nio.ByteBuffer[] readByteBufferByDelimiter(java.lang.String delimiter,
                                                       java.lang.String encoding,
                                                       int maxLength)
                                                throws java.io.IOException,
                                                       ClosedConnectionException,
                                                       MaxReadSizeExceededException
readByteBufferByDelimiter in interface IConnectiondelimiter - the delimiterencoding - the encoding of the delimitermaxLength - 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
public java.nio.ByteBuffer[] readByteBufferByLength(int length)
                                             throws java.io.IOException,
                                                    ClosedConnectionException,
                                                    java.nio.BufferUnderflowException
readByteBufferByLength in interface IConnectionreadByteBufferByLength in interface INonBlockingConnectionlength - the amount of bytes to read
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
public byte[] readBytesByDelimiter(java.lang.String delimiter)
                            throws java.io.IOException,
                                   ClosedConnectionException,
                                   java.nio.BufferUnderflowException
INonBlockingConnection.readBytesByDelimiter(String, int) method is generally preferable  
 
readBytesByDelimiter in interface IConnectionreadBytesByDelimiter in interface INonBlockingConnectiondelimiter - 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
public byte[] readBytesByDelimiter(java.lang.String delimiter,
                                   int maxLength)
                            throws java.io.IOException,
                                   ClosedConnectionException,
                                   MaxReadSizeExceededException,
                                   java.nio.BufferUnderflowException
readBytesByDelimiter in interface IDataSourcereadBytesByDelimiter in interface IConnectionreadBytesByDelimiter in interface INonBlockingConnectiondelimiter - the delimitermaxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
java.io.IOException - If some other I/O error occurs
ClosedConnectionException - If the underlying socket is already closed
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
public byte[] readBytesByDelimiter(java.lang.String delimiter,
                                   java.lang.String encoding,
                                   int maxLength)
                            throws java.io.IOException,
                                   ClosedConnectionException,
                                   MaxReadSizeExceededException
readBytesByDelimiter in interface IConnectiondelimiter - the delimiterencoding - the encoding of the delimitermaxLength - 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
public byte[] readBytesByLength(int length)
                         throws java.io.IOException,
                                ClosedConnectionException,
                                java.nio.BufferUnderflowException
readBytesByLength in interface IDataSourcereadBytesByLength in interface IConnectionreadBytesByLength in interface INonBlockingConnectionlength - the amount of bytes to read
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
public double readDouble()
                  throws java.io.IOException,
                         ClosedConnectionException,
                         java.nio.BufferUnderflowException
readDouble in interface IDataSourcereadDouble in interface IConnectionreadDouble in interface INonBlockingConnectionClosedConnectionException - 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
public int readInt()
            throws java.io.IOException,
                   ClosedConnectionException,
                   java.nio.BufferUnderflowException
readInt in interface IDataSourcereadInt in interface IConnectionreadInt in interface INonBlockingConnectionClosedConnectionException - 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
public short readShort()
                throws java.io.IOException,
                       ClosedConnectionException,
                       java.nio.BufferUnderflowException
readShort in interface IDataSourcejava.io.IOException - If some other I/O error occurs
ClosedConnectionException
java.nio.BufferUnderflowException
public long readLong()
              throws java.io.IOException,
                     ClosedConnectionException,
                     java.nio.BufferUnderflowException
readLong in interface IDataSourcereadLong in interface IConnectionreadLong in interface INonBlockingConnectionClosedConnectionException - 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
public java.lang.String readStringByDelimiter(java.lang.String delimiter)
                                       throws java.io.IOException,
                                              ClosedConnectionException,
                                              java.nio.BufferUnderflowException,
                                              java.io.UnsupportedEncodingException
INonBlockingConnection.readStringByDelimiter(String, int) method is generally preferable
readStringByDelimiter in interface IDataSourcereadStringByDelimiter in interface IConnectionreadStringByDelimiter in interface INonBlockingConnectiondelimiter - the delimiter
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
java.io.UnsupportedEncodingException - if the default encoding is not supported
java.nio.BufferUnderflowException - if the delimiter has not been found
public java.lang.String readStringByDelimiter(java.lang.String delimiter,
                                              int maxLength)
                                       throws java.io.IOException,
                                              ClosedConnectionException,
                                              java.nio.BufferUnderflowException,
                                              java.io.UnsupportedEncodingException,
                                              MaxReadSizeExceededException
readStringByDelimiter in interface IDataSourcereadStringByDelimiter in interface IConnectionreadStringByDelimiter in interface INonBlockingConnectiondelimiter - the delimitermaxLength - 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
java.io.UnsupportedEncodingException - if the default encoding is not supported
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
java.nio.BufferUnderflowException - if the delimiter has not been found
public java.lang.String readStringByDelimiter(java.lang.String delimiter,
                                              java.lang.String encoding)
                                       throws java.io.IOException,
                                              ClosedConnectionException,
                                              java.nio.BufferUnderflowException,
                                              java.io.UnsupportedEncodingException
INonBlockingConnection.readStringByDelimiter(String, String, int) method is generally preferable
readStringByDelimiter in interface IConnectionreadStringByDelimiter in interface INonBlockingConnectiondelimiter - the delimiterencoding - the encodin to use
java.io.IOException - If some other I/O error occurs
java.io.UnsupportedEncodingException - If the given encoding is not supported
ClosedConnectionException - If the underlying socket is already closed
java.nio.BufferUnderflowException - if the buffer`s limit has been reached
public java.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 IDataSourcereadStringByDelimiter in interface IConnectionreadStringByDelimiter in interface INonBlockingConnectiondelimiter - 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
java.io.IOException - If some other I/O error occurs
java.io.UnsupportedEncodingException - If the given encoding is not supported
ClosedConnectionException - If the underlying socket is already closed
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 buffer`s limit has been reached
public java.lang.String readStringByLength(int length)
                                    throws java.io.IOException,
                                           ClosedConnectionException,
                                           java.nio.BufferUnderflowException,
                                           java.io.UnsupportedEncodingException
readStringByLength in interface IDataSourcereadStringByLength in interface IConnectionreadStringByLength in interface INonBlockingConnectionlength - the amount of bytes to read
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
java.io.UnsupportedEncodingException - if the given encoding is not supported
java.nio.BufferUnderflowException - if the buffer`s limit has been reached
public java.lang.String readStringByLength(int length,
                                           java.lang.String encoding)
                                    throws java.io.IOException,
                                           ClosedConnectionException,
                                           java.nio.BufferUnderflowException,
                                           java.io.UnsupportedEncodingException
readStringByLength in interface IDataSourcereadStringByLength in interface IConnectionreadStringByLength in interface INonBlockingConnectionlength - the amount of bytes to readencoding - the encodin to use
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
java.io.UnsupportedEncodingException - if the given encoding is not supported
java.nio.BufferUnderflowException - if the buffer`s limit has been reached
public int getIndexOf(java.lang.String str)
               throws java.io.IOException,
                      ClosedConnectionException,
                      java.nio.BufferUnderflowException
getIndexOf in interface IConnectiongetIndexOf in interface INonBlockingConnectionstr - 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 found
public int getIndexOf(java.lang.String str,
                      int maxLength)
               throws java.io.IOException,
                      ClosedConnectionException,
                      java.nio.BufferUnderflowException,
                      MaxReadSizeExceededException
getIndexOf in interface IConnectiongetIndexOf in interface INonBlockingConnectionstr - 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 found
public int getIndexOf(java.lang.String str,
                      java.lang.String encoding,
                      int maxLength)
               throws java.io.IOException,
                      ClosedConnectionException,
                      MaxReadSizeExceededException
getIndexOf in interface IConnectionstr - any stringencoding - the encoding of the 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
public INonBlockingConnection setOption(java.lang.String name,
                                        java.lang.Object value)
                                 throws java.io.IOException
setOption in interface IConnectionsetOption in interface INonBlockingConnectionname - the name of the optionvalue - the value of the option
java.io.IOException - In an I/O error occurspublic final int getPendingWriteDataSize()
getPendingWriteDataSize in interface IConnection
public final void close()
                 throws java.io.IOException
close in interface java.io.Closeableclose in interface java.nio.channels.Channeljava.io.IOExceptionpublic final boolean isOpen()
IDataHandler.onData(INonBlockingConnection)
isOpen in interface java.nio.channels.ChannelisOpen in interface IConnection
public void suspendRead()
                 throws java.io.IOException
suspendRead in interface IConnectionjava.io.IOException - If some other I/O error occurs
public void resumeRead()
                throws java.io.IOException
resumeRead in interface IConnectionjava.io.IOException - If some other I/O error occurs
public void flush()
           throws ClosedConnectionException,
                  java.io.IOException
flush in interface java.io.Flushableflush in interface IConnectionClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurspublic final void setFlushmode(IConnection.FlushMode flushMode)
flushMode - the flushmodepublic final IConnection.FlushMode getFlushmode()
public void setIdleTimeoutSec(int timeoutInSec)
setIdleTimeoutSec in interface IConnectiontimeoutInSec - idle timeout in secpublic void setConnectionTimeoutSec(int timeoutSec)
setConnectionTimeoutSec in interface IConnectiontimeoutSec - the connection timeout in secpublic int getConnectionTimeoutSec()
getConnectionTimeoutSec in interface IConnectionpublic int getIdleTimeoutSec()
getIdleTimeoutSec in interface IConnectionpublic final java.lang.String getDefaultEncoding()
getDefaultEncoding in interface IConnectionpublic final void setDefaultEncoding(java.lang.String defaultEncoding)
setDefaultEncoding in interface IConnectiondefaultEncoding - the default encodingpublic final void setAutoflush(boolean autoflush)
setAutoflush in interface IConnectionautoflush - true if autoflush should be activatedpublic final boolean getAutoflush()
getAutoflush in interface IConnectionpublic final java.lang.String getId()
getId in interface IConnectionpublic final java.net.InetAddress getLocalAddress()
getLocalAddress in interface IConnectionpublic final int getLocalPort()
getLocalPort in interface IConnectionpublic final java.net.InetAddress getRemoteAddress()
getRemoteAddress in interface IConnectionpublic final int getRemotePort()
getRemotePort in interface IConnection
public void activateSecuredMode()
                         throws java.io.IOException
activateSecuredMode in interface IConnectionjava.io.IOException - If some other I/O error occurs
public final int write(java.lang.String s)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnections - the message to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(java.lang.String s,
                       java.lang.String encoding)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnections - the message to sendencoding - the encoding which should be used th encode the chars into byte (e.g. `US-ASCII` or `UTF-8`)
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(byte b)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnectionb - the byte to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(byte... bytes)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnectionbytes - the bytes to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(byte[] bytes,
                       int offset,
                       int length)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnectionbytes - the bytes to sendoffset - The offset of the subarray to be used; must be non-negative and no larger than array.length. The new buffer`s position will be set to this value.length - The length of the subarray to be used; must be non-negative and no larger than array.length - offset. The new buffer`s limit will be set to offset + length.
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final long write(java.nio.ByteBuffer[] buffers)
                 throws ClosedConnectionException,
                        java.io.IOException
IConnection.INITIAL_AUTOFLUSH) the behaviour is
 according to the WritableByteChannel specification. In case of
 user managed flushing (autoflush is off) the passed over buffers will
 only be queued internally and written after flushing the connection.
write in interface java.nio.channels.GatheringByteChannelwrite in interface IDataSinkwrite in interface IConnectionbuffers - the bytes to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(java.nio.ByteBuffer buffer)
                throws ClosedConnectionException,
                       java.io.IOException
IConnection.INITIAL_AUTOFLUSH) the behaviour is
 according to the WritableByteChannel specification. In case of
 user managed flushing (autoflush is off) the passed over buffers will
 only be queued internally and written after flushing the connection.
write in interface java.nio.channels.WritableByteChannelwrite in interface IDataSinkwrite in interface IConnectionbuffer - the bytes to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(int i)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnectioni - the int value to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(short s)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinks - the short value to write
java.io.IOException - If some other I/O error occurs
ClosedConnectionException
public final int write(long l)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnectionl - the int value to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(double d)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnectiond - the int value to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final long write(java.nio.ByteBuffer[] srcs,
                        int offset,
                        int length)
                 throws java.io.IOException
write in interface java.nio.channels.GatheringByteChanneljava.io.IOExceptionpublic int indexOf(java.lang.String str)
str - any string
public final java.lang.Object attach(java.lang.Object obj)
attach in interface IConnectionpublic final java.lang.Object attachment()
attachment in interface IConnectionpublic final void setAttachment(java.lang.Object obj)
setAttachment in interface IConnectionobj - The object to be attached; may be nullpublic final java.lang.Object getAttachment()
getAttachment in interface IConnectionpublic void markReadPosition()
markReadPosition in interface IConnectionpublic void markWritePosition()
 ...
 con.setAutoflush(false);
 con.markWritePosition();  // mark current position
 con.write((int) 0);       // write "emtpy" length field
 int written = con.write("hello world");
 written += con.write(" it’s nice to be here");
 ...
 con.resetToWriteMark();  // return to length field position
 con.write(written);      // and update it
 con.flush(); // flush (marker will be removed implicit)
…    * 
markWritePosition in interface IConnectionpublic boolean resetToWriteMark()
resetToWriteMark in interface IConnectionpublic boolean resetToReadMark()
resetToReadMark in interface IConnectionpublic void removeReadMark()
removeReadMark in interface IConnectionpublic void removeWriteMark()
removeWriteMark in interface IConnectionpublic void onWritten()
public void onWriteException(java.io.IOException ioException)
public final java.lang.Object getOption(java.lang.String name)
                                 throws java.io.IOException
getOption in interface IConnectionname - the name of the option
java.io.IOException - In an I/O error occurspublic final java.util.Map<java.lang.String,java.lang.Class> getOptions()
getOptions in interface IConnectionpublic java.lang.String toString()
toString in class java.lang.Object
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||