Nio2Endpoint (Apache Tomcat 9.0.117 API Documentation)
Description: declaration: package: org.apache.tomcat.util.net, class: Nio2Endpoint

# Class Nio2Endpoint

java.lang.Object
org.apache.tomcat.util.net.AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>
org.apache.tomcat.util.net.AbstractJsseEndpoint<Nio2Channel, AsynchronousSocketChannel>
org.apache.tomcat.util.net.Nio2Endpoint

public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel, AsynchronousSocketChannel>
NIO2 endpoint.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `protected class`
  `Nio2Endpoint.Nio2Acceptor`
  `static class`
  `Nio2Endpoint.Nio2SocketWrapper`
  `static class`
  `Nio2Endpoint.SendfileData`
  SendfileData class.
  `protected class`
  `Nio2Endpoint.SocketProcessor`
  This class is the equivalent of the Worker, but will simply use in an external Executor thread pool.

  ### Nested classes/interfaces inherited from class AbstractEndpoint

  `AbstractEndpoint.BindState, AbstractEndpoint.Handler<S>`

- ## Field Summary

  ### Fields inherited from class AbstractEndpoint

  `acceptor, acceptorThreadCount, acceptorThreadPriority, attributes, connections, internalExecutor, negotiableProtocols, paused, processorCache, running, sm, socketProperties, sslHostConfigs, threadPriority`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Nio2Endpoint()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `bind()`
  Initialize the endpoint.
  `protected SocketProcessorBase<Nio2Channel>`
  `createSocketProcessor(SocketWrapperBase<Nio2Channel> socketWrapper, SocketEvent event)`
  `protected void`
  `destroySocket(AsynchronousSocketChannel socket)`
  Close the socket.
  `protected void`
  `doCloseServerSocket()`
  Actually close the server socket but don't perform any other clean-up.
  `static void`
  `endInline()`
  `boolean`
  `getDeferAccept()`
  Is deferAccept supported?
  `int`
  `getKeepAliveCount()`
  Number of keep-alive sockets.
  `protected Log`
  `getLog()`
  `protected Log`
  `getLogCertificate()`
  `protected SynchronizedStack<Nio2Channel>`
  `getNioChannels()`
  `protected NetworkChannel`
  `getServerSocket()`
  `static boolean`
  `isInline()`
  `void`
  `resume()`
  Resume the endpoint, which will make it start accepting new connections again.
  `protected AsynchronousSocketChannel`
  `serverSocketAccept()`
  `protected boolean`
  `setSocketOptions(AsynchronousSocketChannel socket)`
  Process the specified connection.
  `void`
  `shutdownExecutor()`
  `protected void`
  `startAcceptorThread()`
  `static void`
  `startInline()`
  `void`
  `startInternal()`
  Start the NIO2 endpoint, creating acceptor.
  `void`
  `stopInternal()`
  Stop the endpoint.
  `void`
  `unbind()`
  Deallocate NIO memory pools, and close server socket.

  ### Methods inherited from class AbstractJsseEndpoint

  `createSSLContext, createSSLEngine, getLocalAddress, getSniParseLimit, getSslImplementation, getSslImplementationName, initialiseSsl, isAlpnSupported, setDefaultSslHostConfig, setSniParseLimit, setSslImplementationName`

  ### Methods inherited from class AbstractEndpoint

  `addNegotiatedProtocol, addSslHostConfig, addSslHostConfig, awaitConnectionsClose, checkSni, closeServerSocketGraceful, closeSocket, countDownConnection, countUpOrAwaitConnection, createExecutor, destroy, destroySsl, findSslHostConfigs, generateCertificateDebug, getAcceptCount, getAcceptorThreadCount, getAcceptorThreadPriority, getAddress, getAttribute, getBindOnInit, getBindState, getConnectionCount, getConnectionLinger, getConnections, getConnectionTimeout, getCurrentThreadCount, getCurrentThreadsBusy, getDaemon, getDefaultSSLHostConfigName, getDomain, getExecutor, getExecutorTerminationTimeoutMillis, getHandler, getId, getKeepAliveTimeout, getLocalPort, getMaxConnections, getMaxKeepAliveRequests, getMaxQueueSize, getMaxThreads, getMinSpareThreads, getName, getPort, getPortOffset, getPortWithOffset, getProperty, getSocketProperties, getSSLHostConfig, getStrictSni, getTcpNoDelay, getThreadPriority, getThreadsMaxIdleTime, getUseAsyncIO, getUseSendfile, getUseVirtualThreads, getUtilityExecutor, hasNegotiableProtocols, init, initializeConnectionLatch, isPaused, isRunning, isSSLEnabled, logCertificate, pause, processSocket, releaseSSLContext, reloadSslHostConfig, reloadSslHostConfigs, removeSslHostConfig, setAcceptCount, setAcceptorThreadCount, setAcceptorThreadPriority, setAddress, setAttribute, setBindOnInit, setConnectionLinger, setConnectionTimeout, setDaemon, setDefaultSSLHostConfigName, setDomain, setExecutor, setExecutorTerminationTimeoutMillis, setHandler, setKeepAliveTimeout, setMaxConnections, setMaxKeepAliveRequests, setMaxQueueSize, setMaxThreads, setMinSpareThreads, setName, setPort, setPortOffset, setProperty, setSSLEnabled, setStrictSni, setTcpNoDelay, setThreadPriority, setThreadsMaxIdleTime, setUseAsyncIO, setUseSendfile, setUseVirtualThreads, setUtilityExecutor, start, stop, toTimeout, unlockAccept`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### Nio2Endpoint

    public Nio2Endpoint()

