org.apache.tomcat.util.net

## Class Nio2Endpoint

- java.lang.Object
- - org.apache.tomcat.util.net.AbstractEndpoint<S>
  - - org.apache.tomcat.util.net.AbstractJsseEndpoint<Nio2Channel>
    - - org.apache.tomcat.util.net.Nio2Endpoint

-     public class Nio2Endpoint
      extends AbstractJsseEndpoint<Nio2Channel>

  NIO2 endpoint.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `Nio2Endpoint.Acceptor` With NIO2, the main acceptor thread only initiates the initial accept but periodically checks that the connector is still accepting (if not it will attempt to start again).
    `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 org.apache.tomcat.util.net.AbstractEndpoint

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

  - ### Field Summary

    - ### Fields inherited from class org.apache.tomcat.util.net.AbstractEndpoint

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

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Nio2Endpoint()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `bind()` Initialize the endpoint.
    `protected AbstractEndpoint.Acceptor` | `createAcceptor()` Hook to allow Endpoints to provide a specific Acceptor implementation.
    `protected SocketProcessorBase<Nio2Channel>` | `createSocketProcessor(SocketWrapperBase<Nio2Channel> socketWrapper, SocketEvent event)`
    `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()`
    `int` | `getReadBufSize()`
    `protected NetworkChannel` | `getServerSocket()`
    `int` | `getWriteBufSize()`
    `static boolean` | `isInline()`
    `protected boolean` | `setSocketOptions(AsynchronousSocketChannel socket)` Process the specified connection.
    `void` | `setSocketProperties(SocketProperties socketProperties)`
    `void` | `shutdownExecutor()`
    `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 org.apache.tomcat.util.net.AbstractJsseEndpoint

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

    - ### Methods inherited from class org.apache.tomcat.util.net.AbstractEndpoint

      `addNegotiatedProtocol, addSslHostConfig, addSslHostConfig, closeServerSocketGraceful, countDownConnection, countUpOrAwaitConnection, createExecutor, destroy, destroySsl, findSslHostConfigs, getAcceptCount, getAcceptorThreadCount, getAcceptorThreadPriority, getAddress, getAttribute, getBacklog, getBindOnInit, getConnectionCount, getConnectionLinger, getConnectionTimeout, getCurrentThreadCount, getCurrentThreadsBusy, getDaemon, getDefaultSSLHostConfigName, getDomain, getExecutor, getExecutorTerminationTimeoutMillis, getHandler, getKeepAliveTimeout, getLocalPort, getMaxConnections, getMaxHeaderCount, getMaxKeepAliveRequests, getMaxThreads, getMinSpareThreads, getName, getPort, getProperty, getSocketProperties, getSoLinger, getSoTimeout, getSSLHostConfig, getTcpNoDelay, getThreadPriority, getUseAsyncIO, getUseSendfile, handleExceptionWithDelay, hasNegotiableProtocols, initializeConnectionLatch, isPaused, isRunning, isSSLEnabled, pause, processSocket, releaseConnectionLatch, releaseSSLContext, reloadSslHostConfig, reloadSslHostConfigs, removeSslHostConfig, resume, setAcceptCount, setAcceptorThreadCount, setAcceptorThreadPriority, setAddress, setAttribute, setBacklog, setBindOnInit, setConnectionLinger, setConnectionTimeout, setDaemon, setDefaultSSLHostConfigName, setDomain, setExecutor, setExecutorTerminationTimeoutMillis, setHandler, setKeepAliveTimeout, setMaxConnections, setMaxHeaderCount, setMaxKeepAliveRequests, setMaxThreads, setMinSpareThreads, setName, setPort, setProperty, setSoLinger, setSoTimeout, setSSLEnabled, setTcpNoDelay, setThreadPriority, setUseAsyncIO, setUseSendfile, start, startAcceptorThreads, stop, toTimeout, unlockAccept`

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

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

- - ### Constructor Detail

    - #### Nio2Endpoint

          public Nio2Endpoint()

  - ### Method Detail

    - #### setSocketProperties

          public void setSocketProperties(SocketProperties socketProperties)

    - #### getDeferAccept

          public boolean getDeferAccept()

      Is deferAccept supported?
      Specified by:
        `getDeferAccept` in class `AbstractEndpoint<Nio2Channel>`

    - #### 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>`
      Throws:
        `Exception`

    - #### startInternal

          public void startInternal()
                             throws Exception

      Start the NIO2 endpoint, creating acceptor.
      Specified by:
        `startInternal` in class `AbstractEndpoint<Nio2Channel>`
      Throws:
        `Exception`

    - #### stopInternal

          public void stopInternal()

      Stop the endpoint. This will cause all processing threads to stop.
      Specified by:
        `stopInternal` in class `AbstractEndpoint<Nio2Channel>`

    - #### unbind

          public void unbind()
                      throws Exception

      Deallocate NIO memory pools, and close server socket.
      Overrides:
        `unbind` in class `AbstractJsseEndpoint<Nio2Channel>`
      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>`
      Throws:
        `IOException` - If an error occurs closing the socket

    - #### shutdownExecutor

          public void shutdownExecutor()

      Overrides:
        `shutdownExecutor` in class `AbstractEndpoint<Nio2Channel>`

    - #### getWriteBufSize

          public int getWriteBufSize()

    - #### getReadBufSize

          public int getReadBufSize()

    - #### createAcceptor

          protected AbstractEndpoint.Acceptor createAcceptor()

      Description copied from class: `AbstractEndpoint`
      Hook to allow Endpoints to provide a specific Acceptor implementation.
      Specified by:
        `createAcceptor` in class `AbstractEndpoint<Nio2Channel>`
      Returns:
        the acceptor

    - #### setSocketOptions

          protected boolean setSocketOptions(AsynchronousSocketChannel socket)

      Process the specified connection.
      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

    - #### createSocketProcessor

          protected SocketProcessorBase<Nio2Channel> createSocketProcessor(SocketWrapperBase<Nio2Channel> socketWrapper,
                                                               SocketEvent event)

      Specified by:
        `createSocketProcessor` in class `AbstractEndpoint<Nio2Channel>`

    - #### getLog

          protected Log getLog()

      Specified by:
        `getLog` in class `AbstractEndpoint<Nio2Channel>`

    - #### getServerSocket

          protected NetworkChannel getServerSocket()

      Specified by:
        `getServerSocket` in class `AbstractJsseEndpoint<Nio2Channel>`

    - #### startInline

          public static void startInline()

    - #### endInline

          public static void endInline()

    - #### isInline

          public static boolean isInline()

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