Represents a TCP or SSL server

If an instance is instantiated from an event loop then the handlers of the instance will always be called on that same event loop. If an instance is instantiated from some other arbitrary Java thread (i.e. when running embedded) then and event loop will be assigned to the instance and used when any of its handlers are called.

Instances of this class are thread-safe.

no subtypes hierarchy

Initializer
NetServer(NetServer delegate)
Attributes
hostshared String host

The host

portshared Integer port

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

Inherited Attributes
Attributes inherited from: NetworkBase
Attributes inherited from: Object
hash, string
Attributes inherited from: ServerBase
Methods
closeshared Promise<Anything> close()

Close the server. This will close any currently open connections. The returned promise will be resolved when the close is complete.

connectHandlershared NetServer connectHandler(void onConnect(NetSocket sock))

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 onConnect() handler.

listenshared Promise<NetServer> listen(Integer port, String? host = null)

Instruct the server to listen for incoming connections on the specified port and host. host can be a host name or an IP address.

Parameters:
  • host = null
Inherited Methods
Methods inherited from: Object
equals