- ## Method Details

  - ### getDeferAccept

    public boolean getDeferAccept()
    Is deferAccept supported?
    Specified by:
      `getDeferAccept` in class `AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>`

  - ### getKeepAliveCount

    public int getKeepAliveCount()
    Number of keep-alive sockets.
    Returns:
      Always returns -1.

  - ### bind

    public void bind() throws Exception
    Initialize the endpoint.
    Specified by:
      `bind` in class `AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>`
    Throws:
      `Exception`

  - ### startInternal

    public void startInternal() throws Exception
    Start the NIO2 endpoint, creating acceptor.
    Specified by:
      `startInternal` in class `AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>`
    Throws:
      `Exception`

  - ### startAcceptorThread

    protected void startAcceptorThread()
    Overrides:
      `startAcceptorThread` in class `AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>`

  - ### resume

    public void resume()
    Description copied from class: `AbstractEndpoint`
    Resume the endpoint, which will make it start accepting new connections again.
    Overrides:
      `resume` in class `AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>`

  - ### stopInternal

    public void stopInternal()
    Stop the endpoint. This will cause all processing threads to stop.
    Specified by:
      `stopInternal` in class `AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>`

  - ### unbind

    public void unbind() throws Exception
    Deallocate NIO memory pools, and close server socket.
    Overrides:
      `unbind` in class `AbstractJsseEndpoint<Nio2Channel, AsynchronousSocketChannel>`
    Throws:
      `Exception`

  - ### doCloseServerSocket

    protected void doCloseServerSocket() throws IOException
    Description copied from class: `AbstractEndpoint`
    Actually close the server socket but don't perform any other clean-up.
    Specified by:
      `doCloseServerSocket` in class `AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>`
    Throws:
      `IOException` - If an error occurs closing the socket

  - ### shutdownExecutor

    public void shutdownExecutor()
    Overrides:
      `shutdownExecutor` in class `AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>`

  - ### setSocketOptions

    protected boolean setSocketOptions(AsynchronousSocketChannel socket)
    Process the specified connection.
    Specified by:
      `setSocketOptions` in class `AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>`
    Parameters:
      `socket` - The socket channel
    Returns:
      `true` if the socket was correctly configured and processing may continue, `false` if the socket needs to be close immediately

  - ### destroySocket

    protected void destroySocket(AsynchronousSocketChannel socket)
    Description copied from class: `AbstractEndpoint`
    Close the socket. This is used when the connector is not in a state which allows processing the socket, or if there was an error which prevented the allocation of the socket wrapper.
    Specified by:
      `destroySocket` in class `AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>`
    Parameters:
      `socket` - The newly accepted socket

  - ### getNioChannels

    protected SynchronizedStack<Nio2Channel> getNioChannels()

  - ### getServerSocket

    protected NetworkChannel getServerSocket()
    Specified by:
      `getServerSocket` in class `AbstractJsseEndpoint<Nio2Channel, AsynchronousSocketChannel>`

  - ### serverSocketAccept

    protected AsynchronousSocketChannel serverSocketAccept() throws Exception
    Specified by:
      `serverSocketAccept` in class `AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>`
    Throws:
      `Exception`

  - ### getLog

    protected Log getLog()
    Specified by:
      `getLog` in class `AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>`

  - ### getLogCertificate

    protected Log getLogCertificate()
    Overrides:
      `getLogCertificate` in class `AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>`

  - ### createSocketProcessor

    protected SocketProcessorBase<Nio2Channel> createSocketProcessor(SocketWrapperBase<Nio2Channel> socketWrapper, SocketEvent event)
    Specified by:
      `createSocketProcessor` in class `AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>`

  - ### startInline

    public static void startInline()

  - ### endInline

    public static void endInline()

  - ### isInline

    public static boolean isInline()