vertx / io.vertx.core.net / NetServer / listen

# 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.

Return
a reference to this, so the API can be used fluently

`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.

### Parameters

`listenHandler` - handler that will be notified when listening or failed

Return
a reference to this, so the API can be used fluently

`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.

Return
a reference to this, so the API can be used fluently

`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.

### Parameters

`port` - the port to listen on

`host` - the host to listen on

`listenHandler` - handler that will be notified when listening or failed

Return
a reference to this, so the API can be used fluently

`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.

Return
a reference to this, so the API can be used fluently

`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.

### Parameters

`port` - the port to listen on

`listenHandler` - handler that will be notified when listening or failed

Return
a reference to this, so the API can be used fluently

`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.

### Parameters

`localAddress` - the local address to listen on

Return
a reference to this, so the API can be used fluently

`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.

### Parameters

`localAddress` - the local address to listen on

`listenHandler` - handler that will be notified when listening or failed

Return
a reference to this, so the API can be used fluently