webflux tcp client examples
snippet in kotlin

webflux tcp client examples

user926

import reactor.core.publisher.Mono;
import reactor.netty.Connection;
import reactor.netty.tcp.TcpClient;

public class Application {

    public static void main(String[] args) {
        Connection connection =
                TcpClient.create()
                         .host("example.com")
                         .port(80)
                         .handle((inbound, outbound) -> outbound.sendString(Mono.just("hello"))) (1)
                         .connectNow();

        connection.onDispose()
                  .block();
    }
}

webflux tcp client examples

user8168

import reactor.netty.Connection;
import reactor.netty.tcp.TcpClient;

public class Application {

    public static void main(String[] args) {
        Connection connection =
                TcpClient.create()
                         .host("example.com")
                         .port(80)
                         .handle((inbound, outbound) -> inbound.receive().then()) (1)
                         .connectNow();

        connection.onDispose()
                  .block();
    }
}

webflux tcp client examples

user2237

import reactor.netty.Connection;
import reactor.netty.tcp.TcpClient;

public class Application {

    public static void main(String[] args) {
        Connection connection =
                TcpClient.create()
                         .host("example.com") (1)
                         .port(80)            (2)
                         .connectNow();

        connection.onDispose()
                  .block();
    }
}