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

java.lang.Objectorg.xsocket.connection.AbstractNonBlockingStream
org.xsocket.connection.NonBlockingConnection
public final class NonBlockingConnection
Implementation of the INonBlockingConnection interface. 
 Depending on the constructor parameter waitForConnect a newly created connection is in the open state. 
 Write or read methods can be called immediately. 
 Absence of the waitForConnect parameter is equals to waitForConnect==true.  
 
The methods of this class are not thread-safe.
| Nested Class Summary | 
|---|
| Nested classes/interfaces inherited from class org.xsocket.connection.AbstractNonBlockingStream | 
|---|
| AbstractNonBlockingStream.ISink, AbstractNonBlockingStream.ISource | 
| Nested classes/interfaces inherited from interface org.xsocket.connection.IConnection | 
|---|
| IConnection.FlushMode | 
| Field Summary | |
|---|---|
| static long | DEFAULT_SEND_TIMEOUT_MILLIS | 
| static String | SEND_TIMEOUT_KEY | 
| Fields inherited from interface org.xsocket.connection.INonBlockingConnection | 
|---|
| UNLIMITED | 
| Fields inherited from interface org.xsocket.connection.IConnection | 
|---|
| DEFAULT_AUTOFLUSH, DEFAULT_CONNECTION_TIMEOUT_MILLIS, DEFAULT_FLUSH_MODE, DEFAULT_IDLE_TIMEOUT_MILLIS, INITIAL_DEFAULT_ENCODING, MAX_TIMEOUT_MILLIS, SO_KEEPALIVE, SO_LINGER, SO_RCVBUF, SO_REUSEADDR, SO_SNDBUF, SO_TIMEOUT, TCP_NODELAY | 
| Constructor Summary | |
|---|---|
| protected  | NonBlockingConnection(org.xsocket.connection.ConnectionManager connectionManager,
                      org.xsocket.connection.HandlerAdapter hdlAdapter)server-side constructor | 
|   | NonBlockingConnection(InetAddress address,
                      int port)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      boolean autoflush,
                      IConnection.FlushMode flushmode)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      boolean autoflush,
                      IConnection.FlushMode flushmode,
                      Object attachment)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      boolean waitForConnect,
                      int connectTimeoutMillis)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      boolean waitForConnect,
                      int connectTimeoutMillis,
                      Executor workerPool)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      boolean waitForConnect,
                      int connectTimeoutMillis,
                      Map<String,Object> options)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      boolean waitForConnect,
                      int connectTimeoutMillis,
                      SSLContext sslContext,
                      boolean sslOn)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      boolean waitForConnect,
                      int connectTimeoutMillis,
                      SSLContext sslContext,
                      boolean sslOn,
                      Executor workerPool)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      Executor workerPool)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      int connectTimeoutMillis)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      int connectTimeoutMillis,
                      Executor workerPool)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      int connectTimeoutMillis,
                      Map<String,Object> options)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      int connectTimeoutMillis,
                      SSLContext sslContext,
                      boolean sslOn)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      int connectTimeoutMillis,
                      SSLContext sslContext,
                      boolean sslOn,
                      Executor workerPool)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      Map<String,Object> options)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      Object attachment)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      IHandler appHandler,
                      SSLContext sslContext,
                      boolean sslOn)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      int connectTimeoutMillis)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      int connectTimeoutMillis,
                      Map<String,Object> options)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      Map<String,Object> options)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      Map<String,Object> options,
                      SSLContext sslContext,
                      boolean sslOn)constructor. | 
|   | NonBlockingConnection(InetAddress address,
                      int port,
                      SSLContext sslContext,
                      boolean sslOn)constructor. | 
|   | NonBlockingConnection(InetSocketAddress address)constructor. | 
|   | NonBlockingConnection(InetSocketAddress remoteAddress,
                      InetSocketAddress localAddress,
                      IHandler appHandler,
                      boolean waitForConnect,
                      int connectTimeoutMillis,
                      Map<String,Object> options,
                      SSLContext sslContext,
                      boolean sslOn)constructor. | 
