Class UdpSocketOptions.Builder

    • Constructor Detail

      • Builder

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

      • withReuseAddress

        public UdpSocketOptions.Builder withReuseAddress​(Boolean reuseAddress)
        Sets whether address reuse is enabled.
        Parameters:
        reuseAddress - true to enable address reuse, false to disable it, or null to use the underlying socket default
        Returns:
        this builder
      • withReceiveBufferSize

        public UdpSocketOptions.Builder withReceiveBufferSize​(Integer receiveBufferSize)
        Sets the receive buffer size.
        Parameters:
        receiveBufferSize - the receive buffer size in bytes, or null to use the underlying socket default
        Returns:
        this builder
        Throws:
        IllegalArgumentException - if receiveBufferSize is not null and is less than or equal to zero
      • withSendBufferSize

        public UdpSocketOptions.Builder withSendBufferSize​(Integer sendBufferSize)
        Sets the send buffer size.
        Parameters:
        sendBufferSize - the send buffer size in bytes, or null to use the underlying socket default
        Returns:
        this builder
        Throws:
        IllegalArgumentException - if sendBufferSize is not null and is less than or equal to zero
      • withSoTimeout

        public UdpSocketOptions.Builder withSoTimeout​(Integer soTimeout)
        Sets the socket timeout.
        Parameters:
        soTimeout - the socket timeout in milliseconds; 0 specifies an infinite timeout, or null uses the underlying socket default
        Returns:
        this builder
        Throws:
        IllegalArgumentException - if soTimeout is negative
      • withBroadcast

        public UdpSocketOptions.Builder withBroadcast​(Boolean broadcast)
        Sets whether broadcast is enabled.
        Parameters:
        broadcast - true to enable broadcast, false to disable it, or null to use the underlying socket default
        Returns:
        this builder
      • withTrafficClass

        public UdpSocketOptions.Builder withTrafficClass​(Integer trafficClass)
        Sets the IP traffic class.
        Parameters:
        trafficClass - the IP traffic class from 0 through 255, or null to use the underlying socket default
        Returns:
        this builder
        Throws:
        IllegalArgumentException - if trafficClass is outside the range 0 through 255
      • build

        public UdpSocketOptions build()
        Builds the UDP socket options using the configuration specified by this builder.
        Returns:
        the configured UDP socket options