org.vertx.java.core.net.impl

## Class DefaultNetClient

- java.lang.Object
- - org.vertx.java.core.net.impl.DefaultNetClient

All Implemented Interfaces:
  NetClient

    public class DefaultNetClient
    extends java.lang.Object
    implements NetClient

### Constructor Summary

Constructors
Constructor and Description
`DefaultNetClient(VertxInternal vertx)`

### Method Summary

Methods
`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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### DefaultNetClient

    public DefaultNetClient(VertxInternal vertx)

### Method Detail

#### connect

    public NetClient connect(int port,
                    java.lang.String host,
                    Handler<NetSocket> connectHandler)

Description copied from interface: `NetClient`
Attempt to open a connection to a server at the specific `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` instance

Specified by:
  `connect` in interface `NetClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### connect

    public NetClient connect(int port,
                    Handler<NetSocket> connectCallback)

Description copied from interface: `NetClient`
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

Specified by:
  `connect` in interface `NetClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### close

    public void close()

Description copied from interface: `NetClient`
Close the client. Any sockets which have not been closed manually will be closed here.

Specified by:
  `close` in interface `NetClient`

#### setReconnectAttempts

    public NetClient setReconnectAttempts(int attempts)

Description copied from interface: `NetClient`
Set the number of reconnection attempts. In the event a connection attempt fails, the client will attempt to connect a further number of times, before it fails. Default value is zero.

Specified by:
  `setReconnectAttempts` in interface `NetClient`

#### getReconnectAttempts

    public int getReconnectAttempts()

Description copied from interface: `NetClient`
Get the number of reconnect attempts

Specified by:
  `getReconnectAttempts` in interface `NetClient`

#### setReconnectInterval

    public NetClient setReconnectInterval(long interval)

Description copied from interface: `NetClient`
Set the reconnect interval, in milliseconds

Specified by:
  `setReconnectInterval` in interface `NetClient`

#### getReconnectInterval

    public long getReconnectInterval()

Description copied from interface: `NetClient`
Get the reconnect interval, in milliseconds.

Specified by:
  `getReconnectInterval` in interface `NetClient`

#### exceptionHandler

    public void exceptionHandler(Handler<java.lang.Exception> handler)

Description copied from interface: `NetClient`
Set the exception handler. Any exceptions that occur during connect or later on will be notified via the `handler`. If no handler is supplied any exceptions will be printed to `System.err`

Specified by:
  `exceptionHandler` in interface `NetClient`

#### isTCPNoDelay

    public java.lang.Boolean isTCPNoDelay()

Specified by:
  `isTCPNoDelay` in interface `NetClient`
Returns:
  true if Nagle's algorithm is disabled.

#### getSendBufferSize

    public java.lang.Integer getSendBufferSize()

Specified by:
  `getSendBufferSize` in interface `NetClient`
Returns:
  The TCP send buffer size

#### getReceiveBufferSize

    public java.lang.Integer getReceiveBufferSize()

Specified by:
  `getReceiveBufferSize` in interface `NetClient`
Returns:
  The TCP receive buffer size

#### isTCPKeepAlive

    public java.lang.Boolean isTCPKeepAlive()

Specified by:
  `isTCPKeepAlive` in interface `NetClient`
Returns:
  true if TCP keep alive is enabled

#### isReuseAddress

    public java.lang.Boolean isReuseAddress()

Specified by:
  `isReuseAddress` in interface `NetClient`
Returns:
  The value of TCP reuse address

#### isSoLinger

    public java.lang.Boolean isSoLinger()

Specified by:
  `isSoLinger` in interface `NetClient`
Returns:
  the value of TCP so linger

#### getTrafficClass

    public java.lang.Integer getTrafficClass()

Specified by:
  `getTrafficClass` in interface `NetClient`
Returns:
  the value of TCP traffic class

#### getConnectTimeout

    public java.lang.Long getConnectTimeout()

Specified by:
  `getConnectTimeout` in interface `NetClient`
Returns:
  The connect timeout in milliseconds

#### getBossThreads

    public java.lang.Integer getBossThreads()

Specified by:
  `getBossThreads` in interface `NetClient`
Returns:
  The number of boss threads

#### setTCPNoDelay

    public NetClient setTCPNoDelay(boolean tcpNoDelay)

Description copied from interface: `NetClient`
If `tcpNoDelay` is set to `true` then Nagle's algorithm will turned off for the TCP connections created by this instance.

Specified by:
  `setTCPNoDelay` in interface `NetClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setSendBufferSize

    public NetClient setSendBufferSize(int size)

Description copied from interface: `NetClient`
Set the TCP send buffer size for connections created by this instance to `size` in bytes.

Specified by:
  `setSendBufferSize` in interface `NetClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setReceiveBufferSize

    public NetClient setReceiveBufferSize(int size)

Description copied from interface: `NetClient`
Set the TCP receive buffer size for connections created by this instance to `size` in bytes.

Specified by:
  `setReceiveBufferSize` in interface `NetClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setTCPKeepAlive

    public NetClient setTCPKeepAlive(boolean keepAlive)

