# Class AbstractEndpoint<S,U>

java.lang.Object
org.apache.tomcat.util.net.AbstractEndpoint<S,U>

Type Parameters:
  `S` - The type used by the socket wrapper associated with this endpoint. Might be the same as U.
  `U` - The type of the underlying socket used by this endpoint. Might be the same as S.

Direct Known Subclasses:
  `AbstractNetworkChannelEndpoint`

public abstract class AbstractEndpoint<S,U> extends Object
Abstract endpoint implementation.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`protected static enum`
`AbstractEndpoint.BindState`
Enum representing the possible states of the bind operation.
`static interface`
`AbstractEndpoint.Handler<S>`
Interface for handlers used by an endpoint.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected Acceptor<U>`
`acceptor`
Thread used to accept new connections and pass them to worker threads.
`protected int`
`acceptorThreadPriority`
Priority of the acceptor threads.
`protected HashMap<String,Object>`
`attributes`
Attributes provide a way for configuration to be passed to subcomponents without the `ProtocolHandler` being aware of the properties available on those subcomponents.
`protected Map<U, SocketWrapperBase<S>>`
`connections`
Map holding all current connections keyed with the sockets.
`protected boolean`
`internalExecutor`
Are we using an internal executor
`protected final List<String>`
`negotiableProtocols`
List of protocols that can be negotiated (e.g.
`protected boolean`
`paused`
Will be set to true whenever the endpoint is paused.
`protected SynchronizedStack<SocketProcessorBase<S>>`
`processorCache`
Cache for SocketProcessor objects
`protected boolean`
`running`
Running state of the endpoint.
`protected static final StringManager`
`sm`
String manager for this package.
`protected final SocketProperties`
`socketProperties`
Socket properties
`protected ConcurrentMap<String, SSLHostConfig>`
`sslHostConfigs`
Map of SSL host configurations keyed by host name.
`protected int`
`threadPriority`
Priority of the worker threads.

## Constructor Summary

Constructors
Constructor
Description
`AbstractEndpoint()`
Construct and return an endpoint.

## Method Summary

Modifier and Type
Method
Description
`void`
`addNegotiatedProtocol(String negotiableProtocol)`
Add a protocol that can be negotiated (e.g.
`void`
`addSslHostConfig(SSLHostConfig sslHostConfig)`
Add the given SSL Host configuration.
`void`
`addSslHostConfig(SSLHostConfig sslHostConfig, boolean replace)`
Add the given SSL Host configuration, optionally replacing the existing configuration for the given host.
`final long`
`awaitConnectionsClose(long waitMillis)`
Wait for the client connections to the server to close gracefully.
`abstract void`
`bind()`
Bind the endpoint to its port and address.
`boolean`
`checkSni(String sniHostName, String protocolHostName)`
Check if two host names share the same SSLHostConfig.
`final void`
`closeServerSocketGraceful()`
Close the server socket (to prevent further connections) if the server socket was originally bound on `start()` (rather than on `init()`).
`protected void`
`closeSocket(U socket)`
Close the socket when the connection has to be immediately closed when an error occurs while configuring the accepted socket or trying to dispatch it for processing.
`protected long`
`countDownConnection()`
Count down a connection.
`protected void`
`countUpOrAwaitConnection()`
Count up or await a connection slot.
`void`
`createExecutor()`
Create the internal executor.
`protected abstract SocketProcessorBase<S>`
`createSocketProcessor(SocketWrapperBase<S> socketWrapper, SocketEvent event)`
Create a socket processor for the given socket wrapper.
`protected void`
`createSSLContext(SSLHostConfig sslHostConfig)`
Create the SSLContext for the given SSLHostConfig.
`protected SSLEngine`
`createSSLEngine(String sniHostName, List<Cipher> clientRequestedCiphers, List<String> clientRequestedApplicationProtocols, List<String> clientRequestedProtocols, List<Group> clientSupportedGroups, List<SignatureScheme> clientSignatureSchemes)`
Create an SSLEngine for the given SNI host name.
`final void`
`destroy()`
Destroy the endpoint and release all resources.
`protected abstract void`
`destroySocket(U socket)`
Close the socket.
`protected void`
`destroySsl()`
Destroy the SSL configuration.
`protected abstract void`
`doCloseServerSocket()`
Actually close the server socket but don't perform any other clean-up.
`SSLHostConfig[]`
`findSslHostConfigs()`
Find all SSL host configurations.
`protected String`
`generateCertificateDebug(X509Certificate certificate)`
Generate debug information about a certificate.
`int`
`getAcceptCount()`
Get the accept count.
`int`
`getAcceptorThreadPriority()`
Get the acceptor thread priority.
`InetAddress`
`getAddress()`
Get the bind address.
`Object`
`getAttribute(String key)`
Used by subcomponents to retrieve configuration information.
`boolean`
`getBindOnInit()`
Get the bind on init flag.
`protected AbstractEndpoint.BindState`
`getBindState()`
Get the current bind state.
`long`
`getConnectionCount()`
Return the current count of connections handled by this endpoint, if the connections are counted (which happens when the maximum count of connections is limited), or `-1` if they are not.
`int`
`getConnectionLinger()`
Socket linger.
`Set<SocketWrapperBase<S>>`
`getConnections()`
Get a set with the current open connections.
`int`
`getConnectionTimeout()`
Socket timeout.
`int`
`getCurrentThreadCount()`
Return the amount of threads that are managed by the pool.
`int`
`getCurrentThreadsBusy()`
Return the amount of threads that are in use
`boolean`
`getDaemon()`
Check if the threads are daemon threads.
`String`
`getDefaultSSLHostConfigName()`
Get the host name for the default SSL configuration for this endpoint - always in lower case.
`String`
`getDomain()`
Get the JMX domain.
`Executor`
`getExecutor()`
Get the external executor.
`long`
`getExecutorTerminationTimeoutMillis()`
Get the executor termination timeout.
`AbstractEndpoint.Handler<S>`
`getHandler()`
Get the handler.
`String`
`getId()`
The default behavior is to identify connectors uniquely with address and port.
`int`
`getKeepAliveTimeout()`
Get the keepalive timeout.
`protected abstract InetSocketAddress`
`getLocalAddress()`
Obtain the network address the server socket is bound to.
`final int`
`getLocalPort()`
Get the local port the server socket is bound to.
`protected abstract Log`
`getLog()`
Get the logger for this endpoint.
`protected Log`
`getLogCertificate()`
Get the logger for certificate-related messages.
`int`
`getMaxConnections()`
Get the maximum number of connections.
`int`
`getMaxKeepAliveRequests()`
Get the maximum number of keep alive requests.
`int`
`getMaxQueueSize()`
Get the maximum queue size.
`int`
`getMaxThreads()`
Get the maximum number of worker threads.
`int`
`getMinSpareThreads()`
Get the minimum number of spare threads.
`String`
`getName()`
Get the name of the thread pool.
`int`
`getPort()`
Get the server socket port.
`int`
`getPortOffset()`
Get the port offset.
`int`
`getPortWithOffset()`
Get the port with offset applied.
`String`
`getProperty(String name)`
Get the value of the specified property.
`int`
`getSniParseLimit()`
Get the SNI parse limit.
`SocketProperties`
`getSocketProperties()`
Get the socket properties.
`protected SSLHostConfig`
`getSSLHostConfig(String sniHostName)`
Look up the SSLHostConfig for the given host name.
`SSLImplementation`
`getSslImplementation()`
Get the SSL implementation.
`String`
`getSslImplementationName()`
Get the name of the SSL implementation class.
`boolean`
`getStrictSni()`
Get the strict SNI check flag.
`boolean`
`getTcpNoDelay()`
Socket TCP no delay.
`int`
`getThreadPriority()`
Get the priority of the worker threads.
`int`
`getThreadsMaxIdleTime()`
Get the maximum idle time for threads in the internal thread pool.
`boolean`
`getUseAsyncIO()`
Check if asynchronous IO is enabled.
`boolean`
`getUseSendfile()`
Get the sendfile flag.
`boolean`
`getUseVirtualThreads()`
Get whether virtual threads are enabled.
`ScheduledExecutorService`
`getUtilityExecutor()`
Get the utility executor.
`boolean`
`hasNegotiableProtocols()`
Check if there are any negotiable protocols configured.
`final void`
`init()`
Initialize the endpoint.
`protected void`
`initialiseSsl()`
Initialise the SSL configuration.
`protected LimitLatch`
`initializeConnectionLatch()`
Initialize the connection latch if it has not already been created.
`boolean`
`isPaused()`
Check if the endpoint is paused.
`boolean`
`isRunning()`
Check if the endpoint is running.
`boolean`
`isSSLEnabled()`
Check if SSL is enabled.
`protected void`
`logCertificate(SSLHostConfigCertificate certificate)`
Log information about the given certificate.
`void`
`pause()`
Pause the endpoint, which will stop it accepting new connections and unlock the acceptor.
`boolean`
`processSocket(SocketWrapperBase<S> socketWrapper, SocketEvent event, boolean dispatch)`
Process the given SocketWrapper with the given status.
`protected void`
`releaseSSLContext(SSLHostConfig sslHostConfig)`
Release the SSLContext, if any, associated with the SSLHostConfig.
`void`
`reloadSslHostConfig(String hostName)`
Re-read the configuration files for the SSL host and replace the existing SSL configuration with the updated settings.
`void`
`reloadSslHostConfigs()`
Re-read the configuration files for all SSL hosts and replace the existing SSL configuration with the updated settings.
`SSLHostConfig`
`removeSslHostConfig(String hostName)`
Removes the SSL host configuration for the given host name, if such a configuration exists.
`void`
`resume()`
Resume the endpoint, which will make it start accepting new connections again.
`protected abstract U`
`serverSocketAccept()`
Accept a connection from the server socket.
`void`
`setAcceptCount(int acceptCount)`
Set the accept count.
`void`
`setAcceptorThreadPriority(int acceptorThreadPriority)`
Set the acceptor thread priority.
`void`
`setAddress(InetAddress address)`
Set the bind address.
`void`
`setAttribute(String name, Object value)`
Generic property setter called when a property for which a specific setter already exists within the `ProtocolHandler` needs to be made available to subcomponents.
`void`
`setBindOnInit(boolean b)`
Set the bind on init flag.
`void`
`setConnectionLinger(int connectionLinger)`
Set the connection linger time.
`void`
`setConnectionTimeout(int soTimeout)`
Set the connection timeout.
`void`
`setDaemon(boolean b)`
Set whether the threads should be daemon threads.
`void`
`setDefaultSSLHostConfigName(String defaultSSLHostConfigName)`
Set the host name for the default SSL configuration.
`void`
`setDomain(String domain)`
Set the domain for JMX registration.
`void`
`setExecutor(Executor executor)`
Set the external executor.
`void`
`setExecutorTerminationTimeoutMillis(long executorTerminationTimeoutMillis)`
Set the executor termination timeout.
`void`
`setHandler(AbstractEndpoint.Handler<S> handler)`
Set the handler for this endpoint.
`void`
`setKeepAliveTimeout(int keepAliveTimeout)`
Set the keepalive timeout.
`void`
`setMaxConnections(int maxCon)`
Set the maximum number of connections.
`void`
`setMaxKeepAliveRequests(int maxKeepAliveRequests)`
Set the maximum number of keep alive requests.
`void`
`setMaxQueueSize(int maxQueueSize)`
Set the maximum task queue size.
`void`
`setMaxThreads(int maxThreads)`
Set the maximum number of worker threads.
`void`
`setMinSpareThreads(int minSpareThreads)`
Set the minimum number of spare threads.
`void`
`setName(String name)`
Set the name of the thread pool.
`void`
`setPort(int port)`
Set the server socket port.
`void`
`setPortOffset(int portOffset)`
Set the port offset.
`boolean`
`setProperty(String name, String value)`
Set the specified property.
`void`
`setSniParseLimit(int sniParseLimit)`
Set the SNI parse limit.
`protected abstract boolean`
`setSocketOptions(U socket)`
Set the socket options for the given accepted socket.
`void`
`setSSLEnabled(boolean SSLEnabled)`
Set the SSL enabled flag.
`void`
`setSslImplementationName(String s)`
Set the name of the SSL implementation class.
`void`
`setStrictSni(boolean strictSni)`
Set the strict SNI check flag.
`void`
`setTcpNoDelay(boolean tcpNoDelay)`
Set the TCP no delay flag.
`void`
`setThreadPriority(int threadPriority)`
Set the priority of the worker threads.
`void`
`setThreadsMaxIdleTime(int threadsMaxIdleTime)`
Set the maximum idle time for threads in the internal thread pool.
`void`
`setUseAsyncIO(boolean useAsyncIO)`
Set whether asynchronous IO is enabled.
`void`
`setUseSendfile(boolean useSendfile)`
Set the sendfile flag.
`void`
`setUseVirtualThreads(boolean useVirtualThreads)`
Set whether virtual threads should be used.
`void`
`setUtilityExecutor(ScheduledExecutorService utilityExecutor)`
Set the utility executor.
`void`
`shutdownExecutor()`
Shutdown the internal executor.
`final void`
`start()`
Start the endpoint.
`protected void`
`startAcceptorThread()`
Start the acceptor thread.
`abstract void`
`startInternal()`
Start the endpoint internal components.
`final void`
`stop()`
Stop the endpoint.
`abstract void`
`stopInternal()`
Stop the endpoint internal components.
`static long`
`toTimeout(long timeout)`
Convert a timeout value to a positive timeout suitable for use with socket operations.
`void`
`unbind()`
Unbind the endpoint from its port and address.
`protected void`
`unlockAccept()`
Unlock the server socket acceptor threads using bogus connections.

### Methods inherited from class Object

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

## Field Details

### sm

protected static final StringManager sm
String manager for this package.

### running

protected volatile boolean running
Running state of the endpoint.

### paused

protected volatile boolean paused
Will be set to true whenever the endpoint is paused.

### internalExecutor

protected volatile boolean internalExecutor
Are we using an internal executor

### socketProperties

protected final SocketProperties socketProperties
Socket properties

### acceptor

protected Acceptor<U> acceptor
Thread used to accept new connections and pass them to worker threads.

### processorCache

protected SynchronizedStack<SocketProcessorBase<S>> processorCache
Cache for SocketProcessor objects

### connections

protected Map<U, SocketWrapperBase<S>> connections
Map holding all current connections keyed with the sockets.

### sslHostConfigs

protected ConcurrentMap<String, SSLHostConfig> sslHostConfigs
Map of SSL host configurations keyed by host name.

### acceptorThreadPriority

protected int acceptorThreadPriority
Priority of the acceptor threads.

### threadPriority

protected int threadPriority
Priority of the worker threads.

### negotiableProtocols

protected final List<String> negotiableProtocols
List of protocols that can be negotiated (e.g. ALPN).

### attributes

protected HashMap<String,Object> attributes
Attributes provide a way for configuration to be passed to subcomponents without the `ProtocolHandler` being aware of the properties available on those subcomponents.

## Constructor Details

### AbstractEndpoint

public AbstractEndpoint()
Construct and return an endpoint.

## Method Details

### toTimeout

public static long toTimeout(long timeout)
Convert a timeout value to a positive timeout suitable for use with socket operations.

Parameters:
  `timeout` - The timeout value in milliseconds. If less than or equal to 0, returns `Long.MAX_VALUE`.
Returns:
  The timeout value, or `Long.MAX_VALUE` if the input is less than or equal to 0

### getSocketProperties

public SocketProperties getSocketProperties()
Get the socket properties.

Returns:
  The socket properties

### getConnections

public Set<SocketWrapperBase<S>> getConnections()
Get a set with the current open connections.

Returns:
  A set with the open socket wrappers

### getSslImplementation

public SSLImplementation getSslImplementation()
Get the SSL implementation.

Returns:
  The SSL implementation

### getSslImplementationName

public String getSslImplementationName()
Get the name of the SSL implementation class.

Returns:
  The SSL implementation class name

### setSslImplementationName

public void setSslImplementationName(String s)
Set the name of the SSL implementation class.

Parameters:
  `s` - The SSL implementation class name

### getSniParseLimit

public int getSniParseLimit()
Get the SNI parse limit.

Returns:
  The SNI parse limit in bytes

### setSniParseLimit

public void setSniParseLimit(int sniParseLimit)
Set the SNI parse limit.

Parameters:
  `sniParseLimit` - The SNI parse limit in bytes

### getStrictSni

public boolean getStrictSni()
Get the strict SNI check flag.

Returns:
  True if strict SNI checking is enabled

### setStrictSni

public void setStrictSni(boolean strictSni)
Set the strict SNI check flag.

Parameters:
  `strictSni` - True to enable strict SNI checking

### getDefaultSSLHostConfigName

public String getDefaultSSLHostConfigName()
Get the host name for the default SSL configuration for this endpoint - always in lower case.

Returns:
  The host name for the default SSL configuration for this endpoint - always in lower case.

### setDefaultSSLHostConfigName

public void setDefaultSSLHostConfigName(String defaultSSLHostConfigName)
Set the host name for the default SSL configuration.

Parameters:
  `defaultSSLHostConfigName` - The default SSL host configuration name

### addSslHostConfig

public void addSslHostConfig(SSLHostConfig sslHostConfig) throws IllegalArgumentException
Add the given SSL Host configuration.

Parameters:
  `sslHostConfig` - The configuration to add
Throws:
  `IllegalArgumentException` - If the host name is not valid or if a configuration has already been provided for that host

### addSslHostConfig

public void addSslHostConfig(SSLHostConfig sslHostConfig, boolean replace) throws IllegalArgumentException
Add the given SSL Host configuration, optionally replacing the existing configuration for the given host.

Parameters:
  `sslHostConfig` - The configuration to add
  `replace` - If `true` replacement of an existing configuration is permitted, otherwise any such attempted replacement will trigger an exception
Throws:
  `IllegalArgumentException` - If the host name is not valid or if a configuration has already been provided for that host and replacement is not allowed

### removeSslHostConfig

public SSLHostConfig removeSslHostConfig(String hostName)
Removes the SSL host configuration for the given host name, if such a configuration exists.

Parameters:
  `hostName` - The host name associated with the SSL host configuration to remove
Returns:
  The SSL host configuration that was removed, if any

### reloadSslHostConfig

public void reloadSslHostConfig(String hostName)
Re-read the configuration files for the SSL host and replace the existing SSL configuration with the updated settings. Note this replacement will happen even if the settings remain unchanged.

Parameters:
  `hostName` - The SSL host for which the configuration should be reloaded. This must match a current SSL host

### reloadSslHostConfigs

public void reloadSslHostConfigs()
Re-read the configuration files for all SSL hosts and replace the existing SSL configuration with the updated settings. Note this replacement will happen even if the settings remain unchanged.

### findSslHostConfigs

public SSLHostConfig[] findSslHostConfigs()
Find all SSL host configurations.

Returns:
  An array of all SSL host configurations

### createSSLContext

protected void createSSLContext(SSLHostConfig sslHostConfig) throws IllegalArgumentException
Create the SSLContext for the given SSLHostConfig.

Parameters:
  `sslHostConfig` - The SSLHostConfig for which the SSLContext should be created
Throws:
  `IllegalArgumentException` - If the SSLContext cannot be created for the given SSLHostConfig

### logCertificate

protected void logCertificate(SSLHostConfigCertificate certificate)
Log information about the given certificate.

Parameters:
  `certificate` - The certificate to log information about

### generateCertificateDebug

protected String generateCertificateDebug(X509Certificate certificate)
Generate debug information about a certificate.

Parameters:
  `certificate` - The certificate to generate debug info for
Returns:
  A string containing certificate debug information

### createSSLEngine

protected SSLEngine createSSLEngine(String sniHostName, List<Cipher> clientRequestedCiphers, List<String> clientRequestedApplicationProtocols, List<String> clientRequestedProtocols, List<Group> clientSupportedGroups, List<SignatureScheme> clientSignatureSchemes)
Create an SSLEngine for the given SNI host name.

Parameters:
  `sniHostName` - The SNI host name
  `clientRequestedCiphers` - The ciphers requested by the client
  `clientRequestedApplicationProtocols` - The application protocols requested by the client
  `clientRequestedProtocols` - The protocols requested by the client
  `clientSupportedGroups` - The groups supported by the client
  `clientSignatureSchemes` - The signature schemes supported by the client
Returns:
  The created SSLEngine

### initialiseSsl

protected void initialiseSsl() throws Exception
Initialise the SSL configuration.

Throws:
  `Exception` - If an error occurs while initializing SSL

### destroySsl

protected void destroySsl() throws Exception
Destroy the SSL configuration.

Throws:
  `Exception` - If an error occurs while destroying SSL

### releaseSSLContext

protected void releaseSSLContext(SSLHostConfig sslHostConfig)
Release the SSLContext, if any, associated with the SSLHostConfig.

Parameters:
  `sslHostConfig` - The SSLHostConfig for which the SSLContext should be released

### getSSLHostConfig

protected SSLHostConfig getSSLHostConfig(String sniHostName)
Look up the SSLHostConfig for the given host name. Lookup order is:

1. exact match
2. wild card match
3. default SSLHostConfig

Parameters:
  `sniHostName` - Host name - must be in lower case
Returns:
  The SSLHostConfig for the given host name.

### checkSni

public boolean checkSni(String sniHostName, String protocolHostName)
Check if two host names share the same SSLHostConfig.

Parameters:
  `sniHostName` - the host name from SNI, null if SNI is not in use
  `protocolHostName` - the host name from the protocol
Returns:
  true if SNI is not checked, if the SNI host name matches the protocol host name, if both host names use the same SSLHostConfig configuration, if there is no SNI and the protocol host name uses the default SSLHostConfig configuration, and false otherwise

### getUseSendfile

public boolean getUseSendfile()
Get the sendfile flag.

Returns:
  True if sendfile is enabled

### setUseSendfile

public void setUseSendfile(boolean useSendfile)
Set the sendfile flag.

Parameters:
  `useSendfile` - True to enable sendfile

### getExecutorTerminationTimeoutMillis

public long getExecutorTerminationTimeoutMillis()
Get the executor termination timeout.

Returns:
  The executor termination timeout in milliseconds

### setExecutorTerminationTimeoutMillis

public void setExecutorTerminationTimeoutMillis(long executorTerminationTimeoutMillis)
Set the executor termination timeout.

Parameters:
  `executorTerminationTimeoutMillis` - The timeout in milliseconds

### setAcceptorThreadPriority

public void setAcceptorThreadPriority(int acceptorThreadPriority)
Set the acceptor thread priority.

Parameters:
  `acceptorThreadPriority` - The thread priority

### getAcceptorThreadPriority

public int getAcceptorThreadPriority()
Get the acceptor thread priority.

Returns:
  The acceptor thread priority

### setMaxConnections

public void setMaxConnections(int maxCon)
Set the maximum number of connections.

Parameters:
  `maxCon` - The maximum number of connections (-1 for unlimited)

### getMaxConnections

public int getMaxConnections()
Get the maximum number of connections.

Returns:
  The maximum number of connections

### getConnectionCount

public long getConnectionCount()
Return the current count of connections handled by this endpoint, if the connections are counted (which happens when the maximum count of connections is limited), or `-1` if they are not. This property is added here so that this value can be inspected through JMX. It is visible on "ThreadPool" MBean.

The count is incremented by the Acceptor before it tries to accept a new connection. Until the limit is reached and thus the count cannot be incremented, this value is more by 1 (the count of acceptors) than the actual count of connections that are being served.

Returns:
  The count

### setExecutor

public void setExecutor(Executor executor)
Set the external executor.

Parameters:
  `executor` - The external executor (null to use internal executor)

### getExecutor

public Executor getExecutor()
Get the external executor.

Returns:
  The external executor, or null if none is configured

### setUseVirtualThreads

public void setUseVirtualThreads(boolean useVirtualThreads)
Set whether virtual threads should be used.

Parameters:
  `useVirtualThreads` - True to use virtual threads

### getUseVirtualThreads

public boolean getUseVirtualThreads()
Get whether virtual threads are enabled.

Returns:
  True if virtual threads are enabled

### setUtilityExecutor

public void setUtilityExecutor(ScheduledExecutorService utilityExecutor)
Set the utility executor.

Parameters:
  `utilityExecutor` - The utility executor

### getUtilityExecutor

public ScheduledExecutorService getUtilityExecutor()
Get the utility executor.

Returns:
  The utility executor

### getPort

public int getPort()
Get the server socket port.

Returns:
  The server socket port

### setPort

public void setPort(int port)
Set the server socket port.

Parameters:
  `port` - The server socket port

### getPortOffset

public int getPortOffset()
Get the port offset.

Returns:
  The port offset

### setPortOffset

public void setPortOffset(int portOffset)
Set the port offset.

Parameters:
  `portOffset` - The port offset (must be >= 0)

### getPortWithOffset

public int getPortWithOffset()
Get the port with offset applied.

Returns:
  The port with offset, or the port if port <= 0

### getLocalPort

public final int getLocalPort()
Get the local port the server socket is bound to.

Returns:
  The local port or -1 if not bound

### getAddress

public InetAddress getAddress()
Get the bind address.

Returns:
  The bind address

### setAddress

public void setAddress(InetAddress address)
Set the bind address.

Parameters:
  `address` - The bind address

### getLocalAddress

protected abstract InetSocketAddress getLocalAddress() throws IOException
Obtain the network address the server socket is bound to. This primarily exists to enable the correct address to be used when unlocking the server socket since it removes the guess-work involved if no address is specifically set.

Returns:
  The network address that the server socket is listening on or null if the server socket is not currently bound.
Throws:
  `IOException` - If there is a problem determining the currently bound socket

### setAcceptCount

public void setAcceptCount(int acceptCount)
Set the accept count.

Parameters:
  `acceptCount` - The accept count (must be > 0)

### getAcceptCount

public int getAcceptCount()
Get the accept count.

Returns:
  The accept count

### getBindOnInit

public boolean getBindOnInit()
Get the bind on init flag.

Returns:
  True if the endpoint binds on init, false if it binds on start

### setBindOnInit

public void setBindOnInit(boolean b)
Set the bind on init flag.

Parameters:
  `b` - True to bind on init, false to bind on start

### getBindState

protected AbstractEndpoint.BindState getBindState()
Get the current bind state.

Returns:
  The current bind state

### getKeepAliveTimeout

public int getKeepAliveTimeout()
Get the keepalive timeout.

Returns:
  The keepalive timeout in milliseconds

### setKeepAliveTimeout

public void setKeepAliveTimeout(int keepAliveTimeout)
Set the keepalive timeout.

Parameters:
  `keepAliveTimeout` - The keepalive timeout in milliseconds

### getTcpNoDelay

public boolean getTcpNoDelay()
Socket TCP no delay.

Returns:
  The current TCP no delay setting for sockets created by this endpoint

### setTcpNoDelay

public void setTcpNoDelay(boolean tcpNoDelay)
Set the TCP no delay flag.

Parameters:
  `tcpNoDelay` - True to enable TCP no delay

### getConnectionLinger

public int getConnectionLinger()
Socket linger.

Returns:
  The current socket linger time for sockets created by this endpoint

### setConnectionLinger

public void setConnectionLinger(int connectionLinger)
Set the connection linger time.

Parameters:
  `connectionLinger` - The socket linger time in seconds

### getConnectionTimeout

public int getConnectionTimeout()
Socket timeout.

Returns:
  The current socket timeout for sockets created by this endpoint

### setConnectionTimeout

public void setConnectionTimeout(int soTimeout)
Set the connection timeout.

Parameters:
  `soTimeout` - The socket timeout in milliseconds

### isSSLEnabled

public boolean isSSLEnabled()
Check if SSL is enabled.

Returns:
  True if SSL is enabled

### setSSLEnabled

public void setSSLEnabled(boolean SSLEnabled)
Set the SSL enabled flag.

Parameters:
  `SSLEnabled` - True to enable SSL

### setMinSpareThreads

public void setMinSpareThreads(int minSpareThreads)
Set the minimum number of spare threads.

Parameters:
  `minSpareThreads` - The minimum number of spare threads

### getMinSpareThreads

public int getMinSpareThreads()
Get the minimum number of spare threads.

Returns:
  The minimum number of spare threads

### setMaxThreads

public void setMaxThreads(int maxThreads)
Set the maximum number of worker threads.

Parameters:
  `maxThreads` - The maximum number of worker threads

### getMaxThreads

public int getMaxThreads()
Get the maximum number of worker threads.

Returns:
  The maximum number of worker threads, or -1 if no internal executor is used

### setMaxQueueSize

public void setMaxQueueSize(int maxQueueSize)
Set the maximum task queue size.

Parameters:
  `maxQueueSize` - The maximum queue size

### getMaxQueueSize

public int getMaxQueueSize()
Get the maximum queue size.

Returns:
  The maximum queue size

### setThreadsMaxIdleTime

public void setThreadsMaxIdleTime(int threadsMaxIdleTime)
Set the maximum idle time for threads in the internal thread pool.

Parameters:
  `threadsMaxIdleTime` - The maximum idle time in milliseconds

### getThreadsMaxIdleTime

public int getThreadsMaxIdleTime()
Get the maximum idle time for threads in the internal thread pool.

Returns:
  The maximum idle time in milliseconds, or -1 if no internal executor is used

### setThreadPriority

public void setThreadPriority(int threadPriority)
Set the priority of the worker threads.

Parameters:
  `threadPriority` - The thread priority

### getThreadPriority

public int getThreadPriority()
Get the priority of the worker threads.

Returns:
  The thread priority, or -1 if no internal executor is used

### getMaxKeepAliveRequests

public int getMaxKeepAliveRequests()
Get the maximum number of keep alive requests.

Returns:
  The maximum number of keep alive requests

### setMaxKeepAliveRequests

public void setMaxKeepAliveRequests(int maxKeepAliveRequests)
Set the maximum number of keep alive requests.

Parameters:
  `maxKeepAliveRequests` - The maximum number of keep alive requests

### setName

public void setName(String name)
Set the name of the thread pool.

Parameters:
  `name` - The name of the thread pool

### getName

public String getName()
Get the name of the thread pool.

Returns:
  The name of the thread pool

### setDomain

public void setDomain(String domain)
Set the domain for JMX registration.

Parameters:
  `domain` - The JMX domain

### getDomain

public String getDomain()
Get the JMX domain.

Returns:
  The JMX domain, or null if not set

### setDaemon

public void setDaemon(boolean b)
Set whether the threads should be daemon threads.

Parameters:
  `b` - True to use daemon threads

### getDaemon

public boolean getDaemon()
Check if the threads are daemon threads.

Returns:
  True if the threads are daemon threads

### setUseAsyncIO

public void setUseAsyncIO(boolean useAsyncIO)
Set whether asynchronous IO is enabled.

Parameters:
  `useAsyncIO` - True to enable asynchronous IO

### getUseAsyncIO

public boolean getUseAsyncIO()
Check if asynchronous IO is enabled.

Returns:
  True if asynchronous IO is enabled

### getId

public String getId()
The default behavior is to identify connectors uniquely with address and port. However, certain connectors are not using that and need some other identifier, which then can be used as a replacement.

Returns:
  the id

### addNegotiatedProtocol

public void addNegotiatedProtocol(String negotiableProtocol)
Add a protocol that can be negotiated (e.g. ALPN).

Parameters:
  `negotiableProtocol` - The protocol to add

### hasNegotiableProtocols

public boolean hasNegotiableProtocols()
Check if there are any negotiable protocols configured.

Returns:
  True if there are negotiable protocols

### setHandler

public void setHandler(AbstractEndpoint.Handler<S> handler)
Set the handler for this endpoint.

Parameters:
  `handler` - The handler to set

### getHandler

public AbstractEndpoint.Handler<S> getHandler()
Get the handler.

Returns:
  The handler

### setAttribute

public void setAttribute(String name, Object value)
Generic property setter called when a property for which a specific setter already exists within the `ProtocolHandler` needs to be made available to subcomponents. The specific setter will call this method to populate the attributes.

Parameters:
  `name` - Name of property to set
  `value` - The value to set the property to

### getAttribute

public Object getAttribute(String key)
Used by subcomponents to retrieve configuration information.

Parameters:
  `key` - The name of the property for which the value should be retrieved
Returns:
  The value of the specified property

### setProperty

public boolean setProperty(String name, String value)
Set the specified property.

Parameters:
  `name` - The name of the property
  `value` - The value of the property
Returns:
  True if the property was set successfully

### getProperty

public String getProperty(String name)
Get the value of the specified property.

Parameters:
  `name` - The name of the property
Returns:
  The value of the property, or null if not found

### getCurrentThreadCount

public int getCurrentThreadCount()
Return the amount of threads that are managed by the pool.

Returns:
  the amount of threads that are managed by the pool

### getCurrentThreadsBusy

public int getCurrentThreadsBusy()
Return the amount of threads that are in use

Returns:
  the amount of threads that are in use

### isRunning

public boolean isRunning()
Check if the endpoint is running.

Returns:
  True if the endpoint is running

### isPaused

public boolean isPaused()
Check if the endpoint is paused.

Returns:
  True if the endpoint is paused

### createExecutor

public void createExecutor()
Create the internal executor.

### shutdownExecutor

public void shutdownExecutor()
Shutdown the internal executor.

### unlockAccept

protected void unlockAccept()
Unlock the server socket acceptor threads using bogus connections.

### processSocket

public boolean processSocket(SocketWrapperBase<S> socketWrapper, SocketEvent event, boolean dispatch)
Process the given SocketWrapper with the given status. Used to trigger processing as if the Poller (for those endpoints that have one) selected the socket.

Parameters:
  `socketWrapper` - The socket wrapper to process
  `event` - The socket event to be processed
  `dispatch` - Should the processing be performed on a new container thread
Returns:
  if processing was triggered successfully

### createSocketProcessor

protected abstract SocketProcessorBase<S> createSocketProcessor(SocketWrapperBase<S> socketWrapper, SocketEvent event)
Create a socket processor for the given socket wrapper.

Parameters:
  `socketWrapper` - The socket wrapper to process
  `event` - The socket event
Returns:
  The socket processor

### bind

public abstract void bind() throws Exception
Bind the endpoint to its port and address.

Throws:
  `Exception` - If an error occurs during binding

### unbind

public void unbind() throws Exception
Unbind the endpoint from its port and address.

Throws:
  `Exception` - If an error occurs during unbinding

### startInternal

public abstract void startInternal() throws Exception
Start the endpoint internal components.

Throws:
  `Exception` - If an error occurs during startup

### stopInternal

public abstract void stopInternal() throws Exception
Stop the endpoint internal components.

Throws:
  `Exception` - If an error occurs during shutdown

### init

public final void init() throws Exception
Initialize the endpoint.

Throws:
  `Exception` - If an error occurs during initialization

### start

public final void start() throws Exception
Start the endpoint.

Throws:
  `Exception` - If an error occurs during startup

### startAcceptorThread

protected void startAcceptorThread()
Start the acceptor thread.

### pause

public void pause()
Pause the endpoint, which will stop it accepting new connections and unlock the acceptor.

### resume

public void resume()
Resume the endpoint, which will make it start accepting new connections again.

### stop

public final void stop() throws Exception
Stop the endpoint.

Throws:
  `Exception` - If an error occurs during shutdown

### destroy

public final void destroy() throws Exception
Destroy the endpoint and release all resources.

Throws:
  `Exception` - If an error occurs while destroying the endpoint

### getLog

protected abstract Log getLog()
Get the logger for this endpoint.

Returns:
  The logger

### getLogCertificate

protected Log getLogCertificate()
Get the logger for certificate-related messages.

Returns:
  The logger (defaults to `getLog()`)

### initializeConnectionLatch

protected LimitLatch initializeConnectionLatch()
Initialize the connection latch if it has not already been created.

Returns:
  The connection latch, or null if connection counting is disabled

### countUpOrAwaitConnection

protected void countUpOrAwaitConnection() throws InterruptedException
Count up or await a connection slot.

Throws:
  `InterruptedException` - If thrown during thread interruption

### countDownConnection

protected long countDownConnection()
Count down a connection.

Returns:
  The number of connections remaining, or -1 if connection counting is disabled

### closeServerSocketGraceful

public final void closeServerSocketGraceful()
Close the server socket (to prevent further connections) if the server socket was originally bound on `start()` (rather than on `init()`).

See Also:
  - `getBindOnInit()`

### awaitConnectionsClose

public final long awaitConnectionsClose(long waitMillis)
Wait for the client connections to the server to close gracefully. The method will return when all of the client connections have closed or the method has been waiting for `waitTimeMillis`.

Parameters:
  `waitMillis` - The maximum time to wait in milliseconds for the client connections to close.
Returns:
  The wait time, if any remaining when the method returned

### doCloseServerSocket

protected abstract void doCloseServerSocket() throws IOException
Actually close the server socket but don't perform any other clean-up.

Throws:
  `IOException` - If an error occurs closing the socket

### serverSocketAccept

protected abstract U serverSocketAccept() throws Exception
Accept a connection from the server socket.

Returns:
  The accepted socket
Throws:
  `Exception` - If an error occurs during accept

### setSocketOptions

protected abstract boolean setSocketOptions(U socket)
Set the socket options for the given accepted socket.

Parameters:
  `socket` - The accepted socket
Returns:
  True if the socket options were set successfully

### closeSocket

protected void closeSocket(U socket)
Close the socket when the connection has to be immediately closed when an error occurs while configuring the accepted socket or trying to dispatch it for processing. The wrapper associated with the socket will be used for the close.

Parameters:
  `socket` - The newly accepted socket

### destroySocket

protected abstract void destroySocket(U socket)
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.

Parameters:
  `socket` - The newly accepted socket