Class TcpClientSocketOptions.Builder

  • Enclosing class:
    TcpClientSocketOptions

    public static class TcpClientSocketOptions.Builder
    extends Object
    Builds TcpClientSocketOptions instances.

    By default, TCP keep-alive is enabled. SO_LINGER is enabled with a linger time of zero seconds so that closing the socket performs an immediate abortive close, allowing the remote endpoint to promptly detect that the connection has been terminated.

    Other socket options default to null, indicating that the corresponding socket setting should not be changed.

    See Also:
    TcpClientSocketOptions
    • Constructor Detail

      • Builder

        public Builder()
        Creates a builder for configuring TCP client socket options.
    • Method Detail

      • withKeepAlive

        public TcpClientSocketOptions.Builder withKeepAlive​(Boolean keepAlive)
        Sets whether TCP keep-alive is enabled.

        A value of null leaves the corresponding socket setting unchanged.

        Parameters:
        keepAlive - true to enable TCP keep-alive, false to disable it, or null to leave the socket setting unchanged
        Returns:
        this builder
      • withReuseAddress

        public TcpClientSocketOptions.Builder withReuseAddress​(Boolean reuseAddress)
        Sets whether the socket address may be reused.

        A value of null leaves the corresponding socket setting unchanged.

        Parameters:
        reuseAddress - true to enable address reuse, false to disable it, or null to leave the socket setting unchanged
        Returns:
        this builder
      • withReceiveBufferSize

        public TcpClientSocketOptions.Builder withReceiveBufferSize​(Integer receiveBufferSize)
        Sets the socket receive buffer size.

        A value of null leaves the corresponding socket setting unchanged.

        Parameters:
        receiveBufferSize - the receive buffer size in bytes, or null to leave the socket setting unchanged
        Returns:
        this builder
      • withSendBufferSize

        public TcpClientSocketOptions.Builder withSendBufferSize​(Integer sendBufferSize)
        Sets the socket send buffer size.

        A value of null leaves the corresponding socket setting unchanged.

        Parameters:
        sendBufferSize - the send buffer size in bytes, or null to leave the socket setting unchanged
        Returns:
        this builder
      • withSoTimeout

        public TcpClientSocketOptions.Builder withSoTimeout​(Integer soTimeout)
        Sets the socket read timeout.

        A value of null leaves the corresponding socket setting unchanged.

        Parameters:
        soTimeout - the socket read timeout in milliseconds, or null to leave the socket setting unchanged
        Returns:
        this builder
      • withSoLinger

        public TcpClientSocketOptions.Builder withSoLinger​(Boolean on,
                                                           Integer time)
        Sets the socket SO_LINGER configuration.

        When enabled with a linger time of zero, closing the socket performs an immediate abortive close, allowing the remote endpoint to promptly detect that the connection has been terminated. If either argument is null, the SO_LINGER setting is not applied.

        Parameters:
        on - true to enable SO_LINGER, false to disable it, or null to leave the socket setting unchanged
        time - the linger time in seconds, or null to leave the socket setting unchanged
        Returns:
        this builder
      • withTcpNoDelay

        public TcpClientSocketOptions.Builder withTcpNoDelay​(Boolean tcpNoDelay)
        Sets whether the Nagle algorithm is disabled for the socket.

        A value of null leaves the corresponding socket setting unchanged.

        Parameters:
        tcpNoDelay - true to disable the Nagle algorithm, false to enable it, or null to leave the socket setting unchanged
        Returns:
        this builder
      • withTrafficClass

        public TcpClientSocketOptions.Builder withTrafficClass​(Integer trafficClass)
        Sets the IP traffic class for the socket.

        A value of null leaves the corresponding socket setting unchanged.

        Parameters:
        trafficClass - the IP traffic class value, or null to leave the socket setting unchanged
        Returns:
        this builder
      • withTcpOobInline

        public TcpClientSocketOptions.Builder withTcpOobInline​(Boolean oobInline)
        Sets whether received TCP urgent data is placed inline with normal socket data.

        A value of null leaves the corresponding socket setting unchanged.

        Parameters:
        oobInline - true to receive urgent data inline, false otherwise, or null to leave the socket setting unchanged
        Returns:
        this builder