Interface AsyncChannelWrapper

All Known Implementing Classes:
AsyncChannelWrapperNonSecure, AsyncChannelWrapperSecure

public interface AsyncChannelWrapper
This is a wrapper for a AsynchronousSocketChannel that limits the methods available thereby simplifying the process of implementing SSL/TLS support since there are fewer methods to intercept.
  • Method Details

    • read

      Reads data from the channel into the given buffer.
      Parameters:
      dst - the buffer into which data is to be read
      Returns:
      a Future holding the number of bytes read
    • read

      <B, A extends B> void read(ByteBuffer dst, A attachment, CompletionHandler<Integer,B> handler)
      Reads data from the channel into the given buffer with a completion handler.
      Type Parameters:
      B - the attachment type
      A - the attachment subtype
      Parameters:
      dst - the buffer into which data is to be read
      attachment - the object to attach to the task
      handler - the handler to use on completion
    • write

      Future<Integer> write(ByteBuffer src)
      Writes data from the given buffer to the channel.
      Parameters:
      src - the buffer from which data is to be written
      Returns:
      a Future holding the number of bytes written
    • write

      <B, A extends B> void write(ByteBuffer[] srcs, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long,B> handler)
      Writes data from the given buffers to the channel with a completion handler.
      Type Parameters:
      B - the attachment type
      A - the attachment subtype
      Parameters:
      srcs - the buffers from which data is to be written
      offset - the offset within the buffer array
      length - the number of buffers to write
      timeout - the maximum time to wait
      unit - the time unit of the timeout
      attachment - the object to attach to the task
      handler - the handler to use on completion
    • close

      void close()
      Closes the underlying channel.
    • handshake

      Future<Void> handshake() throws SSLException
      Performs the SSL/TLS handshake.
      Returns:
      a Future that completes when the handshake is finished
      Throws:
      SSLException - if an SSL error occurs
    • getLocalAddress

      SocketAddress getLocalAddress() throws IOException
      Returns the local address to which the channel is bound.
      Returns:
      the local socket address, or null if not bound
      Throws:
      IOException - if an I/O error occurs