| Constructor and Description |
|---|
DefaultNetClient(VertxInternal vertx) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the client.
|
NetClient |
connect(int port,
Handler<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<NetSocket> connectHandler)
Attempt to open a connection to a server at the specific
port and host. |
void |
exceptionHandler(Handler<java.lang.Exception> handler)
Set the exception handler.
|
java.lang.Integer |
getBossThreads() |
TCPSSLHelper.ClientAuth |
getClientAuth() |
java.lang.Long |
getConnectTimeout() |
java.lang.String |
getKeyStorePassword() |
java.lang.String |
getKeyStorePath() |
java.lang.Integer |
getReceiveBufferSize() |
int |
getReconnectAttempts()
Get the number of reconnect attempts
|
long |
getReconnectInterval()
Get the reconnect interval, in milliseconds.
|
java.lang.Integer |
getSendBufferSize() |
javax.net.ssl.SSLContext |
getSSLContext() |
java.lang.Integer |
getTrafficClass() |
java.lang.String |
getTrustStorePassword() |
java.lang.String |
getTrustStorePath() |
java.lang.Boolean |
isReuseAddress() |
java.lang.Boolean |
isSoLinger() |
boolean |
isSSL() |
java.lang.Boolean |
isTCPKeepAlive() |
java.lang.Boolean |
isTCPNoDelay() |
boolean |
isTrustAll() |
NetClient |
setBossThreads(int threads)
Set the number of boss threads to use.
|
NetClient |
setConnectTimeout(long 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(boolean 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.
|
public DefaultNetClient(VertxInternal vertx)
public NetClient connect(int port, java.lang.String host, Handler<NetSocket> connectHandler)
NetClientport and host.
host can be a valid host name or IP addresss. The connect is done asynchronously and on success, a
NetSocket instance is supplied via the connectHandler instancepublic NetClient connect(int port, Handler<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 void exceptionHandler(Handler<java.lang.Exception> handler)
NetClienthandler.
If no handler is supplied any exceptions will be printed to System.errexceptionHandler in interface NetClientpublic java.lang.Boolean isTCPNoDelay()
isTCPNoDelay in interface NetClientpublic java.lang.Integer getSendBufferSize()
getSendBufferSize in interface NetClientpublic java.lang.Integer getReceiveBufferSize()
getReceiveBufferSize in interface NetClientpublic java.lang.Boolean isTCPKeepAlive()
isTCPKeepAlive in interface NetClientpublic java.lang.Boolean isReuseAddress()
isReuseAddress in interface NetClientpublic java.lang.Boolean isSoLinger()
isSoLinger in interface NetClientpublic java.lang.Integer getTrafficClass()
getTrafficClass in interface NetClientpublic java.lang.Long getConnectTimeout()
getConnectTimeout in interface NetClientpublic java.lang.Integer getBossThreads()
getBossThreads in interface NetClientpublic NetClient setTCPNoDelay(boolean tcpNoDelay)
NetClienttcpNoDelay is set to true then Nagle's algorithm
will turned off for the TCP connections created by this instance.setTCPNoDelay in interface NetClientpublic NetClient setSendBufferSize(int size)
NetClientsize in bytes.setSendBufferSize in interface NetClientpublic NetClient setReceiveBufferSize(int size)
NetClientsize in bytes.setReceiveBufferSize in interface NetClientpublic NetClient setTCPKeepAlive(boolean keepAlive)
NetClientkeepAlive.setTCPKeepAlive in interface NetClientpublic NetClient setReuseAddress(boolean reuse)
NetClientreuse.setReuseAddress in interface NetClientpublic NetClient setSoLinger(boolean linger)
NetClientlinger.setSoLinger in interface NetClientpublic NetClient setTrafficClass(int trafficClass)
NetClienttrafficClass.setTrafficClass in interface NetClientpublic NetClient setConnectTimeout(long timeout)
NetClientsetConnectTimeout in interface NetClientpublic NetClient setBossThreads(int threads)
NetClientsetBossThreads in interface NetClientpublic boolean isSSL()
public java.lang.String getKeyStorePath()
getKeyStorePath in interface NetClientpublic java.lang.String getKeyStorePassword()
getKeyStorePassword in interface NetClientpublic java.lang.String getTrustStorePath()
getTrustStorePath in interface NetClientpublic java.lang.String getTrustStorePassword()
getTrustStorePassword in interface NetClientpublic TCPSSLHelper.ClientAuth getClientAuth()
public javax.net.ssl.SSLContext getSSLContext()
public boolean isTrustAll()
isTrustAll in interface NetClientpublic NetClient setSSL(boolean ssl)
NetClientssl is true, this signifies that any connections will be SSL connections.public NetClient setKeyStorePath(java.lang.String path)
NetClientNetClient.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 NetClientpublic NetClient setKeyStorePassword(java.lang.String pwd)
NetClientNetClient.setSSL(boolean)
has been set to true.setKeyStorePassword in interface NetClientpublic NetClient setTrustStorePath(java.lang.String path)
NetClientNetClient.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.
If you wish the client to trust all server certificates you can use the NetClient.setTrustAll(boolean) method.
setTrustStorePath in interface NetClientpublic NetClient setTrustStorePassword(java.lang.String pwd)
NetClientNetClient.setSSL(boolean)
has been set to true.setTrustStorePassword in interface NetClientpublic NetClient setTrustAll(boolean trustAll)
NetClientUse this with caution as you may be exposed to "main in the middle" attacks
setTrustAll in interface NetClienttrustAll - Set to true if you want to trust all server certificates