Package com.kristensoft.kdc
Class UdpSocketOptions.Builder
- java.lang.Object
-
- com.kristensoft.kdc.UdpSocketOptions.Builder
-
- Direct Known Subclasses:
MulticastSocketOptions.Builder
- Enclosing class:
- UdpSocketOptions
public static class UdpSocketOptions.Builder extends Object
BuildsUdpSocketOptionsinstances.Options that are not explicitly configured use the underlying socket defaults.
-
-
Constructor Summary
Constructors Constructor Description Builder()Creates a builder for configuring UDP socket options.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UdpSocketOptionsbuild()Builds the UDP socket options using the configuration specified by this builder.UdpSocketOptions.BuilderwithBroadcast(Boolean broadcast)Sets whether broadcast is enabled.UdpSocketOptions.BuilderwithReceiveBufferSize(Integer receiveBufferSize)Sets the receive buffer size.UdpSocketOptions.BuilderwithReuseAddress(Boolean reuseAddress)Sets whether address reuse is enabled.UdpSocketOptions.BuilderwithSendBufferSize(Integer sendBufferSize)Sets the send buffer size.UdpSocketOptions.BuilderwithSoTimeout(Integer soTimeout)Sets the socket timeout.UdpSocketOptions.BuilderwithTrafficClass(Integer trafficClass)Sets the IP traffic class.
-
-
-
Method Detail
-
withReuseAddress
public UdpSocketOptions.Builder withReuseAddress(Boolean reuseAddress)
Sets whether address reuse is enabled.- Parameters:
reuseAddress-trueto enable address reuse,falseto disable it, ornullto 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, ornullto use the underlying socket default- Returns:
- this builder
- Throws:
IllegalArgumentException- ifreceiveBufferSizeis notnulland 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, ornullto use the underlying socket default- Returns:
- this builder
- Throws:
IllegalArgumentException- ifsendBufferSizeis notnulland 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;0specifies an infinite timeout, ornulluses the underlying socket default- Returns:
- this builder
- Throws:
IllegalArgumentException- ifsoTimeoutis negative
-
withBroadcast
public UdpSocketOptions.Builder withBroadcast(Boolean broadcast)
Sets whether broadcast is enabled.- Parameters:
broadcast-trueto enable broadcast,falseto disable it, ornullto 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 from0through255, ornullto use the underlying socket default- Returns:
- this builder
- Throws:
IllegalArgumentException- iftrafficClassis outside the range0through255
-
build
public UdpSocketOptions build()
Builds the UDP socket options using the configuration specified by this builder.- Returns:
- the configured UDP socket options
-
-