|   | NonBlockingConnection(String hostname,
                      int port)constructor. | 
|   | NonBlockingConnection(String hostname,
                      int port,
                      IHandler appHandler)constructor constructor. | 
|   | NonBlockingConnection(String hostname,
                      int port,
                      IHandler appHandler,
                      Executor workerPool)constructor constructor. | 
|   | NonBlockingConnection(String hostname,
                      int port,
                      IHandler appHandler,
                      Map<String,Object> options)constructor constructor. | 
|   | NonBlockingConnection(String hostname,
                      int port,
                      Map<String,Object> options,
                      SSLContext sslContext,
                      boolean sslOn)constructor. | 
|   | NonBlockingConnection(String hostname,
                      int port,
                      SSLContext sslContext,
                      boolean sslOn)constructor. | 
| Method Summary | |
|---|---|
|  void | activateSecuredMode()ad hoc activation of a secured mode (SSL). | 
|  void | close() | 
|  void | closeQuietly()closes the connection quitly | 
|  void | deactivateSecuredMode()ad hoc deactivation of a secured mode (SSL). | 
|  void | flush()flush the send buffer. | 
|  long | getConnectionTimeoutMillis()gets the connection timeout | 
|  IHandler | getHandler()gets the connection handler | 
|  String | getId()returns the id | 
|  long | getIdleTimeoutMillis()returns the idle timeout in millis. | 
| protected  String | getInfo()returns a info string | 
|  InetAddress | getLocalAddress()returns the local address | 
|  int | getLocalPort()returns the local port | 
|  int | getMaxReadBufferThreshold()get the max app read buffer size. | 
|  long | getNumberOfReceivedBytes() | 
|  long | getNumberOfSendBytes() | 
|  Object | getOption(String name)returns the value of a option | 
|  Map<String,Class> | getOptions()Returns an unmodifiable map of the options supported by this end point. | 
|  int | getPendingWriteDataSize()returns the size of the data which have already been written, but not yet transferred to the underlying socket. | 
|  long | getRemainingMillisToConnectionTimeout()returns the remaining time before a connection timeout occurs | 
|  long | getRemainingMillisToIdleTimeout()returns the remaining time before a idle timeout occurs | 
|  InetAddress | getRemoteAddress()returns the remote address | 
|  int | getRemotePort()returns the port of the remote end point | 
|  Executor | getWorkerpool()gets the workerpool | 
| protected  int | getWriteTransferChunkeSize()returns the default chunk size for writing | 
|  int | getWriteTransferRate()gets the send delay time. | 
| protected  boolean | isDataWriteable()returns true, if the underlying data sink is open | 
| protected  boolean | isMoreInputDataExpected()returns true, if the underlying data source is open | 
|  boolean | isOpen()return if the data source is open. | 
|  boolean | isReceivingSuspended()returns true if receiving is suspended | 
|  boolean | isSecure()returns if the connection is in secured mode | 
|  boolean | isSecuredModeActivateable()returns if secured mode is activateable | 
|  boolean | isServerSide()returns true id connection is server side | 
| protected  void | onPostAppend() | 
| protected  ByteBuffer[] | onRead(ByteBuffer[] readBufs)notification method which will be called after data has been read internally | 
| protected  void | onWriteDataInserted()notification, that data has been inserted | 
|  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 | 
|  ByteBuffer[] | readByteBufferByLength(int length)read a ByteBuffer | 
| protected  ByteBuffer | readSingleByteBuffer(int length)read a byte buffer by length. | 
| protected  boolean | reset()pool support (the connection- and idle timeout and handler will not be reset) | 
|  void | resumeReceiving()resume receiving data from the underlying subsystem | 
|  void | setConnectionTimeoutMillis(long timeoutMillis)sets the max time for a connections. | 
|  void | setHandler(IHandler hdl)set the connection handler. | 
|  void | setIdleTimeoutMillis(long timeoutMillis)sets the idle timeout in millis | 
|  void | setMaxReadBufferThreshold(int size)set the max app read buffer threshold | 
|  void | setOption(String name,
          Object value)sets the value of a option. | 
