public class NetServerImpl extends Object implements Closeable, MetricsProvider, NetServer
| Modifier and Type | Field and Description |
|---|---|
protected ContextInternal |
creatingContext |
protected boolean |
logEnabled |
protected NetServerOptions |
options |
protected SSLHelper |
sslHelper |
protected VertxInternal |
vertx |
| Constructor and Description |
|---|
NetServerImpl(VertxInternal vertx,
NetServerOptions options) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
accept() |
int |
actualPort()
The actual port the server is listening on.
|
void |
close()
Close the server.
|
void |
close(Handler<AsyncResult<Void>> completionHandler)
Close this resource, the
completionHandler must be notified when the operation has completed. |
void |
closeAll(Handler<AsyncResult<Void>> handler)
Internal method that closes all servers when Vert.x is closing
|
Handler<NetSocket> |
connectHandler() |
NetServer |
connectHandler(Handler<NetSocket> handler)
Supply a connect handler for this server.
|
ReadStream<NetSocket> |
connectStream()
Return the connect stream for this server.
|
NetServer |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler called for socket errors happening before the connection
is passed to the
NetServer.connectHandler(io.vertx.core.Handler<io.vertx.core.net.NetSocket>), e.g during the TLS handshake. |
protected void |
finalize() |
Metrics |
getMetrics()
Returns the metrics implementation.
|
protected void |
initChannel(io.netty.channel.ChannelPipeline pipeline) |
boolean |
isClosed() |
protected boolean |
isListening() |
boolean |
isMetricsEnabled()
Whether the metrics are enabled for this measured object
|
NetServer |
listen()
Start listening on the port and host as configured in the
NetServerOptions used when
creating the server. |
NetServer |
listen(Handler<AsyncResult<NetServer>> listenHandler)
Like
NetServer.listen() but providing a handler that will be notified when the server is listening, or fails. |
void |
listen(Handler<NetSocket> handler,
SocketAddress socketAddress,
Handler<AsyncResult<Void>> listenHandler) |
NetServer |
listen(int port)
Start listening on the specified port and host "0.0.0.0", ignoring port and host configured in the
NetServerOptions used when creating the server. |
NetServer |
listen(int port,
Handler<AsyncResult<NetServer>> listenHandler)
Like
NetServer.listen(int) but providing a handler that will be notified when the server is listening, or fails. |
NetServer |
listen(int port,
String host)
Start listening on the specified port and host, ignoring port and host configured in the
NetServerOptions used when
creating the server. |
NetServer |
listen(int port,
String host,
Handler<AsyncResult<NetServer>> listenHandler)
Like
NetServer.listen(int, String) but providing a handler that will be notified when the server is listening, or fails. |
NetServer |
listen(SocketAddress localAddress)
Start listening on the specified local address, ignoring port and host configured in the
NetServerOptions used when
creating the server. |
NetServer |
listen(SocketAddress localAddress,
Handler<AsyncResult<NetServer>> listenHandler)
Like
NetServer.listen(SocketAddress) but providing a handler that will be notified when the server is listening, or fails. |
protected final VertxInternal vertx
protected final NetServerOptions options
protected final ContextInternal creatingContext
protected final SSLHelper sslHelper
protected final boolean logEnabled
public NetServerImpl(VertxInternal vertx, NetServerOptions options)
protected boolean accept()
protected boolean isListening()
public Handler<NetSocket> connectHandler()
connectHandler in interface NetServerpublic NetServer connectHandler(Handler<NetSocket> handler)
NetServerNetSocket and passes it to the
connect handler.connectHandler in interface NetServerpublic NetServer exceptionHandler(Handler<Throwable> handler)
NetServerNetServer.connectHandler(io.vertx.core.Handler<io.vertx.core.net.NetSocket>), e.g during the TLS handshake.exceptionHandler in interface NetServerhandler - the handler to setprotected void initChannel(io.netty.channel.ChannelPipeline pipeline)
public void listen(Handler<NetSocket> handler, SocketAddress socketAddress, Handler<AsyncResult<Void>> listenHandler)
public void close()
NetServerpublic NetServer listen(int port, String host)
NetServerNetServerOptions used when
creating the server.
Port 0 can be specified meaning "choose an random port".
Host 0.0.0.0 can be specified meaning "listen on all available interfaces".
The server may not be listening until some time after the call to listen has returned.
public NetServer listen(int port)
NetServerNetServerOptions used when creating the server.
Port 0 can be specified meaning "choose an random port".
The server may not be listening until some time after the call to listen has returned.
public NetServer listen(int port, Handler<AsyncResult<NetServer>> listenHandler)
NetServerNetServer.listen(int) but providing a handler that will be notified when the server is listening, or fails.public NetServer listen(SocketAddress localAddress)
NetServerNetServerOptions used when
creating the server.
The server may not be listening until some time after the call to listen has returned.
public NetServer listen(SocketAddress localAddress, Handler<AsyncResult<NetServer>> listenHandler)
NetServerNetServer.listen(SocketAddress) but providing a handler that will be notified when the server is listening, or fails.public NetServer listen()
NetServerNetServerOptions used when
creating the server.
The server may not be listening until some time after the call to listen has returned.
public NetServer listen(int port, String host, Handler<AsyncResult<NetServer>> listenHandler)
NetServerNetServer.listen(int, String) but providing a handler that will be notified when the server is listening, or fails.public NetServer listen(Handler<AsyncResult<NetServer>> listenHandler)
NetServerNetServer.listen() but providing a handler that will be notified when the server is listening, or fails.public ReadStream<NetSocket> connectStream()
NetServerNetSocket and passes it to the
connect stream ReadStream.handler(io.vertx.core.Handler).connectStream in interface NetServerpublic void closeAll(Handler<AsyncResult<Void>> handler)
public void close(Handler<AsyncResult<Void>> completionHandler)
CloseablecompletionHandler must be notified when the operation has completed.public boolean isClosed()
public int actualPort()
NetServeractualPort in interface NetServerpublic boolean isMetricsEnabled()
MeasuredisMetricsEnabled in interface Measuredtrue if metrics are enabledpublic Metrics getMetrics()
MetricsProvidergetMetrics in interface MetricsProviderCopyright © 2020. All rights reserved.