org.apache.tomcat.util.net

## Class SocketWrapperBase<E>

- java.lang.Object
- - org.apache.tomcat.util.net.SocketWrapperBase<E>

- Direct Known Subclasses:
    AprEndpoint.AprSocketWrapper, Nio2Endpoint.Nio2SocketWrapper, NioEndpoint.NioSocketWrapper

      public abstract class SocketWrapperBase<E>
      extends Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `SocketWrapperBase.CompletionCheck`
    `static class` | `SocketWrapperBase.CompletionHandlerCall`
    `static class` | `SocketWrapperBase.CompletionState`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected LinkedBlockingDeque<ByteBufferHolder>` | `bufferedWrites` For "non-blocking" writes use an external set of buffers.
    `protected int` | `bufferedWriteSize` The max size of the buffered write buffer
    `static SocketWrapperBase.CompletionCheck` | `COMPLETE_WRITE` This utility CompletionCheck will cause the write to fully write all remaining data.
    `protected String` | `localAddr`
    `protected String` | `localName`
    `protected int` | `localPort`
    `static SocketWrapperBase.CompletionCheck` | `READ_DATA` This utility CompletionCheck will cause the completion handler to be called once some data has been read.
    `protected String` | `remoteAddr`
    `protected String` | `remoteHost`
    `protected int` | `remotePort`
    `protected static StringManager` | `sm`
    `protected SocketBufferHandler` | `socketBufferHandler` The buffers used for communicating with the socket.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SocketWrapperBase(E socket, AbstractEndpoint<E> endpoint)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addToBuffers(byte[] buf, int offset, int length)`
    `protected void` | `addToBuffers(ByteBuffer from)`
    `boolean` | `awaitReadComplete(long timeout, TimeUnit unit)` If an asynchronous read operation is pending, this method will block until the operation completes, or the specified amount of time has passed.
    `boolean` | `awaitWriteComplete(long timeout, TimeUnit unit)` If an asynchronous write operation is pending, this method will block until the operation completes, or the specified amount of time has passed.
    `boolean` | `canWrite()`
    `void` | `checkError()`
    `abstract void` | `close()`
    `abstract SendfileDataBase` | `createSendfileData(String filename, long pos, long length)`
    `int` | `decrementKeepAlive()`
    `abstract void` | `doClientAuth(SSLSupport sslSupport)` Require the client to perform CLIENT-CERT authentication if it hasn't already done so.
    `protected void` | `doWrite(boolean block)` Write the contents of the socketWriteBuffer to the socket.
    `protected abstract void` | `doWrite(boolean block, ByteBuffer from)` Write the contents of the ByteBuffer to the socket.
    `boolean` | `flush(boolean block)` Writes as much data as possible from any that remains in the buffers.
    `protected void` | `flushBlocking()`
    `protected boolean` | `flushNonBlocking()`
    `boolean` | `getBlockingStatus()`
    `Lock` | `getBlockingStatusReadLock()`
    `ReentrantReadWriteLock.WriteLock` | `getBlockingStatusWriteLock()`
    `AbstractEndpoint<E>` | `getEndpoint()`
    `IOException` | `getError()`
    `String` | `getLocalAddr()`
    `String` | `getLocalName()`
    `int` | `getLocalPort()`
    `String` | `getNegotiatedProtocol()`
    `long` | `getReadTimeout()`
    `String` | `getRemoteAddr()`
    `String` | `getRemoteHost()`
    `int` | `getRemotePort()`
    `E` | `getSocket()`
    `SocketBufferHandler` | `getSocketBufferHandler()`
    `abstract SSLSupport` | `getSslSupport(String clientCertProvider)`
    `long` | `getWriteTimeout()`
    `boolean` | `hasAsyncIO()` Allows using NIO2 style read/write only for connectors that can efficiently support it.
    `boolean` | `hasDataToWrite()`
    `abstract boolean` | `isClosed()`
    `boolean` | `isReadPending()` Allows checking if an asynchronous read operation is currently pending.
    `abstract boolean` | `isReadyForRead()`
    `boolean` | `isReadyForWrite()` Checks to see if there are any writes pending and if there are calls `registerWriteInterest()` to trigger a callback once the pending writes have completed.
    `boolean` | `isSecure()`
    `boolean` | `isUpgraded()`
    `boolean` | `isWritePending()` Allows checking if an asynchronous write operation is currently pending.
    `protected abstract void` | `populateLocalAddr()`
    `protected abstract void` | `populateLocalName()`
    `protected abstract void` | `populateLocalPort()`
    `protected int` | `populateReadBuffer(byte[] b, int off, int len)`
    `protected int` | `populateReadBuffer(ByteBuffer to)`
    `protected abstract void` | `populateRemoteAddr()`
    `protected abstract void` | `populateRemoteHost()`
    `protected abstract void` | `populateRemotePort()`
    `abstract SendfileState` | `processSendfile(SendfileDataBase sendfileData)` Starts the sendfile process.
    `void` | `processSocket(SocketEvent socketStatus, boolean dispatch)`
    `abstract int` | `read(boolean block, byte[] b, int off, int len)`
    `abstract int` | `read(boolean block, ByteBuffer to)`
    `<A> SocketWrapperBase.CompletionState` | `read(boolean block, long timeout, TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, CompletionHandler<Long,? super A> handler, ByteBuffer... dsts)` Scatter read.
    `<A> SocketWrapperBase.CompletionState` | `read(ByteBuffer[] dsts, int offset, int length, boolean block, long timeout, TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, CompletionHandler<Long,? super A> handler)` Scatter read.
    `abstract void` | `registerReadInterest()`
    `abstract void` | `registerWriteInterest()`
    `abstract void` | `setAppReadBufHandler(ApplicationBufferHandler handler)`
    `void` | `setBlockingStatus(boolean blockingStatus)`
    `void` | `setError(IOException error)`
    `void` | `setKeepAliveLeft(int keepAliveLeft)`
    `void` | `setNegotiatedProtocol(String negotiatedProtocol)`
    `void` | `setReadTimeout(long readTimeout)` Set the timeout for reading.
    `void` | `setSecure(boolean secure)`
    `void` | `setUpgraded(boolean upgraded)`
    `void` | `setWriteTimeout(long writeTimeout)` Set the timeout for writing.
    `String` | `toString()` Overridden for debug purposes.
    `protected static int` | `transfer(byte[] from, int offset, int length, ByteBuffer to)`
    `protected static int` | `transfer(ByteBuffer from, ByteBuffer to)`
    `void` | `unRead(ByteBuffer returnedInput)` Return input that has been read to the input buffer for re-reading by the correct component.
    `void` | `write(boolean block, byte[] buf, int off, int len)` Writes the provided data to the socket, buffering any remaining data if used in non-blocking mode.
    `void` | `write(boolean block, ByteBuffer from)` Writes the provided data to the socket, buffering any remaining data if used in non-blocking mode.
    `<A> SocketWrapperBase.CompletionState` | `write(boolean block, long timeout, TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, CompletionHandler<Long,? super A> handler, ByteBuffer... srcs)` Gather write.
    `<A> SocketWrapperBase.CompletionState` | `write(ByteBuffer[] srcs, int offset, int length, boolean block, long timeout, TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, CompletionHandler<Long,? super A> handler)` Gather write.
    `protected void` | `writeBlocking(byte[] buf, int off, int len)` Transfers the data to the socket write buffer (writing that data to the socket if the buffer fills up using a blocking write) until all the data has been transferred and space remains in the socket write buffer.
    `protected void` | `writeBlocking(ByteBuffer from)` Write the data to the socket (writing that data to the socket using a blocking write) until all the data has been transferred and space remains in the socket write buffer.
    `protected void` | `writeByteBufferBlocking(ByteBuffer from)`
    `protected boolean` | `writeByteBufferNonBlocking(ByteBuffer from)`
    `protected void` | `writeNonBlocking(byte[] buf, int off, int len)` Transfers the data to the socket write buffer (writing that data to the socket if the buffer fills up using a non-blocking write) until either all the data has been transferred and space remains in the socket write buffer or a non-blocking write leaves data in the socket write buffer.
    `protected void` | `writeNonBlocking(ByteBuffer from)` Writes the data to the socket (writing that data to the socket using a non-blocking write) until either all the data has been transferred and space remains in the socket write buffer or a non-blocking write leaves data in the socket write buffer.

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

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

