use of reactor.netty.tcp.TcpClient in project reactor-netty by reactor.
the class Application method main.
public static void main(String[] args) {
TcpClient tcpClient = TcpClient.create().host("example.com").port(80).handle((inbound, outbound) -> outbound.sendString(Mono.just("hello")));
// <1>
tcpClient.warmup().block();
// <2>
Connection connection = tcpClient.connectNow();
connection.onDispose().block();
}
use of reactor.netty.tcp.TcpClient in project reactor-netty by reactor.
the class DiscardClient method main.
public static void main(String[] args) {
TcpClient client = TcpClient.create().port(PORT).wiretap(WIRETAP);
if (SECURE) {
TcpSslContextSpec tcpSslContextSpec = TcpSslContextSpec.forClient().configure(builder -> builder.trustManager(InsecureTrustManagerFactory.INSTANCE));
client = client.secure(spec -> spec.sslContext(tcpSslContextSpec));
}
Connection connection = client.handle((in, out) -> {
// Discards the incoming data and releases the buffers
in.receive().subscribe();
return out.sendString(Flux.interval(Duration.ofMillis(100)).map(l -> l + ""));
}).connectNow();
connection.onDispose().block();
}
use of reactor.netty.tcp.TcpClient in project reactor-netty by reactor.
the class EchoClient method main.
public static void main(String[] args) {
TcpClient client = TcpClient.create().port(PORT).wiretap(WIRETAP);
if (SECURE) {
TcpSslContextSpec tcpSslContextSpec = TcpSslContextSpec.forClient().configure(builder -> builder.trustManager(InsecureTrustManagerFactory.INSTANCE));
client = client.secure(spec -> spec.sslContext(tcpSslContextSpec));
}
Connection connection = client.handle((in, out) -> out.send(Flux.concat(ByteBufFlux.fromString(Mono.just("echo")), in.receive().retain()))).connectNow();
connection.onDispose().block();
}
Aggregations