vertx / io.vertx.core.net / NetServer

# NetServer

`interface NetServer : Measured`

Represents a TCP server

Author
Tim Fox

### Functions

actualPort | `abstract fun actualPort(): Int` The actual port the server is listening on. This is useful if you bound the server specifying 0 as port number signifying an ephemeral port
close | `abstract fun close(): Unit` Close the server. This will close any currently open connections. The close may not complete until after this method has returned. `abstract fun close(completionHandler: Handler<AsyncResult<Void>>): Unit` Like `#close` but supplying a handler that will be notified when close is complete.
connectHandler | `abstract fun connectHandler(handler: Handler<NetSocket>): NetServer` Supply a connect handler for this server. The server can only have at most one connect handler at any one time. As the server accepts TCP or SSL connections it creates an instance of NetSocket and passes it to the connect handler. `abstract fun connectHandler(): Handler<NetSocket>`
connectStream | `abstract fun connectStream(): ReadStream<NetSocket>` Return the connect stream for this server. The server can only have at most one handler at any one time. As the server accepts TCP or SSL connections it creates an instance of NetSocket and passes it to the connect stream `ReadStream#handler(io.vertx.core.Handler)`.
exceptionHandler | `abstract fun exceptionHandler(handler: Handler<Throwable>): NetServer` Set an exception handler called for socket errors happening before the connection is passed to the `#connectHandler`, e.g during the TLS handshake.
listen | `abstract fun listen(): NetServer` Start listening on the port and host as configured in the io.vertx.core.net.NetServerOptions used when creating the server. The server may not be listening until some time after the call to listen has returned. `abstract fun listen(listenHandler: Handler<AsyncResult<NetServer>>): NetServer` Like `#listen` but providing a handler that will be notified when the server is listening, or fails. `abstract fun listen(port: Int, host: String): NetServer` Start listening on the specified port and host, ignoring port and host configured in the io.vertx.core.net.NetServerOptions 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. `abstract fun listen(port: Int, host: String, listenHandler: Handler<AsyncResult<NetServer>>): NetServer` Like `#listen(int, String)` but providing a handler that will be notified when the server is listening, or fails. `abstract fun listen(port: Int): NetServer` Start listening on the specified port and host "0.0.0.0", ignoring port and host configured in the io.vertx.core.net.NetServerOptions 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. `abstract fun listen(port: Int, listenHandler: Handler<AsyncResult<NetServer>>): NetServer` Like `#listen(int)` but providing a handler that will be notified when the server is listening, or fails. `abstract fun listen(localAddress: SocketAddress): NetServer` Start listening on the specified local address, ignoring port and host configured in the io.vertx.core.net.NetServerOptions used when creating the server. The server may not be listening until some time after the call to listen has returned. `abstract fun listen(localAddress: SocketAddress, listenHandler: Handler<AsyncResult<NetServer>>): NetServer` Like `#listen(SocketAddress)` but providing a handler that will be notified when the server is listening, or fails.