Package com.kristensoft.kdc
Class TcpServerSocketOptions.Builder
- java.lang.Object
-
- com.kristensoft.kdc.TcpServerSocketOptions.Builder
-
- Enclosing class:
- TcpServerSocketOptions
public static final class TcpServerSocketOptions.Builder extends Object
BuildsTcpServerSocketOptionsinstances.
-
-
Constructor Summary
Constructors Constructor Description Builder()Creates a builder for configuring TCP server socket options.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TcpServerSocketOptionsbuild()Builds the TCP server socket options.TcpServerSocketOptions.BuilderwithReceiveBufferSize(Integer receiveBufferSize)Sets the receive buffer size for the server socket.TcpServerSocketOptions.BuilderwithReuseAddress(Boolean reuseAddress)Sets whether the server socket allows reuse of the local address.TcpServerSocketOptions.BuilderwithSoTimeout(Integer soTimeout)Sets the timeout for server socket operations.
-
-
-
Method Detail
-
withReuseAddress
public TcpServerSocketOptions.Builder withReuseAddress(Boolean reuseAddress)
Sets whether the server socket allows reuse of the local address.The default is
false.- Parameters:
reuseAddress-trueto allow address reuse;falseotherwise- Returns:
- this builder
-
withReceiveBufferSize
public TcpServerSocketOptions.Builder withReceiveBufferSize(Integer receiveBufferSize)
Sets the receive buffer size for the server socket.A
nullvalue leaves the receive buffer size at the underlying socket default.- Parameters:
receiveBufferSize- the receive buffer size in bytes, ornullto use the underlying socket default- Returns:
- this builder
- Throws:
IllegalArgumentException- ifreceiveBufferSizeis less than or equal to zero
-
withSoTimeout
public TcpServerSocketOptions.Builder withSoTimeout(Integer soTimeout)
Sets the timeout for server socket operations.A timeout of zero indicates an infinite timeout. A
nullvalue leaves the timeout at the underlying socket default.- Parameters:
soTimeout- the timeout in milliseconds, ornullto use the underlying socket default- Returns:
- this builder
- Throws:
IllegalArgumentException- ifsoTimeoutis negative
-
build
public TcpServerSocketOptions build()
Builds the TCP server socket options.- Returns:
- the configured TCP server socket options
-
-