|  void | setWorkerpool(Executor workerpool)sets the worker pool | 
|  void | setWriteTransferRate(int bytesPerSecond)set the send delay time. | 
|  void | suspendReceiving()suspend receiving data from the underlying subsystem | 
|  String | toString() | 
|  long | transferFrom(ReadableByteChannel source,
             int chunkSize)transfer the data of the source channel to this data sink | 
|  void | write(byte[] bytes,
      int offset,
      int length,
      IWriteCompletionHandler writeCompletionHandler)writes bytes to the data sink. | 
|  void | write(byte[] bytes,
      IWriteCompletionHandler writeCompletionHandler)writes bytes to the data sink. | 
|  void | write(ByteBuffer[] srcs,
      int offset,
      int length,
      IWriteCompletionHandler writeCompletionHandler)writes a byte buffer array. | 
|  void | write(ByteBuffer[] buffers,
      IWriteCompletionHandler writeCompletionHandler)writes a byte buffer array. | 
|  void | write(ByteBuffer buffer,
      IWriteCompletionHandler writeCompletionHandler)writes a byte buffer. | 
|  void | write(List<ByteBuffer> buffers,
      IWriteCompletionHandler writeCompletionHandler)writes a list of bytes to the data sink. | 
|  void | write(String message,
      String encoding,
      IWriteCompletionHandler writeCompletionHandler)writes a message. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Methods inherited from interface org.xsocket.connection.INonBlockingConnection | 
|---|
| available, getEncoding, getFlushmode, getReadBufferVersion, indexOf, indexOf, isAutoflush, markReadPosition, markWritePosition, readByteBufferByDelimiter, readBytesByDelimiter, readBytesByDelimiter, readStringByDelimiter, readStringByDelimiter, readStringByLength, removeReadMark, removeWriteMark, resetToReadMark, resetToWriteMark, setAutoflush, setEncoding, setFlushmode, transferFrom, unread, unread, unread, unread, write | 
| Methods inherited from interface org.xsocket.connection.IConnection | 
|---|
| getAttachment, setAttachment | 
| Methods inherited from interface org.xsocket.IDataSource | 
|---|
| read, readByte, readByteBufferByDelimiter, readByteBufferByDelimiter, readBytesByDelimiter, readBytesByDelimiter, readBytesByLength, readDouble, readInt, readLong, readShort, readStringByDelimiter, readStringByDelimiter, readStringByLength, transferTo | 
| Methods inherited from interface org.xsocket.IDataSink | 
|---|
| transferFrom, write, write, write, write, write, write, write, write, write, write, write, write | 
| Methods inherited from interface java.nio.channels.GatheringByteChannel | 
|---|
| write, write | 
| Methods inherited from interface java.nio.channels.WritableByteChannel | 
|---|
| write | 
| Methods inherited from interface java.nio.channels.ReadableByteChannel | 
|---|
| read | 
| Field Detail | 
|---|
public static final String SEND_TIMEOUT_KEY
public static final long DEFAULT_SEND_TIMEOUT_MILLIS
| Constructor Detail | 
|---|
public NonBlockingConnection(String hostname,
                             int port)
                      throws IOException
hostname - the remote hostport - the port of the remote host to connect
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port)
                      throws IOException
address - the remote hostport - the port of the remote host to connect
IOException - If some other I/O error occurs
public NonBlockingConnection(InetSocketAddress address)
                      throws IOException
address - the remote host address
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             int connectTimeoutMillis)
                      throws IOException
address - the remote hostport - the port of the remote host to connectconnectTimeoutMillis - the timeout of the connect procedure
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             Map<String,Object> options)
                      throws IOException
address - the remote hostport - the port of the remote host to connectoptions - the socket options
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             int connectTimeoutMillis,
                             Map<String,Object> options)
                      throws IOException
