AprEndpoint.AprSocketWrapper (Apache Tomcat 9.0.120 API Documentation)
Description: declaration: package: org.apache.tomcat.util.net, class: AprEndpoint, class: AprSocketWrapper

# Class AprEndpoint.AprSocketWrapper

java.lang.Object
org.apache.tomcat.util.net.SocketWrapperBase<Long>
org.apache.tomcat.util.net.AprEndpoint.AprSocketWrapper

Enclosing class:
  `AprEndpoint`

public static class AprEndpoint.AprSocketWrapper extends SocketWrapperBase<Long>

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from class SocketWrapperBase

  `SocketWrapperBase.BlockingMode, SocketWrapperBase.CompletionCheck, SocketWrapperBase.CompletionHandlerCall, SocketWrapperBase.CompletionState, SocketWrapperBase.OperationState<A>, SocketWrapperBase.VectoredIOCompletionHandler<A>`

- ## Field Summary

  ### Fields inherited from class SocketWrapperBase

  `bufferedWriteSize, closed, COMPLETE_READ, COMPLETE_READ_WITH_COMPLETION, COMPLETE_WRITE, COMPLETE_WRITE_WITH_COMPLETION, localAddr, localName, localPort, nonBlockingWriteBuffer, previousIOException, READ_DATA, readOperation, readPending, remoteAddr, remoteHost, remotePort, sm, sniHostName, socketBufferHandler, writeOperation, writePending`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AprSocketWrapper(Long socket, AprEndpoint endpoint)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Close the socket wrapper.
  `SendfileDataBase`
  `createSendfileData(String filename, long pos, long length)`
  Creates a sendfile data object for the specified file.
  `void`
  `doClientAuth(SSLSupport sslSupport)`
  Require the client to perform CLIENT-CERT authentication if it hasn't already done so.
  `protected void`
  `doClose()`
  Perform the actual close.
  `protected void`
  `doWrite(boolean block, ByteBuffer from)`
  Write the contents of the ByteBuffer to the socket.
  `protected boolean`
  `flushNonBlocking()`
  Flushes remaining buffered data using a non-blocking write.
  `boolean`
  `getBlockingStatus()`
  `Lock`
  `getBlockingStatusReadLock()`
  `ReentrantReadWriteLock.WriteLock`
  `getBlockingStatusWriteLock()`
  `SSLSupport`
  `getSslSupport()`
  Obtain an SSLSupport instance for this socket.
  `SSLSupport`
  `getSslSupport(String clientCertProvider)`
  Obtain an SSLSupport instance for this socket.
  `boolean`
  `isReadyForRead()`
  Checks if the socket is ready for reading.
  `protected <A> SocketWrapperBase<Long>.OperationState<A>`
  `newOperationState(boolean read, ByteBuffer[] buffers, int offset, int length, SocketWrapperBase.BlockingMode block, long timeout, TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, CompletionHandler<Long, ? super A> handler, Semaphore semaphore, SocketWrapperBase<Long>.VectoredIOCompletionHandler<A> completion)`
  Creates a new operation state for vectored I/O operations.
  `protected void`
  `populateLocalAddr()`
  Populates the cached local IP address from the underlying socket.
  `protected void`
  `populateLocalName()`
  Populates the cached local host name from the underlying socket.
  `protected void`
  `populateLocalPort()`
  Populates the cached local port number from the underlying socket.
  `protected void`
  `populateRemoteAddr()`
  Populates the cached remote IP address from the underlying socket.
  `protected void`
  `populateRemoteHost()`
  Populates the cached remote host name from the underlying socket.
  `protected void`
  `populateRemotePort()`
  Populates the cached remote port number from the underlying socket.
  `SendfileState`
  `processSendfile(SendfileDataBase sendfileData)`
  Starts the sendfile process.
  `int`
  `read(boolean block, byte[] b, int off, int len)`
  Reads data from the socket into a byte array.
  `int`
  `read(boolean block, ByteBuffer to)`
  Reads data from the socket into a ByteBuffer.
  `void`
  `registerReadInterest()`
  Registers interest in read events.
  `void`
  `registerWriteInterest()`
  Registers interest in write events.
  `void`
  `setAppReadBufHandler(ApplicationBufferHandler handler)`
  Sets the application-level read buffer handler.
  `void`
  `setBlockingStatus(boolean blockingStatus)`

  ### Methods inherited from class SocketWrapperBase

  `awaitReadComplete, awaitWriteComplete, buffersArrayHasRemaining, canWrite, checkError, decrementKeepAlive, doWrite, execute, flush, flushBlocking, getCurrentProcessor, getEndpoint, getError, getLocalAddr, getLocalName, getLocalPort, getLock, getNegotiatedProtocol, getReadTimeout, getRemoteAddr, getRemoteHost, getRemotePort, getSniHostName, getSocket, getSocketBufferHandler, getWriteTimeout, hasAsyncIO, hasDataToRead, hasDataToWrite, hasPerOperationTimeout, isClosed, isReadPending, isReadyForWrite, isSecure, isUpgraded, isWritePending, needSemaphores, populateReadBuffer, populateReadBuffer, processSocket, read, read, read, reset, setCurrentProcessor, setError, setKeepAliveLeft, setNegotiatedProtocol, setReadTimeout, setSecure, setSniHostName, setUpgraded, setWriteTimeout, takeCurrentProcessor, toString, transfer, transfer, unRead, vectoredOperation, write, write, write, write, write, writeBlocking, writeBlocking, writeNonBlocking, writeNonBlocking, writeNonBlockingInternal`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### AprSocketWrapper

    public AprSocketWrapper(Long socket, AprEndpoint endpoint)

