public interface NetClient extends ClientSSLSupport<NetClient>, TCPSupport<NetClient>
Multiple connections to different servers can be made using the same instance.
This client supports a configurable number of connection attempts and a configurable delay between attempts.
If an instance is instantiated from an event loop then the handlers of the instance will always be called on that same event loop. If an instance is instantiated from some other arbitrary Java thread (i.e. when using embedded) then an event loop will be assigned to the instance and used when any of its handlers are called.
Instances of this class are thread-safe.
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the client.
|
NetClient |
connect(int port,
Handler<AsyncResult<NetSocket>> connectCallback)
Attempt to open a connection to a server at the specific
port and host localhost
The connect is done asynchronously and on success, a
NetSocket instance is supplied via the connectHandler instance |
NetClient |
connect(int port,
java.lang.String host,
Handler<AsyncResult<NetSocket>> connectHandler)
Attempt to open a connection to a server at the specific
port and host . |
int |
getConnectTimeout() |
int |
getReconnectAttempts()
Get the number of reconnect attempts
|
long |
getReconnectInterval()
Get the reconnect interval, in milliseconds.
|
NetClient |
setConnectTimeout(int timeout)
Set the connect timeout in milliseconds.
|
NetClient |
setReconnectAttempts(int attempts)
Set the number of reconnection attempts.
|
NetClient |
setReconnectInterval(long interval)
Set the reconnect interval, in milliseconds
|
isTrustAll, setTrustAll
getKeyStorePassword, getKeyStorePath, getTrustStorePassword, getTrustStorePath, isSSL, setKeyStorePassword, setKeyStorePath, setSSL, setSSLContext, setTrustStorePassword, setTrustStorePath
getSoLinger, isTCPKeepAlive, isTCPNoDelay, isUsePooledBuffers, setSoLinger, setTCPKeepAlive, setTCPNoDelay, setUsePooledBuffers
getReceiveBufferSize, getSendBufferSize, getTrafficClass, isReuseAddress, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setTrafficClass
NetClient connect(int port, Handler<AsyncResult<NetSocket>> connectCallback)
port
and host localhost
The connect is done asynchronously and on success, a
NetSocket
instance is supplied via the connectHandler
instanceNetClient connect(int port, java.lang.String host, Handler<AsyncResult<NetSocket>> connectHandler)
port
and host
.
host
can be a valid host name or IP address. The connect is done asynchronously and on success, a
NetSocket
instance is supplied via the connectHandler
instanceNetClient setReconnectAttempts(int attempts)
int getReconnectAttempts()
NetClient setReconnectInterval(long interval)
long getReconnectInterval()
NetClient setConnectTimeout(int timeout)
int getConnectTimeout()
void close()