- - ### Field Detail

    - #### sm

          protected static final StringManager sm

    - #### localAddr

          protected String localAddr

    - #### localName

          protected String localName

    - #### localPort

          protected int localPort

    - #### remoteAddr

          protected String remoteAddr

    - #### remoteHost

          protected String remoteHost

    - #### remotePort

          protected int remotePort

    - #### socketBufferHandler

          protected volatile SocketBufferHandler socketBufferHandler

      The buffers used for communicating with the socket.

    - #### bufferedWrites

          protected final LinkedBlockingDeque<ByteBufferHolder> bufferedWrites

      For "non-blocking" writes use an external set of buffers. Although the API only allows one non-blocking write at a time, due to buffering and the possible need to write HTTP headers, there may be more than one write to the OutputBuffer.

    - #### bufferedWriteSize

          protected int bufferedWriteSize

      The max size of the buffered write buffer

    - #### COMPLETE_WRITE

          public static final SocketWrapperBase.CompletionCheck COMPLETE_WRITE

      This utility CompletionCheck will cause the write to fully write all remaining data. If the operation completes inline, the completion handler will not be called.

    - #### READ_DATA

          public static final SocketWrapperBase.CompletionCheck READ_DATA

      This utility CompletionCheck will cause the completion handler to be called once some data has been read. If the operation completes inline, the completion handler will not be called.

  - ### Constructor Detail

    - #### SocketWrapperBase

          public SocketWrapperBase(E socket,
                           AbstractEndpoint<E> endpoint)

  - ### Method Detail

    - #### getSocket

          public E getSocket()

    - #### getEndpoint

          public AbstractEndpoint<E> getEndpoint()

    - #### getError

          public IOException getError()

    - #### setError

          public void setError(IOException error)

    - #### checkError

          public void checkError()
                          throws IOException

      Throws:
        `IOException`

    - #### isUpgraded

          public boolean isUpgraded()

    - #### setUpgraded

          public void setUpgraded(boolean upgraded)

    - #### isSecure

          public boolean isSecure()

    - #### setSecure

          public void setSecure(boolean secure)

    - #### getNegotiatedProtocol

          public String getNegotiatedProtocol()

    - #### setNegotiatedProtocol

          public void setNegotiatedProtocol(String negotiatedProtocol)

    - #### setReadTimeout

          public void setReadTimeout(long readTimeout)

      Set the timeout for reading. Values of zero or less will be changed to -1.
      Parameters:
        `readTimeout` - The timeout in milliseconds. A value of -1 indicates an infinite timeout.

    - #### getReadTimeout

          public long getReadTimeout()

    - #### setWriteTimeout

          public void setWriteTimeout(long writeTimeout)

      Set the timeout for writing. Values of zero or less will be changed to -1.
      Parameters:
        `writeTimeout` - The timeout in milliseconds. A value of zero or less indicates an infinite timeout.

    - #### getWriteTimeout

          public long getWriteTimeout()

    - #### setKeepAliveLeft

          public void setKeepAliveLeft(int keepAliveLeft)

    - #### decrementKeepAlive

          public int decrementKeepAlive()

    - #### getRemoteHost

          public String getRemoteHost()

    - #### populateRemoteHost

          protected abstract void populateRemoteHost()

    - #### getRemoteAddr

          public String getRemoteAddr()

    - #### populateRemoteAddr

          protected abstract void populateRemoteAddr()

    - #### getRemotePort

          public int getRemotePort()

    - #### populateRemotePort

          protected abstract void populateRemotePort()

    - #### getLocalName

          public String getLocalName()

    - #### populateLocalName

          protected abstract void populateLocalName()

    - #### getLocalAddr

          public String getLocalAddr()

    - #### populateLocalAddr

          protected abstract void populateLocalAddr()

    - #### getLocalPort

          public int getLocalPort()

    - #### populateLocalPort

          protected abstract void populateLocalPort()

    - #### getBlockingStatus

          public boolean getBlockingStatus()

    - #### setBlockingStatus

          public void setBlockingStatus(boolean blockingStatus)

    - #### getBlockingStatusReadLock

          public Lock getBlockingStatusReadLock()

    - #### getBlockingStatusWriteLock

          public ReentrantReadWriteLock.WriteLock getBlockingStatusWriteLock()

    - #### getSocketBufferHandler

          public SocketBufferHandler getSocketBufferHandler()

    - #### hasDataToWrite

          public boolean hasDataToWrite()

    - #### isReadyForWrite

          public boolean isReadyForWrite()

      Checks to see if there are any writes pending and if there are calls `registerWriteInterest()` to trigger a callback once the pending writes have completed.

      Note: Once this method has returned `false` it MUST NOT be called again until the pending write has completed and the callback has been fired. TODO: Modify `registerWriteInterest()` so the above restriction is enforced there rather than relying on the caller.

      Returns:
        `true` if no writes are pending and data can be written otherwise `false`

    - #### canWrite

          public boolean canWrite()

    - #### toString

          public String toString()

      Overridden for debug purposes. No guarantees are made about the format of this message which may vary significantly between point releases.

      Overrides:
        `toString` in class `Object`

    - #### read

          public abstract int read(boolean block,
                 byte[] b,
                 int off,
                 int len)
                            throws IOException

      Throws:
        `IOException`

    - #### read

          public abstract int read(boolean block,
                 ByteBuffer to)
                            throws IOException

      Throws:
        `IOException`

    - #### isReadyForRead

          public abstract boolean isReadyForRead()
                                          throws IOException

      Throws:
        `IOException`

    - #### setAppReadBufHandler

          public abstract void setAppReadBufHandler(ApplicationBufferHandler handler)

    - #### populateReadBuffer

          protected int populateReadBuffer(byte[] b,
                               int off,
                               int len)

    - #### populateReadBuffer

          protected int populateReadBuffer(ByteBuffer to)

    - #### unRead

          public void unRead(ByteBuffer returnedInput)

      Return input that has been read to the input buffer for re-reading by the correct component. There are times when a component may read more data than it needs before it passes control to another component. One example of this is during HTTP upgrade. If an (arguably misbehaving client) sends data associated with the upgraded protocol before the HTTP upgrade completes, the HTTP handler may read it. This method provides a way for that data to be returned so it can be processed by the correct component.
      Parameters:
        `returnedInput` - The input to return to the input buffer.

    - #### close

          public abstract void close()
                              throws IOException

      Throws:
        `IOException`

    - #### isClosed

          public abstract boolean isClosed()

    - #### write

          public final void write(boolean block,
                   byte[] buf,
                   int off,
                   int len)
                           throws IOException

      Writes the provided data to the socket, buffering any remaining data if used in non-blocking mode.
      Parameters:
        `block` - `true` if a blocking write should be used, otherwise a non-blocking write will be used
        `buf` - The byte array containing the data to be written
        `off` - The offset within the byte array of the data to be written
        `len` - The length of the data to be written
      Throws:
        `IOException` - If an IO error occurs during the write

    - #### write

          public final void write(boolean block,
                   ByteBuffer from)
                           throws IOException

      Writes the provided data to the socket, buffering any remaining data if used in non-blocking mode.
      Parameters:
        `block` - `true` if a blocking write should be used, otherwise a non-blocking write will be used
        `from` - The ByteBuffer containing the data to be written
      Throws:
        `IOException` - If an IO error occurs during the write

    - #### writeBlocking

          protected void writeBlocking(byte[] buf,
                           int off,
                           int len)
                                throws IOException

      Transfers the data to the socket write buffer (writing that data to the socket if the buffer fills up using a blocking write) until all the data has been transferred and space remains in the socket write buffer.
      Parameters:
        `buf` - The byte array containing the data to be written
        `off` - The offset within the byte array of the data to be written
        `len` - The length of the data to be written
      Throws:
        `IOException` - If an IO error occurs during the write

    - #### writeBlocking

          protected void writeBlocking(ByteBuffer from)
                                throws IOException

      Write the data to the socket (writing that data to the socket using a blocking write) until all the data has been transferred and space remains in the socket write buffer. If it is possible use the provided buffer directly and do not transfer to the socket write buffer.
      Parameters:
        `from` - The ByteBuffer containing the data to be written
      Throws:
        `IOException` - If an IO error occurs during the write

    - #### writeByteBufferBlocking

          protected void writeByteBufferBlocking(ByteBuffer from)
                                          throws IOException

      Throws:
        `IOException`

    - #### writeNonBlocking

          protected void writeNonBlocking(byte[] buf,
                              int off,
                              int len)
                                   throws IOException

      Transfers the data to the socket write buffer (writing that data to the socket if the buffer fills up using a non-blocking write) until either all the data has been transferred and space remains in the socket write buffer or a non-blocking write leaves data in the socket write buffer.
      Parameters:
        `buf` - The byte array containing the data to be written
        `off` - The offset within the byte array of the data to be written
        `len` - The length of the data to be written
      Throws:
        `IOException` - If an IO error occurs during the write

    - #### writeNonBlocking

          protected void writeNonBlocking(ByteBuffer from)
                                   throws IOException

      Writes the data to the socket (writing that data to the socket using a non-blocking write) until either all the data has been transferred and space remains in the socket write buffer or a non-blocking write leaves data in the socket write buffer. If it is possible use the provided buffer directly and do not transfer to the socket write buffer.
      Parameters:
        `from` - The ByteBuffer containing the data to be written
      Throws:
        `IOException` - If an IO error occurs during the write

    - #### writeByteBufferNonBlocking

          protected boolean writeByteBufferNonBlocking(ByteBuffer from)
                                                throws IOException

      Throws:
        `IOException`

    - #### flush

          public boolean flush(boolean block)
                        throws IOException

      Writes as much data as possible from any that remains in the buffers.
      Parameters:
        `block` - `true` if a blocking write should be used, otherwise a non-blocking write will be used
      Returns:
        `true` if data remains to be flushed after this method completes, otherwise `false`. In blocking mode therefore, the return value should always be `false`
      Throws:
        `IOException` - If an IO error occurs during the write

    - #### flushBlocking

          protected void flushBlocking()
                                throws IOException

      Throws:
        `IOException`

    - #### flushNonBlocking

          protected boolean flushNonBlocking()
                                      throws IOException

      Throws:
        `IOException`

    - #### doWrite

          protected void doWrite(boolean block)
                          throws IOException

      Write the contents of the socketWriteBuffer to the socket. For blocking writes either then entire contents of the buffer will be written or an IOException will be thrown. Partial blocking writes will not occur.
      Parameters:
        `block` - Should the write be blocking or not?
      Throws:
        `IOException` - If an I/O error such as a timeout occurs during the write

    - #### doWrite

          protected abstract void doWrite(boolean block,
                     ByteBuffer from)
                                   throws IOException

      Write the contents of the ByteBuffer to the socket. For blocking writes either then entire contents of the buffer will be written or an IOException will be thrown. Partial blocking writes will not occur.
      Parameters:
        `block` - Should the write be blocking or not?
        `from` - the ByteBuffer containing the data to be written
      Throws:
        `IOException` - If an I/O error such as a timeout occurs during the write

    - #### addToBuffers

          protected void addToBuffers(byte[] buf,
                          int offset,
                          int length)

    - #### addToBuffers

          protected void addToBuffers(ByteBuffer from)

    - #### processSocket

          public void processSocket(SocketEvent socketStatus,
                           boolean dispatch)

    - #### registerReadInterest

          public abstract void registerReadInterest()

    - #### registerWriteInterest

          public abstract void registerWriteInterest()

    - #### createSendfileData

          public abstract SendfileDataBase createSendfileData(String filename,
                                            long pos,
                                            long length)

    - #### processSendfile

          public abstract SendfileState processSendfile(SendfileDataBase sendfileData)

      Starts the sendfile process. It is expected that if the sendfile process does not complete during this call and does not report an error, that the caller will not add the socket to the poller (or equivalent). That is the responsibility of this method.
      Parameters:
        `sendfileData` - Data representing the file to send
      Returns:
        The state of the sendfile process after the first write.

    - #### doClientAuth

          public abstract void doClientAuth(SSLSupport sslSupport)

      Require the client to perform CLIENT-CERT authentication if it hasn't already done so.
      Parameters:
        `sslSupport` - The SSL/TLS support instance currently being used by the connection that may need updating after the client authentication

    - #### getSslSupport

          public abstract SSLSupport getSslSupport(String clientCertProvider)

    - #### hasAsyncIO

          public boolean hasAsyncIO()

      Allows using NIO2 style read/write only for connectors that can efficiently support it.
      Returns:
        This default implementation always returns `false`

    - #### isReadPending

          public boolean isReadPending()

      Allows checking if an asynchronous read operation is currently pending.
      Returns:
        `true` if the endpoint supports asynchronous IO and a read operation is being processed asynchronously

    - #### isWritePending

          public boolean isWritePending()

      Allows checking if an asynchronous write operation is currently pending.
      Returns:
        `true` if the endpoint supports asynchronous IO and a write operation is being processed asynchronously

    - #### awaitReadComplete

          public boolean awaitReadComplete(long timeout,
                                  TimeUnit unit)

      If an asynchronous read operation is pending, this method will block until the operation completes, or the specified amount of time has passed.
      Parameters:
        `timeout` - The maximum amount of time to wait
        `unit` - The unit for the timeout
      Returns:
        `true` if the read operation is complete, `false` if the operation is still pending and the specified timeout has passed

    - #### awaitWriteComplete

          public boolean awaitWriteComplete(long timeout,
                                   TimeUnit unit)

      If an asynchronous write operation is pending, this method will block until the operation completes, or the specified amount of time has passed.
      Parameters:
        `timeout` - The maximum amount of time to wait
        `unit` - The unit for the timeout
      Returns:
        `true` if the read operation is complete, `false` if the operation is still pending and the specified timeout has passed

    - #### read

          public final <A> SocketWrapperBase.CompletionState read(boolean block,
                                                   long timeout,
                                                   TimeUnit unit,
                                                   A attachment,
                                                   SocketWrapperBase.CompletionCheck check,
                                                   CompletionHandler<Long,? super A> handler,
                                                   ByteBuffer... dsts)

      Scatter read. The completion handler will be called once some data has been read or an error occurred. If a CompletionCheck object has been provided, the completion handler will only be called if the callHandler method returned true. If no CompletionCheck object has been provided, the default NIO2 behavior is used: the completion handler will be called as soon as some data has been read, even if the read has completed inline.
      Type Parameters:
        `A` - The attachment type
      Parameters:
        `block` - true to block until any pending read is done, if the timeout occurs and a read is still pending, a ReadPendingException will be thrown; false to not block but any pending read operation will cause a ReadPendingException
        `timeout` - timeout duration for the read
        `unit` - units for the timeout duration
        `attachment` - an object to attach to the I/O operation that will be used when calling the completion handler
        `check` - for the IO operation completion
        `handler` - to call when the IO is complete
        `dsts` - buffers
      Returns:
        the completion state (done, done inline, or still pending)

    - #### read

          public <A> SocketWrapperBase.CompletionState read(ByteBuffer[] dsts,
                                                   int offset,
                                                   int length,
                                                   boolean block,
                                                   long timeout,
                                                   TimeUnit unit,
                                                   A attachment,
                                                   SocketWrapperBase.CompletionCheck check,
                                                   CompletionHandler<Long,? super A> handler)

      Scatter read. The completion handler will be called once some data has been read or an error occurred. If a CompletionCheck object has been provided, the completion handler will only be called if the callHandler method returned true. If no CompletionCheck object has been provided, the default NIO2 behavior is used: the completion handler will be called as soon as some data has been read, even if the read has completed inline.
      Type Parameters:
        `A` - The attachment type
      Parameters:
        `dsts` - buffers
        `offset` - in the buffer array
        `length` - in the buffer array
        `block` - true to block until any pending read is done, if the timeout occurs and a read is still pending, a ReadPendingException will be thrown; false to not block but any pending read operation will cause a ReadPendingException
        `timeout` - timeout duration for the read
        `unit` - units for the timeout duration
        `attachment` - an object to attach to the I/O operation that will be used when calling the completion handler
        `check` - for the IO operation completion
        `handler` - to call when the IO is complete
      Returns:
        the completion state (done, done inline, or still pending)

    - #### write

          public final <A> SocketWrapperBase.CompletionState write(boolean block,
                                                    long timeout,
                                                    TimeUnit unit,
                                                    A attachment,
                                                    SocketWrapperBase.CompletionCheck check,
                                                    CompletionHandler<Long,? super A> handler,
                                                    ByteBuffer... srcs)

      Gather write. The completion handler will be called once some data has been written or an error occurred. If a CompletionCheck object has been provided, the completion handler will only be called if the callHandler method returned true. If no CompletionCheck object has been provided, the default NIO2 behavior is used: the completion handler will be called, even if the write is incomplete and data remains in the buffers, or if the write completed inline.
      Type Parameters:
        `A` - The attachment type
      Parameters:
        `block` - true to block until any pending write is done, if the timeout occurs and a write is still pending, a WritePendingException will be thrown; false to not block but any pending write operation will cause a WritePendingException
        `timeout` - timeout duration for the write
        `unit` - units for the timeout duration
        `attachment` - an object to attach to the I/O operation that will be used when calling the completion handler
        `check` - for the IO operation completion
        `handler` - to call when the IO is complete
        `srcs` - buffers
      Returns:
        the completion state (done, done inline, or still pending)

    - #### write

          public <A> SocketWrapperBase.CompletionState write(ByteBuffer[] srcs,
                                                    int offset,
                                                    int length,
                                                    boolean block,
                                                    long timeout,
                                                    TimeUnit unit,
                                                    A attachment,
                                                    SocketWrapperBase.CompletionCheck check,
                                                    CompletionHandler<Long,? super A> handler)

      Gather write. The completion handler will be called once some data has been written or an error occurred. If a CompletionCheck object has been provided, the completion handler will only be called if the callHandler method returned true. If no CompletionCheck object has been provided, the default NIO2 behavior is used: the completion handler will be called, even if the write is incomplete and data remains in the buffers, or if the write completed inline.
      Type Parameters:
        `A` - The attachment type
      Parameters:
        `srcs` - buffers
        `offset` - in the buffer array
        `length` - in the buffer array
        `block` - true to block until any pending write is done, if the timeout occurs and a write is still pending, a WritePendingException will be thrown; false to not block but any pending write operation will cause a WritePendingException
        `timeout` - timeout duration for the write
        `unit` - units for the timeout duration
        `attachment` - an object to attach to the I/O operation that will be used when calling the completion handler
        `check` - for the IO operation completion
        `handler` - to call when the IO is complete
      Returns:
        the completion state (done, done inline, or still pending)

    - #### transfer

          protected static int transfer(byte[] from,
                     int offset,
                     int length,
                     ByteBuffer to)

    - #### transfer

          protected static int transfer(ByteBuffer from,
                     ByteBuffer to)

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.