Class SocketConfig
java.lang.Object
ecmwf.common.rmi.SocketConfig
- Direct Known Subclasses:
RMIClientSocketFactory,RMIServerSocketFactory,RMISSLServerSocketFactory,RMISSLSocketFactory
The Class SocketConfig.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiates a new socket configuration.SocketConfig(ClientSocketStatistics statistics, String name) Instantiates a new socket config.SocketConfig(ClientSocketStatistics statistics, String name, boolean debug) Instantiates a new socket config.SocketConfig(String name) Instantiates a new socket config. -
Method Summary
Modifier and TypeMethodDescriptionConfig to string.configToString(ServerSocket socket) Config to string.configToString(Socket socket) Config to string.protected voidconfigureConnectedSocket(Socket socket) Configure a connected socket.intGets the back log.static SSLContextgetBlindlyTrustingSSLContext(String protocol) Gets the blindly trusting SSL context.intGets the connect time out.getHost()Gets the host.Gets the host.Gets the interruptible.Gets the keep alive.Gets the listen address.static final StringGets the local address.getName()Gets the name.intgetPort()Gets the port.intgetPort(int defaultPort) Gets the port.booleanGets the privileged local port.Gets the public address.static final StringgetPublicAddress(String name) Gets the public address.intGets the receive buffer size.Gets the reuse address.intGets the sends the buffer size.intGets the server port.Gets the server socket.getServerSocket(int port) Gets the server socket.getServerSocket(ServerSocketFactory factory, int port) Gets the server socket.Gets the socket.getSocket(int localPort) Gets the socket.Gets the socket.Gets the socket.getSocket(ServerSocket serverSocket) Gets the socket.getSocket(SocketFactory factory) Gets the socket.getSocket(SocketFactory factory, int localPort) Gets the socket.getSocket(SocketFactory factory, String host, int port) Gets the socket.getSocket(SocketFactory factory, String host, int port, int localPort) Gets the socket.Gets the socket factory.intGets the SO time out.getSSLSocketFactory(String protocol, boolean sslValidation) Gets the SSL socket factory.protected ClientSocketStatisticsGets the statistics.Gets the tcp no delay.booleangetTrace()Gets the trace.static final booleanChecks if is current rmi server thread socket alive.protected voidLoad.voidsetBackLog(int backLog) Sets the back log.voidsetConnectTimeOut(int timeOut) Sets the connect time out.voidsetDebug(boolean debug) Sets the debug.voidSets the host.voidsetInterruptible(boolean interruptible) Sets the interruptible.voidsetKeepAlive(Boolean keepAlive) Sets the keep alive.voidsetListenAddress(String listenAddress) Sets the listen address.voidSets the name.voidsetPort(int port) Sets the port.voidsetPrivilegedLocalPort(boolean privilegedLocalPort) Sets the privileged local port.voidsetPublicAddress(String publicAddress) Sets the public address.voidsetReceiveBufferSize(int receiveBufferSize) Sets the receive buffer size.voidsetReuseAddress(Boolean reuseAddress) Sets the reuse address.voidsetSendBufferSize(int sendBufferSize) Sets the sends the buffer size.voidsetServerPort(int serverPort) Sets the server port.voidsetSOMaxPacingRate(ByteSize soMaxPacingRate) Set a SO option.voidsetSOMaxPacingRate(Integer soMaxPacingRate) Set a SO option.voidsetSoTimeOut(int timeOut) Sets the so time out.voidsetTCPCongestion(String tcpCongestion) Set a TCP option.voidsetTCPKeepAliveInterval(Integer tcpKeepAliveInterval) Set a TCP option.voidsetTCPKeepAliveProbes(Integer tcpKeepAliveProbes) Set a TCP option.voidsetTCPKeepAliveTime(Integer tcpKeepAliveTime) Set a TCP option.voidsetTCPLinger(Boolean tcpLingerEnable, Integer tcpLingerTime) Controls the behavior of a socket when it is closed and there is unsent data.voidsetTCPMaxSegment(Integer tcpMaxSegment) Set a TCP option.voidsetTcpNoDelay(Boolean tcpNoDelay) Sets the tcp no delay.voidsetTCPOptions(Socket socket) Sets the required socket or serverSocket options.voidsetTCPQuickAck(Boolean tcpQuickAck) Controls whether the TCP stack should quickly acknowledge incoming data.voidsetTCPTimeStamp(Boolean tcpTimeStamp) Set a TCP option.voidsetTCPUserTimeout(Integer tcpUserTimeout) Provides a way to control the timeout for unacknowledged data on a TCP connection.voidsetTCPWindowClamp(Integer tcpWindowClamp) Set a TCP option.voidsetTrace(boolean trace) Sets the trace.protected SocketConfigwithClientSocketFactory(ClientSocketFactory clientSocketFactory) With client socket factory.
-
Field Details
-
MIN_PORT
public static final int MIN_PORTThe Constant MIN_PORT. -
MAX_PORT
public static final int MAX_PORTThe Constant MAX_PORT.
-
-
Constructor Details
-
SocketConfig
protected SocketConfig()Instantiates a new socket configuration. -
SocketConfig
-
SocketConfig
Instantiates a new socket config.- Parameters:
statistics- the statisticsname- the name
-
SocketConfig
Instantiates a new socket config.- Parameters:
statistics- the statisticsname- the namedebug- the debug
-
-
Method Details
-
load
-
getStatistics
-
withClientSocketFactory
With client socket factory.- Parameters:
clientSocketFactory- the client socket factory- Returns:
- the socket config
-
setName
-
setDebug
public void setDebug(boolean debug) Sets the debug.- Parameters:
debug- the new debug
-
setTrace
public void setTrace(boolean trace) Sets the trace.- Parameters:
trace- the new trace
-
setListenAddress
Sets the listen address.- Parameters:
listenAddress- the new listen address
-
setPublicAddress
Sets the public address.- Parameters:
publicAddress- the new public address
-
setReceiveBufferSize
public void setReceiveBufferSize(int receiveBufferSize) Sets the receive buffer size.- Parameters:
receiveBufferSize- the new receive buffer size
-
setSendBufferSize
public void setSendBufferSize(int sendBufferSize) Sets the sends the buffer size.- Parameters:
sendBufferSize- the new sends the buffer size
-
setSoTimeOut
public void setSoTimeOut(int timeOut) Sets the so time out.- Parameters:
timeOut- the new so time out
-
setConnectTimeOut
public void setConnectTimeOut(int timeOut) Sets the connect time out.- Parameters:
timeOut- the new connect time out
-
setBackLog
public void setBackLog(int backLog) Sets the back log.- Parameters:
backLog- the new back log
-
setKeepAlive
Sets the keep alive.- Parameters:
keepAlive- the new keep alive
-
setTcpNoDelay
Sets the tcp no delay.- Parameters:
tcpNoDelay- the new tcp no delay
-
setReuseAddress
Sets the reuse address.- Parameters:
reuseAddress- the new reuse address
-
setInterruptible
public void setInterruptible(boolean interruptible) Sets the interruptible.- Parameters:
interruptible- the new interruptible
-
setPrivilegedLocalPort
public void setPrivilegedLocalPort(boolean privilegedLocalPort) Sets the privileged local port.- Parameters:
privilegedLocalPort- the new privileged local port
-
setTCPCongestion
Set a TCP option.- Parameters:
tcpCongestion- the TCP congestion algorithm name
-
setSOMaxPacingRate
Set a SO option.- Parameters:
soMaxPacingRate- set the maximum transmit rate in bytes per second for the socket.
-
setSOMaxPacingRate
Set a SO option.- Parameters:
soMaxPacingRate- set the maximum transmit rate in bytes per second for the socket.
-
setTCPMaxSegment
Set a TCP option.- Parameters:
tcpMaxSegment- maximum amount of data that can be sent in a single TCP segment.
-
setTCPTimeStamp
Set a TCP option.- Parameters:
tcpTimeStamp- enables or disables the use of timestamps in TCP packets
-
setTCPWindowClamp
Set a TCP option.- Parameters:
tcpWindowClamp- bound the size of the advertised window to this value
-
setTCPKeepAliveTime
Set a TCP option.- Parameters:
tcpKeepAliveTime- the interval between the last data packet sent (simple ACKs are not considered data) and the first keepalive probe; after the connection is marked to need keepalive, this counter is not used any further
-
setTCPKeepAliveInterval
Set a TCP option.- Parameters:
tcpKeepAliveInterval- the interval between subsequential keepalive probes, regardless of what the connection has exchanged in the meantime
-
setTCPKeepAliveProbes
Set a TCP option.- Parameters:
tcpKeepAliveProbes- the number of unacknowledged probes to send before considering the connection dead and notifying the application layer
-
setTCPLinger
Controls the behavior of a socket when it is closed and there is unsent data. It specifies whether the socket should linger for a specified amount of time before closing. The TCP_LINGER option is often used to ensure that all data is sent before the socket is closed.- Parameters:
tcpLingerEnable- the tcp linger enabletcpLingerTime- the amount of time, in seconds, the socket should linger before closing
-
setTCPUserTimeout
Provides a way to control the timeout for unacknowledged data on a TCP connection.- Parameters:
tcpUserTimeout- maximum amount of time, in milliseconds, that transmitted data may remain unacknowledged before an error is returned
-
setTCPQuickAck
Controls whether the TCP stack should quickly acknowledge incoming data.- Parameters:
tcpQuickAck- when enabled, the TCP stack sends immediate acknowledgment for incoming data without waiting for the delayed acknowledgment timer.
-
setTCPOptions
Sets the required socket or serverSocket options.- Parameters:
socket- the new TCP options- Throws:
IOException- Signals that an I/O exception has occurred.
-
setHost
-
setPort
public void setPort(int port) Sets the port.- Parameters:
port- the new port
-
setServerPort
public void setServerPort(int serverPort) Sets the server port.- Parameters:
serverPort- the new server port
-
getName
-
getTrace
public boolean getTrace()Gets the trace.- Returns:
- the trace
-
getListenAddress
-
getPublicAddress
-
getReceiveBufferSize
public int getReceiveBufferSize()Gets the receive buffer size.- Returns:
- the receive buffer size
-
getSendBufferSize
public int getSendBufferSize()Gets the sends the buffer size.- Returns:
- the sends the buffer size
-
getSOTimeOut
public int getSOTimeOut()Gets the SO time out.- Returns:
- the SO time out
-
getConnectTimeOut
public int getConnectTimeOut()Gets the connect time out.- Returns:
- the connect time out
-
getBackLog
public int getBackLog()Gets the back log.- Returns:
- the back log
-
getKeepAlive
-
getTcpNoDelay
-
getReuseAddress
-
getInterruptible
-
getPrivilegedLocalPort
public boolean getPrivilegedLocalPort()Gets the privileged local port.- Returns:
- the privileged local port
-
getHost
-
getHost
-
getPort
public int getPort()Gets the port.- Returns:
- the port
-
getServerPort
public int getServerPort()Gets the server port.- Returns:
- the server port
-
getPort
public int getPort(int defaultPort) Gets the port.- Parameters:
defaultPort- the default port- Returns:
- the port
-
getSocket
Gets the socket.- Returns:
- the socket
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getSocket
Gets the socket.- Parameters:
factory- the factory- Returns:
- the socket
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getSocket
Gets the socket.- Parameters:
localPort- the local port- Returns:
- the socket
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getSocket
Gets the socket.- Parameters:
factory- the factorylocalPort- the local port- Returns:
- the socket
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getSocket
Gets the socket.- Parameters:
host- the hostport- the port- Returns:
- the socket
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getSocket
Gets the socket.- Parameters:
factory- the factoryhost- the hostport- the port- Returns:
- the socket
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getSocket
Gets the socket.- Parameters:
host- the hostport- the portlocalPort- the local port- Returns:
- the socket
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getSocket
public Socket getSocket(SocketFactory factory, String host, int port, int localPort) throws IOException Gets the socket.- Parameters:
factory- the factoryhost- the hostport- the portlocalPort- the local port- Returns:
- the socket
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getSocket
Gets the socket.- Parameters:
serverSocket- the server socket- Returns:
- the socket
- Throws:
IOException- Signals that an I/O exception has occurred.
-
configureConnectedSocket
Configure a connected socket. Used internally by the ClientSocketFactory and SSLClientSocketFactory.- Parameters:
socket- the socket- Throws:
IOException- Signals that an I/O exception has occurred.
-
getServerSocket
Gets the server socket.- Returns:
- the server socket
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getServerSocket
Gets the server socket.- Parameters:
port- the port- Returns:
- the server socket
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getServerSocket
Gets the server socket.- Parameters:
factory- the factoryport- the port- Returns:
- the server socket
- Throws:
IOException- Signals that an I/O exception has occurred.
-
isCurrentRMIServerThreadSocketAlive
public static final boolean isCurrentRMIServerThreadSocketAlive()Checks if is current rmi server thread socket alive.- Returns:
- true, if is current rmi server thread socket alive
-
getPublicAddress
-
getLocalAddress
-
configToString
-
configToString
Config to string.- Parameters:
socket- the socket- Returns:
- the string
- Throws:
SocketException- the socket exception
-
configToString
Config to string.- Parameters:
socket- the socket- Returns:
- the string
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getSocketFactory
-
getSSLSocketFactory
public SSLClientSocketFactory getSSLSocketFactory(String protocol, boolean sslValidation) throws KeyManagementException, NoSuchAlgorithmException Gets the SSL socket factory.- Parameters:
protocol- the protocolsslValidation- the ssl validation- Returns:
- the SSL socket factory
- Throws:
KeyManagementException- the key management exceptionNoSuchAlgorithmException- the no such algorithm exception
-
getBlindlyTrustingSSLContext
public static SSLContext getBlindlyTrustingSSLContext(String protocol) throws NoSuchAlgorithmException, KeyManagementException Gets the blindly trusting SSL context.- Parameters:
protocol- the protocol- Returns:
- the blindly trusting SSL context
- Throws:
NoSuchAlgorithmException- the no such algorithm exceptionKeyManagementException- the key management exception
-