Represents a TCP server

no subtypes hierarchy

Initializer
NetServer(NetServer unknown)
Inherited Attributes
Attributes inherited from: Object
hash, string
Methods
actualPortshared default Integer 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

closeshared default void close()

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

closeshared default void close(Anything(Throwable?) completionHandler)

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

Parameters:
  • completionHandler

    the handler

connectHandlershared default NetServer connectHandler(Anything(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.

connectStreamshared default ReadStream<NetSocket> 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 .

exceptionHandlershared default NetServer exceptionHandler(Anything(Throwable) handler)

Set an exception handler called for socket errors happening before the connection is passed to the connectHandler, e.g during the TLS handshake.

Parameters:
  • handler

    the handler to set

isMetricsEnabledshared actual default Boolean isMetricsEnabled()

Whether the metrics are enabled for this measured object

listenshared default 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.

listenshared default NetServer listen(Anything(Throwable|NetServer) listenHandler)

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

listenshared default NetServer listen(Integer 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.

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.

listenshared default NetServer listen(SocketAddress localAddress)

Start listening on the specified local address, ignoring port and host 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.

Parameters:
  • localAddress

    the local address to listen on

listenshared default NetServer listen(Integer port, Anything(Throwable|NetServer) listenHandler)

Like listen 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

listenshared default NetServer listen(Integer port, String host)

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

listenshared default NetServer listen(SocketAddress localAddress, Anything(Throwable|NetServer) listenHandler)

Like listen 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

listenshared default NetServer listen(Integer port, String host, Anything(Throwable|NetServer) listenHandler)

Like listen 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

Inherited Methods
Methods inherited from: Object
equals
Methods inherited from: Measured