Top Description Methods
io.vertx.core.net

public Interface NetClient

extends Measured
Known Direct Implementers
io.vertx.core.net.impl.NetClientImpl
Annotations
@VertxGen
Imports
io.vertx.core.AsyncResult, .Future, .Handler, io.vertx.codegen.annotations.Fluent, .VertxGen, io.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

Method Summary

Modifier and TypeMethod and Description
public void
close(Handler<AsyncResult<Void>> handler)

Close the client.

public Future<Void>
close()

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

public NetClient

Returns:

a reference to this, so the API can be used fluently
connect
(int
the port
port
,
String
the host
host
,
Handler<AsyncResult<NetSocket>> connectHandler)

Open a connection to a server at the specific port and host.

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

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

public NetClient

Returns:

a reference to this, so the API can be used fluently
connect
(int
the port
port
,
String
the host
host
,
String
the SNI server name
serverName
,
Handler<AsyncResult<NetSocket>> connectHandler)

Open a connection to a server at the specific port and host.

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

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

public NetClient

Returns:

a reference to this, so the API can be used fluently
connect
(SocketAddress
the remote address
remoteAddress
,
Handler<AsyncResult<NetSocket>> connectHandler)

Open a connection to a server at the specific remoteAddress.

public Future<NetSocket>
connect(SocketAddress remoteAddress)

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

public NetClient

Returns:

a reference to this, so the API can be used fluently
connect
(SocketAddress
the remote address
remoteAddress
,
String
the SNI server name
serverName
,
Handler<AsyncResult<NetSocket>> connectHandler)

Open a connection to a server at the specific remoteAddress.

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

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

public default Future<Boolean>

Returns:

a future signaling the update success
updateSSLOptions
(SSLOptions
the new SSL options
options
)

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

public default void
updateSSLOptions(SSLOptions
the new SSL options
options
,
Handler<AsyncResult<Boolean>>
the update handler
handler
)

Like updateSSLOptions(SSLOptions) but supplying a handler that will be called when the update happened (or has failed).

public Future<Boolean>

Returns:

a future signaling the update success
updateSSLOptions
(SSLOptions
the new SSL options
options
,
boolean
force the update when options are equals
force
)

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

public default void
updateSSLOptions(SSLOptions
the new SSL options
options
,
boolean
force the update when options are equals
force
,
Handler<AsyncResult<Boolean>>
the update handler
handler
)

Like updateSSLOptions(SSLOptions) but supplying a handler that will be called when the update happened (or has failed).

Inherited from io.vertx.core.metrics.Measured:
isMetricsEnabled

Method Detail

closeback to summary
public 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.

closeback to summary
public Future<Void> close()

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

connectback to summary
public 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:int

the port

host:String

the host

Returns:NetClient

a reference to this, so the API can be used fluently

Annotations
@Fluent
connectback to summary
public Future<NetSocket> connect(int port, String host)

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

connectback to summary
public 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:int

the port

host:String

the host

serverName:String

the SNI server name

Returns:NetClient

a reference to this, so the API can be used fluently

Annotations
@Fluent
connectback to summary
public Future<NetSocket> connect(int port, String host, String serverName)

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

connectback to summary
public 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:SocketAddress

the remote address

Returns:NetClient

a reference to this, so the API can be used fluently

Annotations
@Fluent
connectback to summary
public Future<NetSocket> connect(SocketAddress remoteAddress)

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

connectback to summary
public 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:SocketAddress

the remote address

serverName:String

the SNI server name

Returns:NetClient

a reference to this, so the API can be used fluently

Annotations
@Fluent
connectback to summary
public Future<NetSocket> connect(SocketAddress remoteAddress, String serverName)

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

updateSSLOptionsback to summary
public 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:SSLOptions

the new SSL options

Returns:Future<Boolean>

a future signaling the update success

updateSSLOptionsback to summary
public 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:SSLOptions

the new SSL options

handler:Handler<AsyncResult<Boolean>>

the update handler

updateSSLOptionsback to summary
public 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:SSLOptions

the new SSL options

force:boolean

force the update when options are equals

Returns:Future<Boolean>

a future signaling the update success

updateSSLOptionsback to summary
public 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:SSLOptions

the new SSL options

force:boolean

force the update when options are equals

handler:Handler<AsyncResult<Boolean>>

the update handler