public class TcpServer extends Object implements NettyConnector<NettyInbound,NettyOutbound>
| Modifier | Constructor and Description |
|---|---|
protected |
TcpServer(ServerOptions options) |
| Modifier and Type | Method and Description |
|---|---|
static TcpServer |
create()
Bind a new TCP server to "localhost" on a randomly assigned port.
|
static TcpServer |
create(java.util.function.Consumer<? super ServerOptions> options)
Bind a new TCP server to the bind address and port provided through the options.
|
static TcpServer |
create(int port)
Bind a new TCP server to "localhost" on the given port.
|
static TcpServer |
create(String bindAddress)
Bind a new TCP server to the given bind address on a randomly assigned port.
|
static TcpServer |
create(String bindAddress,
int port)
Bind a new TCP server to the given bind address and port.
|
protected ContextHandler<Channel> |
doHandler(java.util.function.BiFunction<? super NettyInbound,? super NettyOutbound,? extends Publisher<Void>> handler,
MonoSink<NettyContext> sink)
Create a
ContextHandler for ServerBootstrap.childHandler() |
protected LoggingHandler |
loggingHandler()
Return the current logging handler for the server
|
Mono<? extends NettyContext> |
newHandler(java.util.function.BiFunction<? super NettyInbound,? super NettyOutbound,? extends Publisher<Void>> handler) |
String |
toString() |
protected TcpServer(ServerOptions options)
options - server optionspublic static TcpServer create()
The assigned port can be found once a handler has been bound, using
NettyContext.address() and its getPort() method.
Handlers will run on the same thread they have been receiving IO events.
The type of emitted data or received data is ByteBuf
TcpServerpublic static TcpServer create(java.util.function.Consumer<? super ServerOptions> options)
NettyOptions.DEFAULT_PORT once to use a global default port.
Handlers will run on the same thread they have been receiving IO events.
The type of emitted data or received data is ByteBuf
options - ServerOptions configuration inputTcpServerpublic static TcpServer create(int port)
NettyOptions.DEFAULT_PORT once to use
a global default port.
Handlers will run on the same thread they have been receiving IO events.
The type of emitted data or received data is ByteBuf
port - the port to listen on loopbackTcpServerpublic static TcpServer create(String bindAddress)
The assigned port can be found once a handler has been bound, using
NettyContext.address() and its getPort() method.
Handlers will run on the same thread they have been receiving IO events.
The type of emitted data or received data is ByteBuf
bindAddress - bind address (e.g. "127.0.0.1") to create the server on the
default portTcpServerpublic static TcpServer create(String bindAddress, int port)
NettyOptions.DEFAULT_PORT once to use
a global default port.
Handlers will run on the same thread they have been receiving IO events.
The type of emitted data or received data is ByteBuf
bindAddress - bind address (e.g. "127.0.0.1") to create the server on the
passed portport - the port to listen on the passed bind addressTcpServerpublic final Mono<? extends NettyContext> newHandler(java.util.function.BiFunction<? super NettyInbound,? super NettyOutbound,? extends Publisher<Void>> handler)
newHandler in interface Connector<ByteBuf,ByteBuf,NettyInbound,NettyOutbound>protected LoggingHandler loggingHandler()
protected ContextHandler<Channel> doHandler(java.util.function.BiFunction<? super NettyInbound,? super NettyOutbound,? extends Publisher<Void>> handler, MonoSink<NettyContext> sink)
ContextHandler for ServerBootstrap.childHandler()handler - user provided in/out handlersink - user provided bind handlerContextHandler