public class DefaultNetClient extends java.lang.Object implements NetClient
| Constructor and Description |
|---|
DefaultNetClient(VertxInternal vertx) |
| 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() |
java.lang.String |
getKeyStorePassword() |
java.lang.String |
getKeyStorePath() |
int |
getReceiveBufferSize() |
int |
getReconnectAttempts()
Get the number of reconnect attempts
|
long |
getReconnectInterval()
Get the reconnect interval, in milliseconds.
|
int |
getSendBufferSize() |
int |
getSoLinger() |
int |
getTrafficClass() |
java.lang.String |
getTrustStorePassword() |
java.lang.String |
getTrustStorePath() |
boolean |
isReuseAddress() |
boolean |
isSSL() |
boolean |
isTCPKeepAlive() |
boolean |
isTCPNoDelay() |
boolean |
isTrustAll() |
boolean |
isUsePooledBuffers() |
NetClient |
setConnectTimeout(int timeout)
Set the connect timeout in milliseconds.
|
NetClient |
setKeyStorePassword(java.lang.String pwd)
Set the password for the SSL key store.
|
NetClient |
setKeyStorePath(java.lang.String path)
Set the path to the SSL key store.
|
NetClient |
setReceiveBufferSize(int size)
Set the TCP receive buffer size for connections created by this instance to
size in bytes. |
NetClient |
setReconnectAttempts(int attempts)
Set the number of reconnection attempts.
|
NetClient |
setReconnectInterval(long interval)
Set the reconnect interval, in milliseconds
|
NetClient |
setReuseAddress(boolean reuse)
Set the TCP reuseAddress setting for connections created by this instance to
reuse. |
NetClient |
setSendBufferSize(int size)
Set the TCP send buffer size for connections created by this instance to
size in bytes. |
NetClient |
setSoLinger(int linger)
Set the TCP soLinger setting for connections created by this instance to
linger. |
NetClient |
setSSL(boolean ssl)
If
ssl is true, this signifies that any connections will be SSL connections. |
NetClient |
setTCPKeepAlive(boolean keepAlive)
Set the TCP keepAlive setting for connections created by this instance to
keepAlive. |
NetClient |
setTCPNoDelay(boolean tcpNoDelay)
If
tcpNoDelay is set to true then Nagle's algorithm
will turned off for the TCP connections created by this instance. |
NetClient |
setTrafficClass(int trafficClass)
Set the TCP trafficClass setting for connections created by this instance to
trafficClass. |
NetClient |
setTrustAll(boolean trustAll)
If you want an SSL client to trust *all* server certificates rather than match them
against those in its trust store, you can set this to true.
|
NetClient |
setTrustStorePassword(java.lang.String pwd)
Set the password for the SSL trust store.
|
NetClient |
setTrustStorePath(java.lang.String path)
Set the path to the SSL trust store.
|
NetClient |
setUsePooledBuffers(boolean pooledBuffers)
Set if vertx should use pooled buffers for performance reasons.
|
public DefaultNetClient(VertxInternal vertx)
public NetClient connect(int port, java.lang.String host, Handler<AsyncResult<NetSocket>> connectHandler)
NetClientport 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 instancepublic NetClient connect(int port, Handler<AsyncResult<NetSocket>> connectCallback)
NetClientport and host localhost
The connect is done asynchronously and on success, a
NetSocket instance is supplied via the connectHandler instancepublic void close()
NetClientpublic NetClient setReconnectAttempts(int attempts)
NetClientsetReconnectAttempts in interface NetClientpublic int getReconnectAttempts()
NetClientgetReconnectAttempts in interface NetClientpublic NetClient setReconnectInterval(long interval)
NetClientsetReconnectInterval in interface NetClientpublic long getReconnectInterval()
NetClientgetReconnectInterval in interface NetClientpublic boolean isTCPNoDelay()
isTCPNoDelay in interface TCPSupport<NetClient>public int getSendBufferSize()
getSendBufferSize in interface TCPSupport<NetClient>public int getReceiveBufferSize()
getReceiveBufferSize in interface TCPSupport<NetClient>public boolean isTCPKeepAlive()
isTCPKeepAlive in interface TCPSupport<NetClient>public boolean isReuseAddress()
isReuseAddress in interface TCPSupport<NetClient>public int getSoLinger()
getSoLinger in interface TCPSupport<NetClient>public int getTrafficClass()
getTrafficClass in interface TCPSupport<NetClient>public int getConnectTimeout()
getConnectTimeout in interface NetClientpublic NetClient setTCPNoDelay(boolean tcpNoDelay)
TCPSupporttcpNoDelay is set to true then Nagle's algorithm
will turned off for the TCP connections created by this instance.setTCPNoDelay in interface TCPSupport<NetClient>public NetClient setSendBufferSize(int size)
TCPSupportsize in bytes.setSendBufferSize in interface TCPSupport<NetClient>public NetClient setReceiveBufferSize(int size)
TCPSupportsize in bytes.setReceiveBufferSize in interface TCPSupport<NetClient>public NetClient setTCPKeepAlive(boolean keepAlive)
TCPSupportkeepAlive.setTCPKeepAlive in interface TCPSupport<NetClient>public NetClient setReuseAddress(boolean reuse)
TCPSupportreuse.setReuseAddress in interface TCPSupport<NetClient>public NetClient setSoLinger(int linger)
TCPSupportlinger.
Using a negative value will disable soLinger.setSoLinger in interface TCPSupport<NetClient>public NetClient setTrafficClass(int trafficClass)
TCPSupporttrafficClass.setTrafficClass in interface TCPSupport<NetClient>public NetClient setConnectTimeout(int timeout)
NetClientsetConnectTimeout in interface NetClientpublic boolean isSSL()
isSSL in interface SSLSupport<NetClient>public java.lang.String getKeyStorePath()
getKeyStorePath in interface SSLSupport<NetClient>public java.lang.String getKeyStorePassword()
getKeyStorePassword in interface SSLSupport<NetClient>public java.lang.String getTrustStorePath()
getTrustStorePath in interface SSLSupport<NetClient>public java.lang.String getTrustStorePassword()
getTrustStorePassword in interface SSLSupport<NetClient>public boolean isTrustAll()
isTrustAll in interface ClientSSLSupport<NetClient>public NetClient setSSL(boolean ssl)
SSLSupportssl is true, this signifies that any connections will be SSL connections.setSSL in interface SSLSupport<NetClient>public NetClient setKeyStorePath(java.lang.String path)
SSLSupportSSLSupport.setSSL(boolean)
has been set to true.The SSL key store is a standard Java Key Store, and will contain the client certificate. Client certificates are only required if the server requests client authentication.
setKeyStorePath in interface SSLSupport<NetClient>public NetClient setKeyStorePassword(java.lang.String pwd)
SSLSupportSSLSupport.setSSL(boolean)
has been set to true.setKeyStorePassword in interface SSLSupport<NetClient>public NetClient setTrustStorePath(java.lang.String path)
SSLSupportSSLSupport.setSSL(boolean)
has been set to true.The trust store is a standard Java Key Store, and should contain the certificates of any servers that the client trusts.
setTrustStorePath in interface SSLSupport<NetClient>public NetClient setTrustStorePassword(java.lang.String pwd)
SSLSupportSSLSupport.setSSL(boolean)
has been set to true.setTrustStorePassword in interface SSLSupport<NetClient>public NetClient setTrustAll(boolean trustAll)
ClientSSLSupportUse this with caution as you may be exposed to "main in the middle" attacks
setTrustAll in interface ClientSSLSupport<NetClient>trustAll - Set to true if you want to trust all server certificatespublic NetClient setUsePooledBuffers(boolean pooledBuffers)
TCPSupportsetUsePooledBuffers in interface TCPSupport<NetClient>public boolean isUsePooledBuffers()
isUsePooledBuffers in interface TCPSupport<NetClient>true if pooled buffers are used