Constructor
new Server() → {Server}
Creates a new Server instance.
Fires:
- event:request - Emitted each time there is a request.
- event:close - Emitted when the server closes.
- event:clientError - Emitted when a client connection emits an 'error' event.
Returns:
- Type:
-
Server
An instance of the HTTP Server
class.
Methods
accept() → {Promise.<Connection>}
Waits for a client to connect and accepts the HTTP request.
Returns:
- Type:
-
Promise.<Connection>
An object representing an HTTP connection.
(async) listen(port, host) → {Promise.<SocketHost>}
Starts listening for incoming HTTP connections.
Parameters:
Name | Type | Description |
---|---|---|
port |
string
|
number
|
The port number or string on which the server should listen. |
host |
string
|
The hostname or IP address on which the server will listen. |
Returns:
- Type:
-
Promise.<SocketHost>
The host information where the server is listening.