Lately I’ve been looking at the node.js sources and something has interested me.
Code:
const http = require("http");
const server = http.createServer(function (request, response) {
response.end("hello");
});
server.listen(3000, function () {
console.log("Runing on port 3000");
});
server.on("connection", function (socket) {
console.log("connection received, let's listen event 'ready'");
socket.on('ready', (...args) => console.log("ready", args));
})
The ready
event in this code will never be listened to. What am I doing wrong or what is missing?
Node.js doc says:
Event:
'ready'
Emitted when a socket is ready to be used.