Package org.apache.tomcat.util.net

## Class Nio2Endpoint

- java.lang.Object
- - org.apache.tomcat.util.net.AbstractEndpoint<S,​U>
  - - org.apache.tomcat.util.net.AbstractJsseEndpoint<Nio2Channel,​java.nio.channels.AsynchronousSocketChannel>
    - - org.apache.tomcat.util.net.Nio2Endpoint

-     public class Nio2Endpoint
      extends AbstractJsseEndpoint<Nio2Channel,​java.nio.channels.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 org.apache.tomcat.util.net.AbstractEndpoint

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

  - ### Field Summary

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

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

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Nio2Endpoint()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `bind()` | Initialize the endpoint.
    `protected SocketProcessorBase<Nio2Channel>` | `createSocketProcessor​(SocketWrapperBase<Nio2Channel> socketWrapper, SocketEvent event)` |
    `protected void` | `destroySocket​(java.nio.channels.AsynchronousSocketChannel socket)` | Close the socket.
    `protected void` | `doCloseServerSocket()` | Actually close the server socket but don't perform any other clean-up.
    `static void` | `endInline()` |
    `int` | `getKeepAliveCount()` | Number of keep-alive sockets.
    `protected Log` | `getLog()` |
    `protected SynchronizedStack<Nio2Channel>` | `getNioChannels()` |
    `protected java.nio.channels.NetworkChannel` | `getServerSocket()` |
    `static boolean` | `isInline()` |
    `void` | `resume()` | Resume the endpoint, which will make it start accepting new connections again.
    `protected java.nio.channels.AsynchronousSocketChannel` | `serverSocketAccept()` |
    `protected boolean` | `setSocketOptions​(java.nio.channels.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 org.apache.tomcat.util.net.AbstractJsseEndpoint

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

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

      `addNegotiatedProtocol, addSslHostConfig, addSslHostConfig, awaitConnectionsClose, closeServerSocketGraceful, closeSocket, countDownConnection, countUpOrAwaitConnection, createExecutor, destroy, destroySsl, findSslHostConfigs, getAcceptCount, getAcceptorThreadPriority, getAddress, getAttribute, getBindOnInit, getBindState, getConnectionCount, getConnectionLinger, getConnections, getConnectionTimeout, getCurrentThreadCount, getCurrentThreadsBusy, getDaemon, getDefaultSSLHostConfigName, getDeferAccept, getDomain, getExecutor, getExecutorTerminationTimeoutMillis, getHandler, getId, getKeepAliveTimeout, getLocalPort, getMaxConnections, getMaxKeepAliveRequests, getMaxThreads, getMinSpareThreads, getName, getPort, getPortOffset, getPortWithOffset, getProperty, getSocketProperties, getSSLHostConfig, getTcpNoDelay, getThreadPriority, getUseAsyncIO, getUseSendfile, getUtilityExecutor, hasNegotiableProtocols, init, initializeConnectionLatch, isPaused, isRunning, isSSLEnabled, pause, processSocket, releaseSSLContext, reloadSslHostConfig, reloadSslHostConfigs, removeSslHostConfig, setAcceptCount, setAcceptorThreadPriority, setAddress, setAttribute, setBindOnInit, setConnectionLinger, setConnectionTimeout, setDaemon, setDefaultSSLHostConfigName, setDomain, setExecutor, setExecutorTerminationTimeoutMillis, setHandler, setKeepAliveTimeout, setMaxConnections, setMaxKeepAliveRequests, setMaxThreads, setMinSpareThreads, setName, setPort, setPortOffset, setProperty, setSSLEnabled, setTcpNoDelay, setThreadPriority, setUseAsyncIO, setUseSendfile, setUtilityExecutor, start, 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

    - #### getKeepAliveCount

          public int getKeepAliveCount()

      Number of keep-alive sockets.
      Returns:
        Always returns -1.

    - #### bind

          public void bind()
                    throws java.lang.Exception

      Initialize the endpoint.
      Specified by:
        `bind` in class `AbstractEndpoint<Nio2Channel,​java.nio.channels.AsynchronousSocketChannel>`
      Throws:
        `java.lang.Exception`

    - #### startInternal

          public void startInternal()
                             throws java.lang.Exception

      Start the NIO2 endpoint, creating acceptor.
      Specified by:
        `startInternal` in class `AbstractEndpoint<Nio2Channel,​java.nio.channels.AsynchronousSocketChannel>`
      Throws:
        `java.lang.Exception`

    - #### startAcceptorThread

          protected void startAcceptorThread()

      Overrides:
        `startAcceptorThread` in class `AbstractEndpoint<Nio2Channel,​java.nio.channels.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,​java.nio.channels.AsynchronousSocketChannel>`

    - #### stopInternal

          public void stopInternal()

      Stop the endpoint. This will cause all processing threads to stop.
      Specified by:
        `stopInternal` in class `AbstractEndpoint<Nio2Channel,​java.nio.channels.AsynchronousSocketChannel>`

    - #### unbind

          public void unbind()
                      throws java.lang.Exception

      Deallocate NIO memory pools, and close server socket.
      Overrides:
        `unbind` in class `AbstractJsseEndpoint<Nio2Channel,​java.nio.channels.AsynchronousSocketChannel>`
      Throws:
        `java.lang.Exception`

    - #### doCloseServerSocket

          protected void doCloseServerSocket()
                                      throws java.io.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,​java.nio.channels.AsynchronousSocketChannel>`
      Throws:
        `java.io.IOException` - If an error occurs closing the socket

    - #### shutdownExecutor

          public void shutdownExecutor()

      Overrides:
        `shutdownExecutor` in class `AbstractEndpoint<Nio2Channel,​java.nio.channels.AsynchronousSocketChannel>`

    - #### setSocketOptions

          protected boolean setSocketOptions​(java.nio.channels.AsynchronousSocketChannel socket)

      Process the specified connection.
      Specified by:
        `setSocketOptions` in class `AbstractEndpoint<Nio2Channel,​java.nio.channels.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​(java.nio.channels.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,​java.nio.channels.AsynchronousSocketChannel>`
      Parameters:
        `socket` - The newly accepted socket

    - #### getNioChannels

          protected SynchronizedStack<Nio2Channel> getNioChannels()

    - #### getServerSocket

          protected java.nio.channels.NetworkChannel getServerSocket()

      Specified by:
        `getServerSocket` in class `AbstractJsseEndpoint<Nio2Channel,​java.nio.channels.AsynchronousSocketChannel>`

    - #### serverSocketAccept

          protected java.nio.channels.AsynchronousSocketChannel serverSocketAccept()
                                                                            throws java.lang.Exception

      Specified by:
        `serverSocketAccept` in class `AbstractEndpoint<Nio2Channel,​java.nio.channels.AsynchronousSocketChannel>`
      Throws:
        `java.lang.Exception`

    - #### getLog

          protected Log getLog()

      Specified by:
        `getLog` in class `AbstractEndpoint<Nio2Channel,​java.nio.channels.AsynchronousSocketChannel>`

    - #### createSocketProcessor

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

      Specified by:
        `createSocketProcessor` in class `AbstractEndpoint<Nio2Channel,​java.nio.channels.AsynchronousSocketChannel>`

    - #### startInline

          public static void startInline()

    - #### endInline

          public static void endInline()

    - #### isInline

          public static boolean isInline()