address - the remote hostport - the port of the remote host to connectconnectTimeoutMillis - the timeout of the connect procedureoptions - the socket options
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             Object attachment)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)attachment - the attacjment or IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             int connectTimeoutMillis)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)connectTimeoutMillis - the timeout of the connect procedure
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             boolean waitForConnect,
                             int connectTimeoutMillis)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)waitForConnect - true, if the constructor should block until the connection is established. If the connect fails, the handler's onData and onDisconnect method will be called (if present)connectTimeoutMillis - the timeout of the connect procedure
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             SSLContext sslContext,
                             boolean sslOn)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)sslContext - the ssl contextsslOn - true, if ssl should be activated
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             int connectTimeoutMillis,
                             SSLContext sslContext,
                             boolean sslOn)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)sslContext - the ssl contextsslOn - true, if ssl should be activatedconnectTimeoutMillis - the timeout of the connect procedure
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             boolean waitForConnect,
                             int connectTimeoutMillis,
                             SSLContext sslContext,
                             boolean sslOn)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)sslContext - the ssl contextsslOn - true, if ssl should be activatedwaitForConnect - true, if the constructor should block until the connection is established. If the connect fails, the handler's onData and onDisconnect method will be called (if present)connectTimeoutMillis - the timeout of the connect procedure
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             Map<String,Object> options)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)options - the socket options
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             int connectTimeoutMillis,
                             Map<String,Object> options)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)connectTimeoutMillis - the timeout of the connect procedureoptions - the socket options
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             boolean waitForConnect,
                             int connectTimeoutMillis,
                             Map<String,Object> options)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)waitForConnect - true, if the constructor should block until the connection is established. If the connect fails, the handler's onData and onDisconnect method will be called (if present)connectTimeoutMillis - the timeout of the connect procedureoptions - the socket options
IOException - If some other I/O error occurs
public NonBlockingConnection(String hostname,
                             int port,
                             IHandler appHandler)
                      throws IOException
hostname - the remote hostport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)
IOException - If some other I/O error occurs
public NonBlockingConnection(String hostname,
                             int port,
                             IHandler appHandler,
                             Executor workerPool)
                      throws IOException
hostname - the remote hostport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)workerPool - the worker pool to use
IOException - If some other I/O error occurs
public NonBlockingConnection(String hostname,
                             int port,
                             IHandler appHandler,
                             Map<String,Object> options)
                      throws IOException
hostname - the remote hostport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)options - the socket options
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             SSLContext sslContext,
                             boolean sslOn)
                      throws IOException
address - the remote addressport - the remote portsslContext - the ssl context to usesslOn - true, activate SSL mode. false, ssl can be activated by user (see IReadWriteableConnection#activateSecuredMode())
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             Map<String,Object> options,
                             SSLContext sslContext,
                             boolean sslOn)
                      throws IOException
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 IReadWriteableConnection#activateSecuredMode())
IOException - If some other I/O error occurs
public NonBlockingConnection(String hostname,
                             int port,
                             SSLContext sslContext,
                             boolean sslOn)
                      throws IOException
hostname - the remote hostport - the remote portsslContext - the ssl context to usesslOn - true, activate SSL mode. false, ssl can be activated by user (see IReadWriteableConnection#activateSecuredMode())
IOException - If some other I/O error occurs
public NonBlockingConnection(String hostname,
                             int port,
                             Map<String,Object> options,
                             SSLContext sslContext,
                             boolean sslOn)
                      throws IOException
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 IReadWriteableConnection#activateSecuredMode())
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             Executor workerPool)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)workerPool - the worker pool to use
IOException - If some other I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             int connectTimeoutMillis,
                             Executor workerPool)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)connectTimeoutMillis - the timeout of the connect procedureworkerPool - the worker pool to use
IOException - if a I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             boolean waitForConnect,
                             int connectTimeoutMillis,
                             Executor workerPool)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)waitForConnect - true, if the constructor should block until the connection is established. If the connect fails, the handler's onData and onDisconnect method will be called (if present)connectTimeoutMillis - the timeout of the connect procedureworkerPool - the worker pool to use
