# Class SocketProperties

java.lang.Object
org.apache.tomcat.util.net.SocketProperties

public class SocketProperties extends Object
Properties that can be set in the <Connector> element in server.xml. All properties are prefixed with "socket." and are currently only working for the Nio connector

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected int`
  `appReadBufSize`
  The application read buffer size in bytes.
  `protected int`
  `appWriteBufSize`
  The application write buffer size in bytes.
  `protected int`
  `bufferPool`
  NioChannel pool size for the endpoint, this value is how many channels.
  `protected int`
  `bufferPoolSize`
  Buffer pool size in bytes to be cached.
  `protected boolean`
  `directBuffer`
  Enable/disable direct buffers for the network buffers.
  `protected boolean`
  `directSslBuffer`
  Enable/disable direct buffers for the network buffers for SSL.
  `protected int`
  `eventCache`
  Enable/disable poller event cache, this bounded cache stores PollerEvent objects to reduce GC for the poller
  `protected Boolean`
  `ooBInline`
  OOBINLINE option.
  `protected Integer`
  `performanceBandwidth`
  Performance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used.
  `protected Integer`
  `performanceConnectionTime`
  Performance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used.
  `protected Integer`
  `performanceLatency`
  Performance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used.
  `protected int`
  `processorCache`
  Enable/disable socket processor cache, this bounded cache stores SocketProcessor objects to reduce GC.
  `protected Integer`
  `rxBufSize`
  Socket receive buffer size in bytes (SO_RCVBUF).
  `protected Boolean`
  `soKeepAlive`
  SO_KEEPALIVE option.
  `protected Boolean`
  `soLingerOn`
  SO_LINGER option, paired with the `soLingerTime` value.
  `protected Integer`
  `soLingerTime`
  SO_LINGER option, paired with the `soLingerOn` value.
  `protected Boolean`
  `soReuseAddress`
  SO_REUSEADDR option.
  `protected Integer`
  `soTimeout`
  SO_TIMEOUT option. default is 20000.
  `protected Boolean`
  `tcpNoDelay`
  TCP_NO_DELAY option.
  `protected long`
  `timeoutInterval`
  The minimum frequency of the timeout interval to avoid excess load from the poller during high traffic
  `protected Integer`
  `txBufSize`
  Socket send buffer size in bytes (SO_SNDBUF).
  `protected int`
  `unlockTimeout`
  Timeout in milliseconds for an unlock to take place.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SocketProperties()`
  Creates a new instance of SocketProperties with default values.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getActualBufferPool(int bufferOverhead)`
  Get the actual buffer pool size to use.
  `int`
  `getAppReadBufSize()`
  Returns the application read buffer size in bytes.
  `int`
  `getAppWriteBufSize()`
  Returns the application write buffer size in bytes.
  `int`
  `getBufferPool()`
  Returns the NioChannel pool size.
  `int`
  `getBufferPoolSize()`
  Returns the buffer pool size in bytes to be cached.
  `boolean`
  `getDirectBuffer()`
  Returns whether direct buffers are used for network buffers.
  `int`
  `getDirectBufferPool()`
  Returns the direct buffer pool size.
  `boolean`
  `getDirectSslBuffer()`
  Returns whether direct buffers are used for SSL network buffers.
  `int`
  `getEventCache()`
  Returns the poller event cache size.
  `boolean`
  `getOoBInline()`
  Returns the OOBINLINE socket option value.
  `int`
  `getPerformanceBandwidth()`
  Returns the performance preference for bandwidth.
  `int`
  `getPerformanceConnectionTime()`
  Returns the performance preference for connection time.
  `int`
  `getPerformanceLatency()`
  Returns the performance preference for latency.
  `int`
  `getProcessorCache()`
  Returns the socket processor cache size.
  `int`
  `getRxBufSize()`
  Returns the socket receive buffer size in bytes.
  `boolean`
  `getSoKeepAlive()`
  Returns the SO_KEEPALIVE socket option value.
  `boolean`
  `getSoLingerOn()`
  Returns whether SO_LINGER is enabled.
  `int`
  `getSoLingerTime()`
  Returns the SO_LINGER timeout value in seconds.
  `boolean`
  `getSoReuseAddress()`
  Returns the SO_REUSEADDR socket option value.
  `int`
  `getSoTimeout()`
  Returns the SO_TIMEOUT value in milliseconds.
  `boolean`
  `getTcpNoDelay()`
  Returns the TCP_NODELAY socket option value.
  `long`
  `getTimeoutInterval()`
  Returns the minimum frequency of the timeout interval in milliseconds.
  `int`
  `getTxBufSize()`
  Returns the socket send buffer size in bytes.
  `int`
  `getUnlockTimeout()`
  Returns the unlock timeout in milliseconds.
  `void`
  `setAppReadBufSize(int appReadBufSize)`
  Sets the application read buffer size in bytes.
  `void`
  `setAppWriteBufSize(int appWriteBufSize)`
  Sets the application write buffer size in bytes.
  `void`
  `setBufferPool(int bufferPool)`
  Sets the NioChannel pool size.
  `void`
  `setBufferPoolSize(int bufferPoolSize)`
  Sets the buffer pool size in bytes to be cached.
  `void`
  `setDirectBuffer(boolean directBuffer)`
  Sets whether direct buffers are used for network buffers.
  `void`
  `setDirectBufferPool(int directBufferPool)`
  Sets the direct buffer pool size.
  `void`
  `setDirectSslBuffer(boolean directSslBuffer)`
  Sets whether direct buffers are used for SSL network buffers.
  `void`
  `setEventCache(int eventCache)`
  Sets the poller event cache size.
  `void`
  `setOoBInline(boolean ooBInline)`
  Sets the OOBINLINE socket option.
  `void`
  `setPerformanceBandwidth(int performanceBandwidth)`
  Sets the performance preference for bandwidth.
  `void`
  `setPerformanceConnectionTime(int performanceConnectionTime)`
  Sets the performance preference for connection time.
  `void`
  `setPerformanceLatency(int performanceLatency)`
  Sets the performance preference for latency.
  `void`
  `setProcessorCache(int processorCache)`
  Sets the socket processor cache size.
  `void`
  `setProperties(ServerSocket socket)`
  Applies socket properties to the given `ServerSocket`.
  `void`
  `setProperties(Socket socket)`
  Applies socket properties to the given `Socket`.
  `void`
  `setProperties(AsynchronousServerSocketChannel socket)`
  Applies socket properties to the given `AsynchronousServerSocketChannel`.
  `void`
  `setProperties(AsynchronousSocketChannel socket)`
  Applies socket properties to the given `AsynchronousSocketChannel`.
  `void`
  `setRxBufSize(int rxBufSize)`
  Sets the socket receive buffer size in bytes.
  `void`
  `setSoKeepAlive(boolean soKeepAlive)`
  Sets the SO_KEEPALIVE socket option.
  `void`
  `setSoLingerOn(boolean soLingerOn)`
  Sets whether SO_LINGER is enabled.
  `void`
  `setSoLingerTime(int soLingerTime)`
  Sets the SO_LINGER timeout value in seconds.
  `void`
  `setSoReuseAddress(boolean soReuseAddress)`
  Sets the SO_REUSEADDR socket option.
  `void`
  `setSoTimeout(int soTimeout)`
  Sets the SO_TIMEOUT value in milliseconds.
  `void`
  `setTcpNoDelay(boolean tcpNoDelay)`
  Sets the TCP_NODELAY socket option.
  `void`
  `setTimeoutInterval(long timeoutInterval)`
  Sets the minimum frequency of the timeout interval in milliseconds.
  `void`
  `setTxBufSize(int txBufSize)`
  Sets the socket send buffer size in bytes.
  `void`
  `setUnlockTimeout(int unlockTimeout)`
  Sets the unlock timeout in milliseconds.

  ### Methods inherited from class Object

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

- ## Field Details

  - ### processorCache

    protected int processorCache
    Enable/disable socket processor cache, this bounded cache stores SocketProcessor objects to reduce GC.

    Default is 0
    -1 is unlimited
    0 is disabled

  - ### eventCache

    protected int eventCache
    Enable/disable poller event cache, this bounded cache stores PollerEvent objects to reduce GC for the poller

    Default is 0
    -1 is unlimited
    0 is disabled
    >0 the max number of objects to keep in cache.

  - ### directBuffer

    protected boolean directBuffer
    Enable/disable direct buffers for the network buffers. Default value is disabled.

  - ### directSslBuffer

    protected boolean directSslBuffer
    Enable/disable direct buffers for the network buffers for SSL. Default value is disabled.

  - ### rxBufSize

    protected Integer rxBufSize
    Socket receive buffer size in bytes (SO_RCVBUF). JVM default used if not set.

  - ### txBufSize

    protected Integer txBufSize
    Socket send buffer size in bytes (SO_SNDBUF). JVM default used if not set.

  - ### appReadBufSize

    protected int appReadBufSize
    The application read buffer size in bytes. Default value is 8192.

  - ### appWriteBufSize

    protected int appWriteBufSize
    The application write buffer size in bytes. Default value is 8192.

  - ### bufferPool

    protected int bufferPool
    NioChannel pool size for the endpoint, this value is how many channels.

    0 means no cache
    -1 means unlimited cached
    -2 means bufferPoolSize will be used
    Default value is -2

  - ### bufferPoolSize

    protected int bufferPoolSize
    Buffer pool size in bytes to be cached.

    -1 means unlimited
    0 means no cache
    Default value is based on the max memory reported by the JVM, if less than 1GB, then 0, else the value divided by 32. This value will then be used to compute bufferPool if its value is -2

  - ### tcpNoDelay

    protected Boolean tcpNoDelay
    TCP_NO_DELAY option. JVM default used if not set.

  - ### soKeepAlive

    protected Boolean soKeepAlive
    SO_KEEPALIVE option. JVM default used if not set.

  - ### ooBInline

    protected Boolean ooBInline
    OOBINLINE option. JVM default used if not set.

  - ### soReuseAddress

    protected Boolean soReuseAddress
    SO_REUSEADDR option. JVM default used if not set.

  - ### soLingerOn

    protected Boolean soLingerOn
    SO_LINGER option, paired with the `soLingerTime` value. JVM defaults used unless both attributes are set.

  - ### soLingerTime

    protected Integer soLingerTime
    SO_LINGER option, paired with the `soLingerOn` value. JVM defaults used unless both attributes are set.

  - ### soTimeout

    protected Integer soTimeout
    SO_TIMEOUT option. default is 20000.

  - ### performanceConnectionTime

    protected Integer performanceConnectionTime
    Performance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used.

  - ### performanceLatency

    protected Integer performanceLatency
    Performance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used.

  - ### performanceBandwidth

    protected Integer performanceBandwidth
    Performance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used.

  - ### timeoutInterval

    protected long timeoutInterval
    The minimum frequency of the timeout interval to avoid excess load from the poller during high traffic

  - ### unlockTimeout

    protected int unlockTimeout
    Timeout in milliseconds for an unlock to take place.

- ## Constructor Details

  - ### SocketProperties

    public SocketProperties()
    Creates a new instance of SocketProperties with default values.

- ## Method Details

  - ### setProperties

    public void setProperties(Socket socket) throws SocketException
    Applies socket properties to the given `Socket`.
    Parameters:
      `socket` - the socket to configure
    Throws:
      `SocketException` - if a socket error occurs

  - ### setProperties

    public void setProperties(ServerSocket socket) throws SocketException
    Applies socket properties to the given `ServerSocket`.
    Parameters:
      `socket` - the server socket to configure
    Throws:
      `SocketException` - if a socket error occurs

  - ### setProperties

    public void setProperties(AsynchronousSocketChannel socket) throws IOException
    Applies socket properties to the given `AsynchronousSocketChannel`.
    Parameters:
      `socket` - the asynchronous socket channel to configure
    Throws:
      `IOException` - if an I/O error occurs

  - ### setProperties

    public void setProperties(AsynchronousServerSocketChannel socket) throws IOException
    Applies socket properties to the given `AsynchronousServerSocketChannel`.
    Parameters:
      `socket` - the asynchronous server socket channel to configure
    Throws:
      `IOException` - if an I/O error occurs

  - ### getDirectBuffer

    public boolean getDirectBuffer()
    Returns whether direct buffers are used for network buffers.
    Returns:
      `true` if direct buffers are enabled

  - ### getDirectSslBuffer

    public boolean getDirectSslBuffer()
    Returns whether direct buffers are used for SSL network buffers.
    Returns:
      `true` if direct SSL buffers are enabled

  - ### getOoBInline

    public boolean getOoBInline()
    Returns the OOBINLINE socket option value.
    Returns:
      the OOBINLINE value

  - ### getPerformanceBandwidth

    public int getPerformanceBandwidth()
    Returns the performance preference for bandwidth.
    Returns:
      the bandwidth preference value

  - ### getPerformanceConnectionTime

    public int getPerformanceConnectionTime()
    Returns the performance preference for connection time.
    Returns:
      the connection time preference value

  - ### getPerformanceLatency

    public int getPerformanceLatency()
    Returns the performance preference for latency.
    Returns:
      the latency preference value

  - ### getRxBufSize

    public int getRxBufSize()
    Returns the socket receive buffer size in bytes.
    Returns:
      the receive buffer size

  - ### getSoKeepAlive

    public boolean getSoKeepAlive()
    Returns the SO_KEEPALIVE socket option value.
    Returns:
      the keep-alive value

  - ### getSoLingerOn

    public boolean getSoLingerOn()
    Returns whether SO_LINGER is enabled.
    Returns:
      `true` if SO_LINGER is enabled

  - ### getSoLingerTime

    public int getSoLingerTime()
    Returns the SO_LINGER timeout value in seconds.
    Returns:
      the linger timeout value

  - ### getSoReuseAddress

    public boolean getSoReuseAddress()
    Returns the SO_REUSEADDR socket option value.
    Returns:
      the reuse address value

  - ### getSoTimeout

    public int getSoTimeout()
    Returns the SO_TIMEOUT value in milliseconds.
    Returns:
      the socket timeout value

  - ### getTcpNoDelay

    public boolean getTcpNoDelay()
    Returns the TCP_NODELAY socket option value.
    Returns:
      the TCP no delay value

  - ### getTxBufSize

    public int getTxBufSize()
    Returns the socket send buffer size in bytes.
    Returns:
      the send buffer size

  - ### getBufferPool

    public int getBufferPool()
    Returns the NioChannel pool size.
    Returns:
      the buffer pool size

  - ### getBufferPoolSize

    public int getBufferPoolSize()
    Returns the buffer pool size in bytes to be cached.
    Returns:
      the buffer pool byte size

  - ### getEventCache

    public int getEventCache()
    Returns the poller event cache size.
    Returns:
      the event cache size

  - ### getAppReadBufSize

    public int getAppReadBufSize()
    Returns the application read buffer size in bytes.
    Returns:
      the application read buffer size

  - ### getAppWriteBufSize

    public int getAppWriteBufSize()
    Returns the application write buffer size in bytes.
    Returns:
      the application write buffer size

  - ### getProcessorCache

    public int getProcessorCache()
    Returns the socket processor cache size.
    Returns:
      the processor cache size

  - ### getTimeoutInterval

    public long getTimeoutInterval()
    Returns the minimum frequency of the timeout interval in milliseconds.
    Returns:
      the timeout interval

  - ### getDirectBufferPool

    public int getDirectBufferPool()
    Returns the direct buffer pool size.
    Returns:
      the direct buffer pool size

  - ### setPerformanceConnectionTime

    public void setPerformanceConnectionTime(int performanceConnectionTime)
    Sets the performance preference for connection time.
    Parameters:
      `performanceConnectionTime` - the connection time preference value

  - ### setTxBufSize

    public void setTxBufSize(int txBufSize)
    Sets the socket send buffer size in bytes.
    Parameters:
      `txBufSize` - the send buffer size

  - ### setTcpNoDelay

    public void setTcpNoDelay(boolean tcpNoDelay)
    Sets the TCP_NODELAY socket option.
    Parameters:
      `tcpNoDelay` - the TCP no delay value

  - ### setSoTimeout

    public void setSoTimeout(int soTimeout)
    Sets the SO_TIMEOUT value in milliseconds.
    Parameters:
      `soTimeout` - the socket timeout value

  - ### setSoReuseAddress

    public void setSoReuseAddress(boolean soReuseAddress)
    Sets the SO_REUSEADDR socket option.
    Parameters:
      `soReuseAddress` - the reuse address value

  - ### setSoLingerTime

    public void setSoLingerTime(int soLingerTime)
    Sets the SO_LINGER timeout value in seconds.
    Parameters:
      `soLingerTime` - the linger timeout value

  - ### setSoKeepAlive

    public void setSoKeepAlive(boolean soKeepAlive)
    Sets the SO_KEEPALIVE socket option.
    Parameters:
      `soKeepAlive` - the keep-alive value

  - ### setRxBufSize

    public void setRxBufSize(int rxBufSize)
    Sets the socket receive buffer size in bytes.
    Parameters:
      `rxBufSize` - the receive buffer size

  - ### setPerformanceLatency

    public void setPerformanceLatency(int performanceLatency)
    Sets the performance preference for latency.
    Parameters:
      `performanceLatency` - the latency preference value

  - ### setPerformanceBandwidth

    public void setPerformanceBandwidth(int performanceBandwidth)
    Sets the performance preference for bandwidth.
    Parameters:
      `performanceBandwidth` - the bandwidth preference value

  - ### setOoBInline

    public void setOoBInline(boolean ooBInline)
    Sets the OOBINLINE socket option.
    Parameters:
      `ooBInline` - the OOB inline value

  - ### setDirectBuffer

    public void setDirectBuffer(boolean directBuffer)
    Sets whether direct buffers are used for network buffers.
    Parameters:
      `directBuffer` - `true` to enable direct buffers

  - ### setDirectSslBuffer

    public void setDirectSslBuffer(boolean directSslBuffer)
    Sets whether direct buffers are used for SSL network buffers.
    Parameters:
      `directSslBuffer` - `true` to enable direct SSL buffers

  - ### setSoLingerOn

    public void setSoLingerOn(boolean soLingerOn)
    Sets whether SO_LINGER is enabled.
    Parameters:
      `soLingerOn` - `true` to enable SO_LINGER

  - ### setBufferPool

    public void setBufferPool(int bufferPool)
    Sets the NioChannel pool size.
    Parameters:
      `bufferPool` - the buffer pool size

  - ### setBufferPoolSize

    public void setBufferPoolSize(int bufferPoolSize)
    Sets the buffer pool size in bytes to be cached.
    Parameters:
      `bufferPoolSize` - the buffer pool byte size

  - ### setEventCache

    public void setEventCache(int eventCache)
    Sets the poller event cache size.
    Parameters:
      `eventCache` - the event cache size

  - ### setAppReadBufSize

    public void setAppReadBufSize(int appReadBufSize)
    Sets the application read buffer size in bytes.
    Parameters:
      `appReadBufSize` - the application read buffer size

  - ### setAppWriteBufSize

    public void setAppWriteBufSize(int appWriteBufSize)
    Sets the application write buffer size in bytes.
    Parameters:
      `appWriteBufSize` - the application write buffer size

  - ### setProcessorCache

    public void setProcessorCache(int processorCache)
    Sets the socket processor cache size.
    Parameters:
      `processorCache` - the processor cache size

  - ### setTimeoutInterval

    public void setTimeoutInterval(long timeoutInterval)
    Sets the minimum frequency of the timeout interval in milliseconds.
    Parameters:
      `timeoutInterval` - the timeout interval

  - ### setDirectBufferPool

    public void setDirectBufferPool(int directBufferPool)
    Sets the direct buffer pool size.
    Parameters:
      `directBufferPool` - the direct buffer pool size

  - ### getUnlockTimeout

    public int getUnlockTimeout()
    Returns the unlock timeout in milliseconds.
    Returns:
      the unlock timeout

  - ### setUnlockTimeout

    public void setUnlockTimeout(int unlockTimeout)
    Sets the unlock timeout in milliseconds.
    Parameters:
      `unlockTimeout` - the unlock timeout value (must be positive)

  - ### getActualBufferPool

    public int getActualBufferPool(int bufferOverhead)
    Get the actual buffer pool size to use.
    Parameters:
      `bufferOverhead` - When TLS is enabled, additional network buffers are needed and will be added to the application buffer size
    Returns:
      the actual buffer pool size that will be used