Package com.kristensoft.kdc
Class SocketOptions.Builder<T extends SocketOptions.Builder<T>>
- java.lang.Object
-
- com.kristensoft.kdc.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
SocketOptionsimplementation.
-
-
Constructor Summary
Constructors Constructor Description Builder()Creates a builder for configuring socket options.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract SocketOptionsbuild()Builds the socket options instance using the configured values.TwithReceiveBufferSize(int value)Configures the socket receive buffer size.TwithReuseAddress(boolean value)Configures whether the socket may reuse its local address.TwithSendBufferSize(int value)Configures the socket send buffer size.TwithTrafficClass(int value)Configures the IP traffic class for the socket.
-
-
-
Method Detail
-
withReuseAddress
public T withReuseAddress(boolean value)
Configures whether the socket may reuse its local address.- Parameters:
value-trueto enable address reuse,falseto 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- ifvalueis 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- ifvalueis not greater than zero
-
withTrafficClass
public T withTrafficClass(int value)
Configures the IP traffic class for the socket.- Parameters:
value- the traffic class value, from0through255- Returns:
- this builder
- Throws:
IllegalArgumentException- ifvalueis outside the range0through255
-
build
public abstract SocketOptions build()
Builds the socket options instance using the configured values.- Returns:
- the constructed socket options instance
-
-