Class TcpClientSocketOptions.Builder
- java.lang.Object
-
- com.kristensoft.kdc.TcpClientSocketOptions.Builder
-
- Enclosing class:
- TcpClientSocketOptions
public static class TcpClientSocketOptions.Builder extends Object
BuildsTcpClientSocketOptionsinstances.By default, TCP keep-alive is enabled.
SO_LINGERis enabled with a linger time of zero seconds so that closing the socket performs an immediate abortive close, allowing the remote endpoint to promptly detect that the connection has been terminated.Other socket options default to
null, indicating that the corresponding socket setting should not be changed.- See Also:
TcpClientSocketOptions
-
-
Constructor Summary
Constructors Constructor Description Builder()Creates a builder for configuring TCP client socket options.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TcpClientSocketOptionsbuild()Builds aTcpClientSocketOptionsinstance using the current builder configuration.TcpClientSocketOptions.BuilderwithKeepAlive(Boolean keepAlive)Sets whether TCP keep-alive is enabled.TcpClientSocketOptions.BuilderwithReceiveBufferSize(Integer receiveBufferSize)Sets the socket receive buffer size.TcpClientSocketOptions.BuilderwithReuseAddress(Boolean reuseAddress)Sets whether the socket address may be reused.TcpClientSocketOptions.BuilderwithSendBufferSize(Integer sendBufferSize)Sets the socket send buffer size.TcpClientSocketOptions.BuilderwithSoLinger(Boolean on, Integer time)Sets the socketSO_LINGERconfiguration.TcpClientSocketOptions.BuilderwithSoTimeout(Integer soTimeout)Sets the socket read timeout.TcpClientSocketOptions.BuilderwithTcpNoDelay(Boolean tcpNoDelay)Sets whether the Nagle algorithm is disabled for the socket.TcpClientSocketOptions.BuilderwithTcpOobInline(Boolean oobInline)Sets whether received TCP urgent data is placed inline with normal socket data.TcpClientSocketOptions.BuilderwithTrafficClass(Integer trafficClass)Sets the IP traffic class for the socket.
-
-
-
Method Detail
-
withKeepAlive
public TcpClientSocketOptions.Builder withKeepAlive(Boolean keepAlive)
Sets whether TCP keep-alive is enabled.A value of
nullleaves the corresponding socket setting unchanged.- Parameters:
keepAlive-trueto enable TCP keep-alive,falseto disable it, ornullto leave the socket setting unchanged- Returns:
- this builder
-
withReuseAddress
public TcpClientSocketOptions.Builder withReuseAddress(Boolean reuseAddress)
Sets whether the socket address may be reused.A value of
nullleaves the corresponding socket setting unchanged.- Parameters:
reuseAddress-trueto enable address reuse,falseto disable it, ornullto leave the socket setting unchanged- Returns:
- this builder
-
withReceiveBufferSize
public TcpClientSocketOptions.Builder withReceiveBufferSize(Integer receiveBufferSize)
Sets the socket receive buffer size.A value of
nullleaves the corresponding socket setting unchanged.- Parameters:
receiveBufferSize- the receive buffer size in bytes, ornullto leave the socket setting unchanged- Returns:
- this builder
-
withSendBufferSize
public TcpClientSocketOptions.Builder withSendBufferSize(Integer sendBufferSize)
Sets the socket send buffer size.A value of
nullleaves the corresponding socket setting unchanged.- Parameters:
sendBufferSize- the send buffer size in bytes, ornullto leave the socket setting unchanged- Returns:
- this builder
-
withSoTimeout
public TcpClientSocketOptions.Builder withSoTimeout(Integer soTimeout)
Sets the socket read timeout.A value of
nullleaves the corresponding socket setting unchanged.- Parameters:
soTimeout- the socket read timeout in milliseconds, ornullto leave the socket setting unchanged- Returns:
- this builder
-
withSoLinger
public TcpClientSocketOptions.Builder withSoLinger(Boolean on, Integer time)
Sets the socketSO_LINGERconfiguration.When enabled with a linger time of zero, closing the socket performs an immediate abortive close, allowing the remote endpoint to promptly detect that the connection has been terminated. If either argument is
null, theSO_LINGERsetting is not applied.- Parameters:
on-trueto enableSO_LINGER,falseto disable it, ornullto leave the socket setting unchangedtime- the linger time in seconds, ornullto leave the socket setting unchanged- Returns:
- this builder
-
withTcpNoDelay
public TcpClientSocketOptions.Builder withTcpNoDelay(Boolean tcpNoDelay)
Sets whether the Nagle algorithm is disabled for the socket.A value of
nullleaves the corresponding socket setting unchanged.- Parameters:
tcpNoDelay-trueto disable the Nagle algorithm,falseto enable it, ornullto leave the socket setting unchanged- Returns:
- this builder
-
withTrafficClass
public TcpClientSocketOptions.Builder withTrafficClass(Integer trafficClass)
Sets the IP traffic class for the socket.A value of
nullleaves the corresponding socket setting unchanged.- Parameters:
trafficClass- the IP traffic class value, ornullto leave the socket setting unchanged- Returns:
- this builder
-
withTcpOobInline
public TcpClientSocketOptions.Builder withTcpOobInline(Boolean oobInline)
Sets whether received TCP urgent data is placed inline with normal socket data.A value of
nullleaves the corresponding socket setting unchanged.- Parameters:
oobInline-trueto receive urgent data inline,falseotherwise, ornullto leave the socket setting unchanged- Returns:
- this builder
-
build
public TcpClientSocketOptions build()
Builds aTcpClientSocketOptionsinstance using the current builder configuration.- Returns:
- the configured TCP client socket options
-
-