- ## Method Details

  - ### getBlockingStatus

    public boolean getBlockingStatus()

  - ### setBlockingStatus

    public void setBlockingStatus(boolean blockingStatus)

  - ### getBlockingStatusReadLock

    public Lock getBlockingStatusReadLock()

  - ### getBlockingStatusWriteLock

    public ReentrantReadWriteLock.WriteLock getBlockingStatusWriteLock()

  - ### read

    public int read(boolean block, byte[] b, int off, int len) throws IOException
    Description copied from class: `SocketWrapperBase`
    Reads data from the socket into a byte array.
    Specified by:
      `read` in class `SocketWrapperBase<Long>`
    Parameters:
      `block` - Whether to block
      `b` - The byte array to read into
      `off` - The offset in the array
      `len` - The number of bytes to read
    Returns:
      the number of bytes read
    Throws:
      `IOException` - If an I/O error occurs

  - ### read

    public int read(boolean block, ByteBuffer to) throws IOException
    Description copied from class: `SocketWrapperBase`
    Reads data from the socket into a ByteBuffer.
    Specified by:
      `read` in class `SocketWrapperBase<Long>`
    Parameters:
      `block` - Whether to block
      `to` - The ByteBuffer to read into
    Returns:
      the number of bytes read
    Throws:
      `IOException` - If an I/O error occurs

  - ### isReadyForRead

    public boolean isReadyForRead() throws IOException
    Description copied from class: `SocketWrapperBase`
    Checks if the socket is ready for reading.
    Specified by:
      `isReadyForRead` in class `SocketWrapperBase<Long>`
    Returns:
      `true` if data is available to read
    Throws:
      `IOException` - If an I/O error occurs

  - ### close

    public void close()
    Description copied from class: `SocketWrapperBase`
    Close the socket wrapper.
    Overrides:
      `close` in class `SocketWrapperBase<Long>`

  - ### doClose

    protected void doClose()
    Description copied from class: `SocketWrapperBase`
    Perform the actual close. The closed atomic boolean guarantees this will be called only once per wrapper.
    Specified by:
      `doClose` in class `SocketWrapperBase<Long>`

  - ### flushNonBlocking

    protected boolean flushNonBlocking() throws IOException
    Description copied from class: `SocketWrapperBase`
    Flushes remaining buffered data using a non-blocking write.
    Specified by:
      `flushNonBlocking` in class `SocketWrapperBase<Long>`
    Returns:
      `true` if data remains to be flushed after this method completes, otherwise `false`
    Throws:
      `IOException` - If an IO error occurs during the write

  - ### doWrite

    protected void doWrite(boolean block, ByteBuffer from) throws IOException
    Description copied from class: `SocketWrapperBase`
    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.
    Specified by:
      `doWrite` in class `SocketWrapperBase<Long>`
    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

  - ### registerReadInterest

    public void registerReadInterest()
    Description copied from class: `SocketWrapperBase`
    Registers interest in read events.
    Specified by:
      `registerReadInterest` in class `SocketWrapperBase<Long>`

  - ### registerWriteInterest

    public void registerWriteInterest()
    Description copied from class: `SocketWrapperBase`
    Registers interest in write events.
    Specified by:
      `registerWriteInterest` in class `SocketWrapperBase<Long>`

  - ### createSendfileData

    public SendfileDataBase createSendfileData(String filename, long pos, long length)
    Description copied from class: `SocketWrapperBase`
    Creates a sendfile data object for the specified file.
    Specified by:
      `createSendfileData` in class `SocketWrapperBase<Long>`
    Parameters:
      `filename` - The file to send
      `pos` - The starting position in the file
      `length` - The number of bytes to send
    Returns:
      a new sendfile data object

  - ### processSendfile

    public SendfileState processSendfile(SendfileDataBase sendfileData)
    Description copied from class: `SocketWrapperBase`
    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.
    Specified by:
      `processSendfile` in class `SocketWrapperBase<Long>`
    Parameters:
      `sendfileData` - Data representing the file to send
    Returns:
      The state of the sendfile process after the first write.

  - ### populateRemoteAddr

    protected void populateRemoteAddr()
    Description copied from class: `SocketWrapperBase`
    Populates the cached remote IP address from the underlying socket.
    Specified by:
      `populateRemoteAddr` in class `SocketWrapperBase<Long>`

  - ### populateRemoteHost

    protected void populateRemoteHost()
    Description copied from class: `SocketWrapperBase`
    Populates the cached remote host name from the underlying socket.
    Specified by:
      `populateRemoteHost` in class `SocketWrapperBase<Long>`

  - ### populateRemotePort

    protected void populateRemotePort()
    Description copied from class: `SocketWrapperBase`
    Populates the cached remote port number from the underlying socket.
    Specified by:
      `populateRemotePort` in class `SocketWrapperBase<Long>`

  - ### populateLocalName

    protected void populateLocalName()
    Description copied from class: `SocketWrapperBase`
    Populates the cached local host name from the underlying socket.
    Specified by:
      `populateLocalName` in class `SocketWrapperBase<Long>`

  - ### populateLocalAddr

    protected void populateLocalAddr()
    Description copied from class: `SocketWrapperBase`
    Populates the cached local IP address from the underlying socket.
    Specified by:
      `populateLocalAddr` in class `SocketWrapperBase<Long>`

  - ### populateLocalPort

    protected void populateLocalPort()
    Description copied from class: `SocketWrapperBase`
    Populates the cached local port number from the underlying socket.
    Specified by:
      `populateLocalPort` in class `SocketWrapperBase<Long>`

  - ### getSslSupport

    public SSLSupport getSslSupport(String clientCertProvider)
    Description copied from class: `SocketWrapperBase`
    Obtain an SSLSupport instance for this socket.
    Overrides:
      `getSslSupport` in class `SocketWrapperBase<Long>`
    Parameters:
      `clientCertProvider` - The name of the client certificate provider to use. Only used by APR/native.
    Returns:
      An SSLSupport instance for this socket.

  - ### getSslSupport

    public SSLSupport getSslSupport()
    Description copied from class: `SocketWrapperBase`
    Obtain an SSLSupport instance for this socket.
    Specified by:
      `getSslSupport` in class `SocketWrapperBase<Long>`
    Returns:
      An SSLSupport instance for this socket.

  - ### doClientAuth

    public void doClientAuth(SSLSupport sslSupport) throws IOException
    Description copied from class: `SocketWrapperBase`
    Require the client to perform CLIENT-CERT authentication if it hasn't already done so.
    Specified by:
      `doClientAuth` in class `SocketWrapperBase<Long>`
    Parameters:
      `sslSupport` - The SSL/TLS support instance currently being used by the connection that may need updating after the client authentication
    Throws:
      `IOException` - If authentication is required then there will be I/O with the client and this exception will be thrown if that goes wrong

  - ### setAppReadBufHandler

    public void setAppReadBufHandler(ApplicationBufferHandler handler)
    Description copied from class: `SocketWrapperBase`
    Sets the application-level read buffer handler.
    Specified by:
      `setAppReadBufHandler` in class `SocketWrapperBase<Long>`
    Parameters:
      `handler` - The application buffer handler

  - ### newOperationState

    protected <A> SocketWrapperBase<Long>.OperationState<A> newOperationState(boolean read, ByteBuffer[] buffers, int offset, int length, SocketWrapperBase.BlockingMode block, long timeout, TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, CompletionHandler<Long, ? super A> handler, Semaphore semaphore, SocketWrapperBase<Long>.VectoredIOCompletionHandler<A> completion)
    Description copied from class: `SocketWrapperBase`
    Creates a new operation state for vectored I/O operations.
    Specified by:
      `newOperationState` in class `SocketWrapperBase<Long>`
    Type Parameters:
      `A` - The attachment type
    Parameters:
      `read` - Whether this is a read operation
      `buffers` - The buffers for the operation
      `offset` - The offset in the buffer array
      `length` - The number of buffers
      `block` - The blocking mode
      `timeout` - The timeout duration
      `unit` - The timeout time unit
      `attachment` - An attachment object
      `check` - The completion check
      `handler` - The completion handler
      `semaphore` - The semaphore for synchronization
      `completion` - The vectored I/O completion handler
    Returns:
      a new operation state instance