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)
NetClient
port
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)
NetClient
port
and host localhost
The connect is done asynchronously and on success, a
NetSocket
instance is supplied via the connectHandler
instancepublic void close()
NetClient
public NetClient setReconnectAttempts(int attempts)
NetClient
setReconnectAttempts
in interface NetClient
public int getReconnectAttempts()
NetClient
getReconnectAttempts
in interface NetClient
public NetClient setReconnectInterval(long interval)
NetClient
setReconnectInterval
in interface NetClient
public long getReconnectInterval()
NetClient
getReconnectInterval
in interface NetClient
public void exceptionHandler(Handler<java.lang.Exception> handler)
NetClient
handler
.
If no handler is supplied any exceptions will be printed to System.err
exceptionHandler
in interface NetClient
public java.lang.Boolean isTCPNoDelay()
isTCPNoDelay
in interface NetClient
public java.lang.Integer getSendBufferSize()
getSendBufferSize
in interface NetClient
public java.lang.Integer getReceiveBufferSize()
getReceiveBufferSize
in interface NetClient
public java.lang.Boolean isTCPKeepAlive()
isTCPKeepAlive
in interface NetClient
public java.lang.Boolean isReuseAddress()
isReuseAddress
in interface NetClient
public java.lang.Boolean isSoLinger()
isSoLinger
in interface NetClient
public java.lang.Integer getTrafficClass()
getTrafficClass
in interface NetClient
public java.lang.Long getConnectTimeout()
getConnectTimeout
in interface NetClient
public java.lang.Integer getBossThreads()
getBossThreads
in interface NetClient
public NetClient setTCPNoDelay(boolean tcpNoDelay)
NetClient
tcpNoDelay
is set to true
then Nagle's algorithm
will turned off for the TCP connections created by this instance.setTCPNoDelay
in interface NetClient
public NetClient setSendBufferSize(int size)
NetClient
size
in bytes.setSendBufferSize
in interface NetClient
public NetClient setReceiveBufferSize(int size)
NetClient
size
in bytes.setReceiveBufferSize
in interface NetClient
public NetClient setTCPKeepAlive(boolean keepAlive)
NetClient
keepAlive
.setTCPKeepAlive
in interface NetClient
public NetClient setReuseAddress(boolean reuse)
NetClient
reuse
.setReuseAddress
in interface NetClient
public NetClient setSoLinger(boolean linger)
NetClient
linger
.setSoLinger
in interface NetClient
public NetClient setTrafficClass(int trafficClass)
NetClient
trafficClass
.setTrafficClass
in interface NetClient
public NetClient setConnectTimeout(long timeout)
NetClient
setConnectTimeout
in interface NetClient
public NetClient setBossThreads(int threads)
NetClient
setBossThreads
in interface NetClient
public boolean isSSL()
public java.lang.String getKeyStorePath()
getKeyStorePath
in interface NetClient
public java.lang.String getKeyStorePassword()
getKeyStorePassword
in interface NetClient
public java.lang.String getTrustStorePath()
getTrustStorePath
in interface NetClient
public java.lang.String getTrustStorePassword()
getTrustStorePassword
in interface NetClient
public TCPSSLHelper.ClientAuth getClientAuth()
public javax.net.ssl.SSLContext getSSLContext()
public boolean isTrustAll()
isTrustAll
in interface NetClient
public NetClient setSSL(boolean ssl)
NetClient
ssl
is true
, this signifies that any connections will be SSL connections.public NetClient setKeyStorePath(java.lang.String path)
NetClient
NetClient.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 NetClient
public NetClient setKeyStorePassword(java.lang.String pwd)
NetClient
NetClient.setSSL(boolean)
has been set to true
.setKeyStorePassword
in interface NetClient
public NetClient setTrustStorePath(java.lang.String path)
NetClient
NetClient.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 NetClient
public NetClient setTrustStorePassword(java.lang.String pwd)
NetClient
NetClient.setSSL(boolean)
has been set to true
.setTrustStorePassword
in interface NetClient
public NetClient setTrustAll(boolean trustAll)
NetClient
Use this with caution as you may be exposed to "main in the middle" attacks
setTrustAll
in interface NetClient
trustAll
- Set to true if you want to trust all server certificates