use of reactor.netty.tcp.TcpServer in project spring-boot by spring-projects.
the class NettyRSocketServerFactory method createTcpTransport.
private ServerTransport<CloseableChannel> createTcpTransport() {
TcpServer tcpServer = TcpServer.create();
if (this.resourceFactory != null) {
tcpServer = tcpServer.runOn(this.resourceFactory.getLoopResources());
}
if (this.ssl != null && this.ssl.isEnabled()) {
TcpSslServerCustomizer sslServerCustomizer = new TcpSslServerCustomizer(this.ssl, this.sslStoreProvider);
tcpServer = sslServerCustomizer.apply(tcpServer);
}
return TcpServerTransport.create(tcpServer.bindAddress(this::getListenAddress));
}
use of reactor.netty.tcp.TcpServer in project reactor-netty by reactor.
the class Application method main.
public static void main(String[] args) {
TcpServer tcpServer = TcpServer.create().handle((inbound, outbound) -> inbound.receive().then());
// <1>
tcpServer.warmup().block();
DisposableServer server = tcpServer.bindNow();
server.onDispose().block();
}
use of reactor.netty.tcp.TcpServer in project reactor-netty by reactor.
the class MultiAddressApplication method main.
public static void main(String[] args) {
TcpServer tcpServer = TcpServer.create();
DisposableServer server1 = tcpServer.host(// <1>
"localhost").port(// <2>
8080).bindNow();
DisposableServer server2 = tcpServer.host(// <3>
"0.0.0.0").port(// <4>
8081).bindNow();
Mono.when(server1.onDispose(), server2.onDispose()).block();
}
use of reactor.netty.tcp.TcpServer in project reactor-netty by reactor.
the class DefaultLoopResourcesTest method testServerTransportWarmup.
private void testServerTransportWarmup(boolean preferNative) {
final DefaultLoopResources loop = (DefaultLoopResources) LoopResources.create("testServerTransportWarmup", 1, true);
try {
TcpServer tcpServer = TcpServer.create().runOn(loop, preferNative);
Mono<Void> warmupMono = tcpServer.warmup();
assertThat(loop.cacheNativeServerLoops.get()).isNull();
assertThat(loop.cacheNativeSelectLoops.get()).isNull();
assertThat(loop.serverLoops.get()).isNull();
assertThat(loop.serverSelectLoops.get()).isNull();
warmupMono.block(Duration.ofSeconds(5));
if (preferNative && LoopResources.hasNativeSupport()) {
assertThat(loop.cacheNativeServerLoops.get()).isNotNull();
assertThat(loop.cacheNativeSelectLoops.get()).isNotNull();
assertThat(loop.serverLoops.get()).isNull();
assertThat(loop.serverSelectLoops.get()).isNull();
} else {
assertThat(loop.cacheNativeServerLoops.get()).isNull();
assertThat(loop.cacheNativeSelectLoops.get()).isNull();
assertThat(loop.serverLoops.get()).isNotNull();
assertThat(loop.serverSelectLoops.get()).isNotNull();
}
} finally {
loop.disposeLater().block(Duration.ofSeconds(5));
}
}
use of reactor.netty.tcp.TcpServer in project reactor-netty by reactor.
the class DiscardServer method main.
public static void main(String[] args) throws Exception {
TcpServer server = TcpServer.create().port(PORT).wiretap(WIRETAP).handle((in, out) -> {
// Discards the incoming data and releases the buffers
in.receive().subscribe();
return out.neverComplete();
});
if (SECURE) {
SelfSignedCertificate ssc = new SelfSignedCertificate();
server = server.secure(spec -> spec.sslContext(TcpSslContextSpec.forServer(ssc.certificate(), ssc.privateKey())));
}
server.bindNow().onDispose().block();
}
Aggregations