All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.arangodb.shaded.vertx.core.net.NetClient Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
/*
 * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
 * which is available at https://www.apache.org/licenses/LICENSE-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
 */

package com.arangodb.shaded.vertx.core.net;

import com.arangodb.shaded.vertx.core.AsyncResult;
import com.arangodb.shaded.vertx.core.Future;
import com.arangodb.shaded.vertx.core.Handler;
import com.arangodb.shaded.vertx.codegen.annotations.Fluent;
import com.arangodb.shaded.vertx.codegen.annotations.VertxGen;
import com.arangodb.shaded.vertx.core.metrics.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 */ @VertxGen public interface NetClient extends Measured { /** * Open a connection to a server at the specific {@code port} and {@code host}. *

* {@code host} can be a valid host name or IP address. The connect is done asynchronously and on success, a * {@link NetSocket} instance is supplied via the {@code connectHandler} instance * * @param port the port * @param host the host * @return a reference to this, so the API can be used fluently */ @Fluent NetClient connect(int port, String host, Handler> connectHandler); /** * Like {@link #connect(int, String, Handler)} but returns a {@code Future} of the asynchronous result */ Future connect(int port, String host); /** * Open a connection to a server at the specific {@code port} and {@code host}. *

* {@code host} can be a valid host name or IP address. The connect is done asynchronously and on success, a * {@link NetSocket} instance is supplied via the {@code connectHandler} instance * * @param port the port * @param host the host * @param serverName the SNI server name * @return a reference to this, so the API can be used fluently */ @Fluent NetClient connect(int port, String host, String serverName, Handler> connectHandler); /** * Like {@link #connect(int, String, String, Handler)} but returns a {@code Future} of the asynchronous result */ Future connect(int port, String host, String serverName); /** * Open a connection to a server at the specific {@code remoteAddress}. *

* The connect is done asynchronously and on success, a {@link NetSocket} instance is supplied via the {@code connectHandler} instance * * @param remoteAddress the remote address * @return a reference to this, so the API can be used fluently */ @Fluent NetClient connect(SocketAddress remoteAddress, Handler> connectHandler); /** * Like {@link #connect(SocketAddress, Handler)} but returns a {@code Future} of the asynchronous result */ Future connect(SocketAddress remoteAddress); /** * Open a connection to a server at the specific {@code remoteAddress}. *

* The connect is done asynchronously and on success, a {@link NetSocket} instance is supplied via the {@code connectHandler} instance * * @param remoteAddress the remote address * @param serverName the SNI server name * @return a reference to this, so the API can be used fluently */ @Fluent NetClient connect(SocketAddress remoteAddress, String serverName, Handler> connectHandler); /** * Like {@link #connect(SocketAddress, String, Handler)} but returns a {@code Future} of the asynchronous result */ Future connect(SocketAddress remoteAddress, String serverName); /** * 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. */ void close(Handler> handler); /** * Like {@link #close(Handler)} but returns a {@code Future} of the asynchronous result */ Future close(); /** * Update the client SSL options. * * Update only happens if the SSL options is valid. * * @param options the new SSL options * @return a future signaling the update success */ Future updateSSLOptions(SSLOptions options); /** * Like {@link #updateSSLOptions(SSLOptions)} but supplying a handler that will be called when the update * happened (or has failed). * * @param options the new SSL options * @param handler the update handler */ default void updateSSLOptions(SSLOptions options, Handler> handler) { Future fut = updateSSLOptions(options); if (handler != null) { fut.onComplete(handler); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy