Class AsyncSocketConnection

java.lang.Object
org.nustaq.kontraktor.asyncio.AsyncSocketConnection
Direct Known Subclasses:
QueuingAsyncSocketConnection

public abstract class AsyncSocketConnection extends Object
Baseclass for handling async io. Its strongly recommended to use QueuingAsyncSocketConnection as this eases things.
  • Field Details

    • readBuf

      protected ByteBuffer readBuf
    • key

      protected SelectionKey key
    • chan

      protected SocketChannel chan
    • writePromise

      protected Promise writePromise
    • writingBuffer

      protected ByteBuffer writingBuffer
    • isClosed

      protected boolean isClosed
    • myActor

      protected Executor myActor
    • theExecutingThread

      protected Thread theExecutingThread
      writes given buffer content. In case of partial write, another write is enqueued internally. once the write is completed, the returned promise is fulfilled. the next write has to wait until the future has completed, else write order might get mixed up. Better use write* methods of QueuingAsyncSocketConnection as these will write to a binary queue which is read+sent behind the scenes in parallel.
  • Constructor Details

  • Method Details

    • closed

      public abstract void closed(Throwable ioe)
    • close

      public void close() throws IOException
      Throws:
      IOException
    • checkThread

      protected void checkThread()
    • directWrite

      protected IPromise directWrite(ByteBuffer buf)
    • canWrite

      public boolean canWrite()
    • dataReceived

      public abstract void dataReceived(ByteBuffer buf)
    • isClosed

      public boolean isClosed()