com.marklogic.io

## Class SslByteChannel

- java.lang.Object
- - com.marklogic.io.SslByteChannel

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.ByteChannel, java.nio.channels.Channel, java.nio.channels.ReadableByteChannel, java.nio.channels.WritableByteChannel

      public class SslByteChannel
      extends java.lang.Object
      implements java.nio.channels.ByteChannel

  A ByteChannel that passes the data through an SSLEngine.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.logging.Logger` | `logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SslByteChannel(java.nio.channels.ByteChannel wrappedChannel, javax.net.ssl.SSLEngine engine, java.util.logging.Logger logger)` Creates a new instance of SSLByteChannel

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Ends SSL operation and close the wrapped byte channel
    `void` | `close(boolean closeSocket)`
    `int` | `getTimeout()`
    `boolean` | `isOpen()` Is the channel open ?
    `int` | `read(java.nio.ByteBuffer clientBuffer)` Fill the given buffer with some bytes and return the number of bytes added in the buffer. This method may return immediately with nothing added in the buffer.
    `int` | `readInsideHandshake(java.nio.ByteBuffer clientBuffer)`
    `void` | `setTimeout(int timeoutMillis)`
    `int` | `write(java.nio.ByteBuffer clientBuffer)` Write remaining bytes of the given byte buffer.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### logger

          protected final java.util.logging.Logger logger

  - ### Constructor Detail

    - #### SslByteChannel

          public SslByteChannel(java.nio.channels.ByteChannel wrappedChannel,
                                javax.net.ssl.SSLEngine engine,
                                java.util.logging.Logger logger)

      Creates a new instance of SSLByteChannel
      Parameters:
        `wrappedChannel` - The byte channel on which this ssl channel is built. This channel contains encrypted data.
        `engine` - A SSLEngine instance that will remember SSL current context. Warning, such an instance CAN NOT be shared
        `logger` - Logger for logging.

  - ### Method Detail

    - #### setTimeout

          public void setTimeout(int timeoutMillis)

    - #### getTimeout

          public int getTimeout()

    - #### close

          public void close()
                     throws java.io.IOException

      Ends SSL operation and close the wrapped byte channel
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Specified by:
        `close` in interface `java.nio.channels.Channel`
      Throws:
        `java.io.IOException` - May be raised by close operation on wrapped byte channel

    - #### close

          public void close(boolean closeSocket)
                     throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### isOpen

          public boolean isOpen()

      Is the channel open ?
      Specified by:
        `isOpen` in interface `java.nio.channels.Channel`
      Returns:
        true if the channel is still open

    - #### read

          public int read(java.nio.ByteBuffer clientBuffer)
                   throws java.io.IOException

      Fill the given buffer with some bytes and return the number of bytes added in the buffer.
      This method may return immediately with nothing added in the buffer. This method must be use exactly in the same way of ByteChannel read operation, so be careful with buffer position, limit, ... Check corresponding javadoc.
      Specified by:
        `read` in interface `java.nio.channels.ReadableByteChannel`
      Parameters:
        `clientBuffer` - The buffer that will received read bytes
      Returns:
        The number of bytes read
      Throws:
        `java.io.IOException` - May be raised by ByteChannel read operation

    - #### readInsideHandshake

          public int readInsideHandshake(java.nio.ByteBuffer clientBuffer)
                                  throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### write

          public int write(java.nio.ByteBuffer clientBuffer)
                    throws java.io.IOException

      Write remaining bytes of the given byte buffer. This method may return immediately with nothing written. This method must be use exactly in the same way of ByteChannel write operation, so be careful with buffer position, limit, ... Check corresponding javadoc.
      Specified by:
        `write` in interface `java.nio.channels.WritableByteChannel`
      Parameters:
        `clientBuffer` - buffer with remaining bytes to write
      Returns:
        The number of bytes written
      Throws:
        `java.io.IOException` - May be raised by ByteChannel write operation

Copyright © 2025 MarkLogic Corporation. All Rights Reserved.

Complete online documentation for MarkLogic Server, XQuery and related components may be found at developer.marklogic.com