IOException - if a I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             int connectTimeoutMillis,
                             SSLContext sslContext,
                             boolean sslOn,
                             Executor workerPool)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)rconnectTimeoutMillis - the timeout of the connect proceduresslContext - the ssl context to usesslOn - true, activate SSL mode. false, ssl can be activated by user (see IReadWriteableConnection#activateSecuredMode())workerPool - the worker pool to use
IOException - if a I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             boolean waitForConnect,
                             int connectTimeoutMillis,
                             SSLContext sslContext,
                             boolean sslOn,
                             Executor workerPool)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)rwaitForConnect - true, if the constructor should block until the connection is established. If the connect fails, the handler's onData and onDisconnect method will be called (if present)connectTimeoutMillis - the timeout of the connect proceduresslContext - the ssl context to usesslOn - true, activate SSL mode. false, ssl can be activated by user (see IReadWriteableConnection#activateSecuredMode())workerPool - the worker pool to use
IOException - if a I/O error occurs
public NonBlockingConnection(InetSocketAddress remoteAddress,
                             InetSocketAddress localAddress,
                             IHandler appHandler,
                             boolean waitForConnect,
                             int connectTimeoutMillis,
                             Map<String,Object> options,
                             SSLContext sslContext,
                             boolean sslOn)
                      throws IOException
remoteAddress - the remote addresslocalAddress - the localAddressappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)rwaitForConnect - true, if the constructor should block until the connection is established. If the connect fails, the handler's onData and onDisconnect method will be called (if present)connectTimeoutMillis - the timeout of the connect procedureoptions - the socket optionssslContext - the ssl context to usesslOn - true, activate SSL mode. false, ssl can be activated by user (see IReadWriteableConnection#activateSecuredMode())
IOException - if a I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             boolean autoflush,
                             IConnection.FlushMode flushmode)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)autoflush - the auto flush modeflushmode - the flush mode
IOException - if a I/O error occurs
public NonBlockingConnection(InetAddress address,
                             int port,
                             IHandler appHandler,
                             boolean autoflush,
                             IConnection.FlushMode flushmode,
                             Object attachment)
                      throws IOException
address - the remote addressport - the remote portappHandler - the application handler (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler and IConnectionTimeoutHandler)autoflush - the auto flush modeflushmode - the flush modeattachment - the attachment or IOException - if a I/O error occurs
protected NonBlockingConnection(org.xsocket.connection.ConnectionManager connectionManager,
                                org.xsocket.connection.HandlerAdapter hdlAdapter)
                         throws IOException
IOException| Method Detail | 
|---|
public int getMaxReadBufferThreshold()
getMaxReadBufferThreshold in interface INonBlockingConnectionpublic void setMaxReadBufferThreshold(int size)
setMaxReadBufferThreshold in interface INonBlockingConnectionprotected boolean isMoreInputDataExpected()
isMoreInputDataExpected in class AbstractNonBlockingStreamprotected boolean isDataWriteable()
isDataWriteable in class AbstractNonBlockingStream
public void setHandler(IHandler hdl)
                throws IOException
setHandler in interface INonBlockingConnectionhdl - the handler
IOException - If some other I/O error occurspublic IHandler getHandler()
getHandler in interface INonBlockingConnectionpublic void setWorkerpool(Executor workerpool)
setWorkerpool in interface INonBlockingConnectionworkerpool - the worker poolpublic Executor getWorkerpool()
getWorkerpool in interface INonBlockingConnectionprotected boolean reset()
reset in class AbstractNonBlockingStreampublic boolean isOpen()
isOpen in interface ChannelisOpen in interface IConnectionisOpen in interface INonBlockingConnectionpublic boolean isServerSide()
IConnection
isServerSide in interface IConnectionprotected void onPostAppend()
onPostAppend in class AbstractNonBlockingStream
protected ByteBuffer[] onRead(ByteBuffer[] readBufs)
                       throws IOException
