Class SocketOptions.Builder<T extends SocketOptions.Builder<T>>

  • Type Parameters:
    T - the concrete builder type
    Enclosing class:
    SocketOptions

    public abstract static class SocketOptions.Builder<T extends SocketOptions.Builder<T>>
    extends Object
    Base builder for configuring common socket options.

    Concrete builders extend this class to provide additional transport-specific configuration options and construct the corresponding SocketOptions implementation.

    • Constructor Detail

      • Builder

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

      • withReuseAddress

        public T withReuseAddress​(boolean value)
        Configures whether the socket may reuse its local address.
        Parameters:
        value - true to enable address reuse, false to disable it
        Returns:
        this builder
      • withReceiveBufferSize

        public T withReceiveBufferSize​(int value)
        Configures the socket receive buffer size.

        The specified size is requested from the underlying socket implementation. The effective size may differ depending on the operating system.

        Parameters:
        value - the requested receive buffer size in bytes; must be greater than zero
        Returns:
        this builder
        Throws:
        IllegalArgumentException - if value is not greater than zero
      • withSendBufferSize

        public T withSendBufferSize​(int value)
        Configures the socket send buffer size.

        The specified size is requested from the underlying socket implementation. The effective size may differ depending on the operating system.

        Parameters:
        value - the requested send buffer size in bytes; must be greater than zero
        Returns:
        this builder
        Throws:
        IllegalArgumentException - if value is not greater than zero
      • withTrafficClass

        public T withTrafficClass​(int value)
        Configures the IP traffic class for the socket.
        Parameters:
        value - the traffic class value, from 0 through 255
        Returns:
        this builder
        Throws:
        IllegalArgumentException - if value is outside the range 0 through 255
      • build

        public abstract SocketOptions build()
        Builds the socket options instance using the configured values.
        Returns:
        the constructed socket options instance