Package com.kristensoft.kdc
Class MulticastSocketOptions.Builder
- java.lang.Object
-
- com.kristensoft.kdc.UdpSocketOptions.Builder
-
- com.kristensoft.kdc.MulticastSocketOptions.Builder
-
- Enclosing class:
- MulticastSocketOptions
public static class MulticastSocketOptions.Builder extends UdpSocketOptions.Builder
BuildsMulticastSocketOptionsinstances.
-
-
Constructor Summary
Constructors Constructor Description Builder()Creates a builder for configuring multicast socket options.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MulticastSocketOptionsbuild()Builds the multicast socket options using the configured settings.MulticastSocketOptions.BuilderwithBroadcast(Boolean broadcast)Sets whether broadcast is enabled.MulticastSocketOptions.BuilderwithLoopbackModeDisabled(Boolean disabled)Sets whether multicast loopback mode is disabled.MulticastSocketOptions.BuilderwithNetworkInterface(NetworkInterface networkInterface)Sets the network interface used for multicast communication.MulticastSocketOptions.BuilderwithReceiveBufferSize(Integer receiveBufferSize)Sets the receive buffer size.MulticastSocketOptions.BuilderwithReuseAddress(Boolean reuseAddress)Sets whether address reuse is enabled.MulticastSocketOptions.BuilderwithSendBufferSize(Integer sendBufferSize)Sets the send buffer size.MulticastSocketOptions.BuilderwithSoTimeout(Integer soTimeout)Sets the socket timeout.MulticastSocketOptions.BuilderwithTimeToLive(Integer timeToLive)Sets the multicast time-to-live.MulticastSocketOptions.BuilderwithTrafficClass(Integer trafficClass)Sets the IP traffic class.
-
-
-
Method Detail
-
withTimeToLive
public MulticastSocketOptions.Builder withTimeToLive(Integer timeToLive)
Sets the multicast time-to-live.The value must be between
0and255, inclusive.- Parameters:
timeToLive- the multicast time-to-live- Returns:
- this builder
- Throws:
IllegalArgumentException- iftimeToLiveisnullor outside the range0through255
-
withLoopbackModeDisabled
public MulticastSocketOptions.Builder withLoopbackModeDisabled(Boolean disabled)
Sets whether multicast loopback mode is disabled.A value of
truedisables loopback, whilefalseenables it.- Parameters:
disabled-trueto disable multicast loopback;falseto enable it- Returns:
- this builder
- Throws:
IllegalArgumentException- ifdisabledisnull
-
withNetworkInterface
public MulticastSocketOptions.Builder withNetworkInterface(NetworkInterface networkInterface)
Sets the network interface used for multicast communication.This typically corresponds to the network interface associated with the configured bind address.
- Parameters:
networkInterface- the network interface to use- Returns:
- this builder
- Throws:
IllegalArgumentException- ifnetworkInterfaceisnull
-
withReuseAddress
public MulticastSocketOptions.Builder withReuseAddress(Boolean reuseAddress)
Sets whether address reuse is enabled.- Overrides:
withReuseAddressin classUdpSocketOptions.Builder- Parameters:
reuseAddress-trueto enable address reuse,falseto disable it, ornullto use the underlying socket default- Returns:
- this builder
-
withReceiveBufferSize
public MulticastSocketOptions.Builder withReceiveBufferSize(Integer receiveBufferSize)
Sets the receive buffer size.- Overrides:
withReceiveBufferSizein classUdpSocketOptions.Builder- Parameters:
receiveBufferSize- the receive buffer size in bytes, ornullto use the underlying socket default- Returns:
- this builder
-
withSendBufferSize
public MulticastSocketOptions.Builder withSendBufferSize(Integer sendBufferSize)
Sets the send buffer size.- Overrides:
withSendBufferSizein classUdpSocketOptions.Builder- Parameters:
sendBufferSize- the send buffer size in bytes, ornullto use the underlying socket default- Returns:
- this builder
-
withSoTimeout
public MulticastSocketOptions.Builder withSoTimeout(Integer soTimeout)
Sets the socket timeout.- Overrides:
withSoTimeoutin classUdpSocketOptions.Builder- Parameters:
soTimeout- the socket timeout in milliseconds;0specifies an infinite timeout, ornulluses the underlying socket default- Returns:
- this builder
-
withBroadcast
public MulticastSocketOptions.Builder withBroadcast(Boolean broadcast)
Sets whether broadcast is enabled.- Overrides:
withBroadcastin classUdpSocketOptions.Builder- Parameters:
broadcast-trueto enable broadcast,falseto disable it, ornullto use the underlying socket default- Returns:
- this builder
-
withTrafficClass
public MulticastSocketOptions.Builder withTrafficClass(Integer trafficClass)
Sets the IP traffic class.- Overrides:
withTrafficClassin classUdpSocketOptions.Builder- Parameters:
trafficClass- the IP traffic class from0through255, ornullto use the underlying socket default- Returns:
- this builder
-
build
public MulticastSocketOptions build()
Builds the multicast socket options using the configured settings.If reuse address has not been explicitly configured, it defaults to
true.- Overrides:
buildin classUdpSocketOptions.Builder- Returns:
- the configured multicast socket options
-
-