AbstractNonBlockingStream
onRead in class AbstractNonBlockingStreamreadBufs - the read buffers
IOException - If some other I/O error occurspublic long getRemainingMillisToConnectionTimeout()
getRemainingMillisToConnectionTimeout in interface IConnectionpublic long getRemainingMillisToIdleTimeout()
getRemainingMillisToIdleTimeout in interface IConnectionpublic long getNumberOfReceivedBytes()
public long getNumberOfSendBytes()
public void setWriteTransferRate(int bytesPerSecond)
                          throws ClosedChannelException,
                                 IOException
INonBlockingConnection#setFlushmode(org.xsocket.connection.IConnection.FlushMode))
setWriteTransferRate in interface INonBlockingConnectionbytesPerSecond - the transfer rate of the outgoing data
ClosedChannelException - If the underlying socket is already closed
IOException - If some other I/O error occurs
public int getWriteTransferRate()
                         throws ClosedChannelException,
                                IOException
getWriteTransferRate in interface INonBlockingConnectionClosedChannelException - If the underlying socket is already closed
IOException - If some other I/O error occurspublic boolean isSecuredModeActivateable()
isSecuredModeActivateable in interface INonBlockingConnection
public void activateSecuredMode()
                         throws IOException
activateSecuredMode in interface INonBlockingConnectionIOException - If some other I/O error occurs
public void deactivateSecuredMode()
                           throws IOException
INonBlockingConnection
deactivateSecuredMode in interface INonBlockingConnectionIOException - If some other I/O error occurspublic boolean isSecure()
isSecure in interface INonBlockingConnection
public ByteBuffer[] readByteBufferByDelimiter(String delimiter,
                                              String encoding,
                                              int maxLength)
                                       throws IOException,
                                              BufferUnderflowException,
                                              MaxReadSizeExceededException
readByteBufferByDelimiter in interface INonBlockingConnectionreadByteBufferByDelimiter in class AbstractNonBlockingStreamdelimiter - the delimiterencoding - the delimiter encodingmaxLength - 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
IOException - If some other I/O error occurs
ClosedChannelException - If the stream is closed
BufferUnderflowException - if not enough data is available
public ByteBuffer[] readByteBufferByLength(int length)
                                    throws IOException,
                                           BufferUnderflowException
readByteBufferByLength in interface IDataSourcereadByteBufferByLength in class AbstractNonBlockingStreamlength - the length could be negative, in this case a empty array will be returned
IOException - If some other I/O error occurs
ClosedChannelException - If the stream is closed
BufferUnderflowException - if not enough data is available
protected ByteBuffer readSingleByteBuffer(int length)
                                   throws IOException,
                                          ClosedChannelException,
                                          BufferUnderflowException
readSingleByteBuffer in class AbstractNonBlockingStreamlength - the length
IOException - If some other I/O error occurs
ClosedChannelException - If the stream is closed
BufferUnderflowException - if not enough data is availablepublic void setIdleTimeoutMillis(long timeoutMillis)
setIdleTimeoutMillis in interface IConnectionpublic void setConnectionTimeoutMillis(long timeoutMillis)
setConnectionTimeoutMillis in interface IConnectionpublic long getConnectionTimeoutMillis()
getConnectionTimeoutMillis in interface IConnectionpublic long getIdleTimeoutMillis()
getIdleTimeoutMillis in interface IConnectionpublic InetAddress getLocalAddress()
getLocalAddress in interface IConnectionpublic String getId()
getId in interface IConnectionpublic int getLocalPort()
getLocalPort in interface IConnectionpublic InetAddress getRemoteAddress()
getRemoteAddress in interface IConnectionpublic int getRemotePort()
getRemotePort in interface IConnectionpublic int getPendingWriteDataSize()
getPendingWriteDataSize in interface INonBlockingConnection
public void suspendReceiving()
                      throws IOException
suspendReceiving in interface INonBlockingConnectionIOException - If some other I/O error occurspublic boolean isReceivingSuspended()
isReceivingSuspended in interface INonBlockingConnection
public void resumeReceiving()
                     throws IOException
