Package: io.vertx.groovy.core.net

## [Groovy] Class NetServer

- io.vertx.groovy.core.net.NetServer

- All Implemented Interfaces and Traits:
    Measured

      @groovy.transform.CompileStatic
      class NetServer
      extends java.lang.Object

  Represents a TCP server

- - ### Constructor Summary

    Constructors
    Constructor and description
    `NetServer (java.lang.Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `int` | `actualPort()` The actual port the server is listening on.
    `void` | `close()` Close the server.
    `void` | `close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> completionHandler)` Like NetServer.close but supplying a handler that will be notified when close is complete.
    `NetServer` | `connectHandler(io.vertx.core.Handler<NetSocket> handler)` Supply a connect handler for this server.
    `NetSocketStream` | `connectStream()` Return the connect stream for this server.
    `java.lang.Object` | `getDelegate()`
    `boolean` | `isMetricsEnabled()` Whether the metrics are enabled for this measured object
    `NetServer` | `listen()` Start listening on the port and host as configured in the | `NetServer` | `listen(io.vertx.core.Handler<io.vertx.core.AsyncResult<NetServer>> listenHandler)` Like NetServer.listen but providing a handler that will be notified when the server is listening, or fails.
    `NetServer` | `listen(int port, java.lang.String host)` Start listening on the specified port and host, ignoring post and host configured in the | `NetServer` | `listen(int port, java.lang.String host, io.vertx.core.Handler<io.vertx.core.AsyncResult<NetServer>> listenHandler)` Like NetServer.listen but providing a handler that will be notified when the server is listening, or fails.
    `NetServer` | `listen(int port)` Start listening on the specified port and host "0.0.0.0", ignoring post and host configured in the | `NetServer` | `listen(int port, io.vertx.core.Handler<io.vertx.core.AsyncResult<NetServer>> listenHandler)` Like NetServer.listen but providing a handler that will be notified when the server is listening, or fails.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### NetServer(java.lang.Object delegate)

  - ### Method Detail

    - #### int actualPort()

      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

      Returns:
        the actual port the server is listening on.

    - #### void close()

      Close the server. This will close any currently open connections. The close may not complete until after this method has returned.

    - #### void close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> completionHandler)

      Like NetServer.close but supplying a handler that will be notified when close is complete.

      Parameters:
        `completionHandler` - the handler

    - #### NetServer connectHandler(io.vertx.core.Handler<NetSocket> handler)

      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.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        handler

    - #### NetSocketStream connectStream()

      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 .

      Returns:
        the connect stream

    - #### java.lang.Object getDelegate()

    - #### boolean isMetricsEnabled()

      Whether the metrics are enabled for this measured object

      Returns:
        true if the metrics are enabled

    - #### NetServer listen()

      Start listening on the port and host as configured in the NetServerOptions used when creating the server.

      The server may not be listening until some time after the call to listen has returned.

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

    - #### NetServer listen(io.vertx.core.Handler<io.vertx.core.AsyncResult<NetServer>> listenHandler)

      Like NetServer.listen but providing a handler that will be notified when the server is listening, or fails.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `listenHandler` - handler that will be notified when listening or failed

    - #### NetServer listen(int port, java.lang.String host)

      Start listening on the specified port and host, ignoring post and host configured in the 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.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        port
        host

    - #### NetServer listen(int port, java.lang.String host, io.vertx.core.Handler<io.vertx.core.AsyncResult<NetServer>> listenHandler)

      Like NetServer.listen but providing a handler that will be notified when the server is listening, or fails.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `port` - the port to listen on
        `host` - the host to listen on
        `listenHandler` - handler that will be notified when listening or failed

    - #### NetServer listen(int port)

      Start listening on the specified port and host "0.0.0.0", ignoring post and host configured in the 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.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        port

    - #### NetServer listen(int port, io.vertx.core.Handler<io.vertx.core.AsyncResult<NetServer>> listenHandler)

      Like NetServer.listen but providing a handler that will be notified when the server is listening, or fails.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `port` - the port to listen on
        `listenHandler` - handler that will be notified when listening or failed