Description copied from interface: `NetClient`
Set the TCP keepAlive setting for connections created by this instance to `keepAlive`.

Specified by:
  `setTCPKeepAlive` in interface `NetClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setReuseAddress

    public NetClient setReuseAddress(boolean reuse)

Description copied from interface: `NetClient`
Set the TCP reuseAddress setting for connections created by this instance to `reuse`.

Specified by:
  `setReuseAddress` in interface `NetClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setSoLinger

    public NetClient setSoLinger(boolean linger)

Description copied from interface: `NetClient`
Set the TCP soLinger setting for connections created by this instance to `linger`.

Specified by:
  `setSoLinger` in interface `NetClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setTrafficClass

    public NetClient setTrafficClass(int trafficClass)

Description copied from interface: `NetClient`
Set the TCP trafficClass setting for connections created by this instance to `trafficClass`.

Specified by:
  `setTrafficClass` in interface `NetClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setConnectTimeout

    public NetClient setConnectTimeout(long timeout)

Description copied from interface: `NetClient`
Set the connect timeout in milliseconds.

Specified by:
  `setConnectTimeout` in interface `NetClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setBossThreads

    public NetClient setBossThreads(int threads)

Description copied from interface: `NetClient`
Set the number of boss threads to use. Boss threads are used to make connections.

Specified by:
  `setBossThreads` in interface `NetClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### isSSL

    public boolean isSSL()

Specified by:
  `isSSL` in interface `NetClient`
Returns:
  true if this client will make SSL connections

#### getKeyStorePath

    public java.lang.String getKeyStorePath()

Specified by:
  `getKeyStorePath` in interface `NetClient`
Returns:
  The path to the key store

#### getKeyStorePassword

    public java.lang.String getKeyStorePassword()

Specified by:
  `getKeyStorePassword` in interface `NetClient`
Returns:
  The keystore password

#### getTrustStorePath

    public java.lang.String getTrustStorePath()

Specified by:
  `getTrustStorePath` in interface `NetClient`
Returns:
  The trust store path

#### getTrustStorePassword

    public java.lang.String getTrustStorePassword()

Specified by:
  `getTrustStorePassword` in interface `NetClient`
Returns:
  The trust store password

#### getClientAuth

    public TCPSSLHelper.ClientAuth getClientAuth()

#### getSSLContext

    public javax.net.ssl.SSLContext getSSLContext()

#### isTrustAll

    public boolean isTrustAll()

Specified by:
  `isTrustAll` in interface `NetClient`
Returns:
  true if this client will trust all server certificates.

#### setSSL

    public NetClient setSSL(boolean ssl)

Description copied from interface: `NetClient`
If `ssl` is `true`, this signifies that any connections will be SSL connections.

Specified by:
  `setSSL` in interface `NetClient`
Returns:
  A reference to this, so multiple invocations can be chained together.

#### setKeyStorePath

    public NetClient setKeyStorePath(java.lang.String path)

Description copied from interface: `NetClient`
Set the path to the SSL key store. This method should only be used in SSL mode, i.e. after `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.

Specified by:
  `setKeyStorePath` in interface `NetClient`
Returns:
  A reference to this, so multiple invocations can be chained together.

#### setKeyStorePassword

    public NetClient setKeyStorePassword(java.lang.String pwd)

Description copied from interface: `NetClient`
Set the password for the SSL key store. This method should only be used in SSL mode, i.e. after `NetClient.setSSL(boolean)` has been set to `true`.

Specified by:
  `setKeyStorePassword` in interface `NetClient`
Returns:
  A reference to this, so multiple invocations can be chained together.

#### setTrustStorePath

    public NetClient setTrustStorePath(java.lang.String path)

Description copied from interface: `NetClient`
Set the path to the SSL trust store. This method should only be used in SSL mode, i.e. after `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.

Specified by:
  `setTrustStorePath` in interface `NetClient`
Returns:
  A reference to this, so multiple invocations can be chained together.

#### setTrustStorePassword

    public NetClient setTrustStorePassword(java.lang.String pwd)

Description copied from interface: `NetClient`
Set the password for the SSL trust store. This method should only be used in SSL mode, i.e. after `NetClient.setSSL(boolean)` has been set to `true`.

Specified by:
  `setTrustStorePassword` in interface `NetClient`
Returns:
  A reference to this, so multiple invocations can be chained together.

#### setTrustAll

    public NetClient setTrustAll(boolean trustAll)

Description copied from interface: `NetClient`
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.

Use this with caution as you may be exposed to "main in the middle" attacks

Specified by:
  `setTrustAll` in interface `NetClient`
Parameters:
  `trustAll` - Set to true if you want to trust all server certificates