resumeReceiving in interface INonBlockingConnectionIOException - If some other I/O error occurs
public void write(String message,
                  String encoding,
                  IWriteCompletionHandler writeCompletionHandler)
           throws IOException
write in interface INonBlockingConnectionmessage - the message to writeencoding - the encoding which should be used th encode the chars into byte (e.g. `US-ASCII` or `UTF-8`)writeCompletionHandler - the completion handler
IOException - If some other I/O error occurs
public void write(byte[] bytes,
                  IWriteCompletionHandler writeCompletionHandler)
           throws IOException
write in interface INonBlockingConnectionbytes - the bytes to writewriteCompletionHandler - the completion handler
IOException - If some other I/O error occurs
public void write(byte[] bytes,
                  int offset,
                  int length,
                  IWriteCompletionHandler writeCompletionHandler)
           throws IOException
write in interface INonBlockingConnectionbytes - the bytes to writeoffset - the offset of the sub array 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 sub array 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.writeCompletionHandler - the completion handler
IOException - If some other I/O error occurs
public void write(ByteBuffer[] srcs,
                  int offset,
                  int length,
                  IWriteCompletionHandler writeCompletionHandler)
           throws IOException
write in interface INonBlockingConnectionsrcs - the buffersoffset - the offsetlength - the lengthwriteCompletionHandler - the completionHandler
IOException - If some I/O error occurs
public void write(ByteBuffer buffer,
                  IWriteCompletionHandler writeCompletionHandler)
           throws IOException
write in interface INonBlockingConnectionbuffer - the buffer to writewriteCompletionHandler - the completionHandler
IOException - If some I/O error occurs
public void write(ByteBuffer[] buffers,
                  IWriteCompletionHandler writeCompletionHandler)
           throws IOException
write in interface INonBlockingConnectionbuffers - the buffers to writewriteCompletionHandler - the completionHandler
IOException - If some I/O error occurs
public void write(List<ByteBuffer> buffers,
                  IWriteCompletionHandler writeCompletionHandler)
           throws IOException
write in interface INonBlockingConnectionbuffers - the bytes to writewriteCompletionHandler - the completionHandler
IOException - If some other I/O error occurs
public long transferFrom(ReadableByteChannel source,
                         int chunkSize)
                  throws IOException,
                         BufferOverflowException
AbstractNonBlockingStream
transferFrom in interface IDataSinktransferFrom in class AbstractNonBlockingStreamsource - the source channelchunkSize - the chunk size to use
IOException - If some other I/O error occurs
ClosedChannelException - If the stream is closed
BufferOverflowException - If the no enough space is available
protected void onWriteDataInserted()
                            throws IOException,
                                   ClosedChannelException
onWriteDataInserted in class AbstractNonBlockingStreamIOException - if an exception occurs
ClosedChannelException - if the stream is closed
public Object getOption(String name)
                 throws IOException
getOption in interface IConnectionname - the name of the option
IOException - In an I/O error occurspublic Map<String,Class> getOptions()
getOptions in interface IConnection
public void setOption(String name,
                      Object value)
               throws IOException
http://www.onlamp.com/lpt/a/6324
setOption in interface IConnectionname - the name of the optionvalue - the value of the option
IOException - In an I/O error occursprotected int getWriteTransferChunkeSize()
AbstractNonBlockingStream
getWriteTransferChunkeSize in class AbstractNonBlockingStream
public void close()
           throws IOException
close in interface Closeableclose in interface Channelclose in class AbstractNonBlockingStreamIOExceptionpublic void closeQuietly()
public void flush()
           throws ClosedChannelException,
                  IOException
flush in interface Flushableflush in interface INonBlockingConnectionClosedChannelException - if the underlying channel is closed
IOException - If some other I/O error occurs
SocketTimeoutException - If the timeout has been reachedprotected String getInfo()
AbstractNonBlockingStream
getInfo in class AbstractNonBlockingStreampublic String toString()
toString in class Object| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||