Node.js
program is terminated when the event loop is empty. If I use http
module and create a server without any callback to be added to event loop, the program is terminated:
const http = require('http');
const server = http.createServer();
However, if I add listen
, the program keeps running:
const http = require('http');
const server = http.createServer();
server.listen(5155);
So how does listen
method keep the process running even if I don't add anything to event loop? Does it adds something to event loop? How does it interact with it?