io.vertx.core.net

## Interface NetClient

- All Superinterfaces:
    Measured

      public interface NetClient
      extends Measured

  A TCP client.

  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.

  Author:
    Tim Fox

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `Future<Void>` | `close()` Like `close(Handler)` but returns a `Future` of the asynchronous result
    `void` | `close(Handler<AsyncResult<Void>> handler)` Close the client.
    `Future<NetSocket>` | `connect(int port, String host)` Like `connect(int, String, Handler)` but returns a `Future` of the asynchronous result
    `NetClient` | `connect(int port, String host, Handler<AsyncResult<NetSocket>> connectHandler)` Open a connection to a server at the specific `port` and `host`.
    `Future<NetSocket>` | `connect(int port, String host, String serverName)` Like `connect(int, String, String, Handler)` but returns a `Future` of the asynchronous result
    `NetClient` | `connect(int port, String host, String serverName, Handler<AsyncResult<NetSocket>> connectHandler)` Open a connection to a server at the specific `port` and `host`.
    `Future<NetSocket>` | `connect(SocketAddress remoteAddress)` Like `connect(SocketAddress, Handler)` but returns a `Future` of the asynchronous result
    `NetClient` | `connect(SocketAddress remoteAddress, Handler<AsyncResult<NetSocket>> connectHandler)` Open a connection to a server at the specific `remoteAddress`.
    `Future<NetSocket>` | `connect(SocketAddress remoteAddress, String serverName)` Like `connect(SocketAddress, String, Handler)` but returns a `Future` of the asynchronous result
    `NetClient` | `connect(SocketAddress remoteAddress, String serverName, Handler<AsyncResult<NetSocket>> connectHandler)` Open a connection to a server at the specific `remoteAddress`.
    `default Future<Boolean>` | `updateSSLOptions(SSLOptions options)` Update the client with new SSL `options`, the update happens if the options object is valid and different from the existing options object.
    `Future<Boolean>` | `updateSSLOptions(SSLOptions options, boolean force)` Update the client with new SSL `options`, the update happens if the options object is valid and different from the existing options object.
    `default void` | `updateSSLOptions(SSLOptions options, boolean force, Handler<AsyncResult<Boolean>> handler)` Like `updateSSLOptions(SSLOptions)` but supplying a handler that will be called when the update happened (or has failed).
    `default void` | `updateSSLOptions(SSLOptions options, Handler<AsyncResult<Boolean>> handler)` Like `updateSSLOptions(SSLOptions)` but supplying a handler that will be called when the update happened (or has failed).

    - ### Methods inherited from interface io.vertx.core.metrics.Measured

      `isMetricsEnabled`

- - ### Method Detail

    - #### connect

          NetClient connect(int port,
                            String host,
                            Handler<AsyncResult<NetSocket>> connectHandler)

      Open a connection to a server at the specific `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` instance

      Parameters:
        `port` - the port
        `host` - the host
      Returns:
        a reference to this, so the API can be used fluently

    - #### connect

          Future<NetSocket> connect(int port,
                                    String host)

      Like `connect(int, String, Handler)` but returns a `Future` of the asynchronous result

    - #### connect

          NetClient connect(int port,
                            String host,
                            String serverName,
                            Handler<AsyncResult<NetSocket>> connectHandler)

      Open a connection to a server at the specific `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` instance

      Parameters:
        `port` - the port
        `host` - the host
        `serverName` - the SNI server name
      Returns:
        a reference to this, so the API can be used fluently

    - #### connect

          Future<NetSocket> connect(int port,
                                    String host,
                                    String serverName)

      Like `connect(int, String, String, Handler)` but returns a `Future` of the asynchronous result

    - #### connect

          NetClient connect(SocketAddress remoteAddress,
                            Handler<AsyncResult<NetSocket>> connectHandler)

      Open a connection to a server at the specific `remoteAddress`.

      The connect is done asynchronously and on success, a `NetSocket` instance is supplied via the `connectHandler` instance

      Parameters:
        `remoteAddress` - the remote address
      Returns:
        a reference to this, so the API can be used fluently

    - #### connect

          Future<NetSocket> connect(SocketAddress remoteAddress)

      Like `connect(SocketAddress, Handler)` but returns a `Future` of the asynchronous result

    - #### connect

          NetClient connect(SocketAddress remoteAddress,
                            String serverName,
                            Handler<AsyncResult<NetSocket>> connectHandler)

      Open a connection to a server at the specific `remoteAddress`.

      The connect is done asynchronously and on success, a `NetSocket` instance is supplied via the `connectHandler` instance

      Parameters:
        `remoteAddress` - the remote address
        `serverName` - the SNI server name
      Returns:
        a reference to this, so the API can be used fluently

    - #### connect

          Future<NetSocket> connect(SocketAddress remoteAddress,
                                    String serverName)

      Like `connect(SocketAddress, String, Handler)` but returns a `Future` of the asynchronous result

    - #### close

          void close(Handler<AsyncResult<Void>> handler)

      Close the client.

      Any sockets which have not been closed manually will be closed here. The close is asynchronous and may not complete until some time after the method has returned.

    - #### close

          Future<Void> close()

      Like `close(Handler)` but returns a `Future` of the asynchronous result

    - #### updateSSLOptions

          default Future<Boolean> updateSSLOptions(SSLOptions options)

      Update the client with new SSL `options`, the update happens if the options object is valid and different from the existing options object.

      The boolean succeeded future result indicates whether the update occurred.

      Parameters:
        `options` - the new SSL options
      Returns:
        a future signaling the update success

    - #### updateSSLOptions

          default void updateSSLOptions(SSLOptions options,
                                        Handler<AsyncResult<Boolean>> handler)

      Like `updateSSLOptions(SSLOptions)` but supplying a handler that will be called when the update happened (or has failed).
      Parameters:
        `options` - the new SSL options
        `handler` - the update handler

    - #### updateSSLOptions

          Future<Boolean> updateSSLOptions(SSLOptions options,
                                           boolean force)

      Update the client with new SSL `options`, the update happens if the options object is valid and different from the existing options object.

      The `options` object is compared using its `equals` method against the existing options to prevent an update when the objects are equals since loading options can be costly, this can happen for share TCP servers. When object are equals, setting `force` to `true` forces the update.

      The boolean succeeded future result indicates whether the update occurred.

      Parameters:
        `options` - the new SSL options
        `force` - force the update when options are equals
      Returns:
        a future signaling the update success

    - #### updateSSLOptions

          default void updateSSLOptions(SSLOptions options,
                                        boolean force,
                                        Handler<AsyncResult<Boolean>> handler)

      Like `updateSSLOptions(SSLOptions)` but supplying a handler that will be called when the update happened (or has failed).
      Parameters:
        `options` - the new SSL options
        `force` - force the update when options are equals
        `handler` - the update handler

Copyright © 2023 Eclipse. All rights reserved.