Node.js server.close() Method
Example
Stop listening for connections:
var http = require('http');
var srvr = http.createServer(function (req, res) {
res.write('Hello
World!');
res.end();
});
srvr.listen(8080);
srvr.close();
Definition and Usage
The server.close() method stops the HTTP server from accepting new connections.
All existing connections are kept.
Syntax
server.close(callback);
Parameter Values
Parameter | Description |
---|---|
callback | Optional. Specifies a function to be executed after the server stops listening for connections |
Technical Details
Return Value: | None |
---|---|
Node.js Version: | 0.1.90 |