I'm poking around the Node.js internals, and I came across the following method definition
//File: node/lib/net.js
Socket.prototype.listen = function() {
debug('socket.listen');
var self = this;
self.on('connection', arguments[0]);
listen(self, null, null, null);
};
Within the Socket object's listen method, there's a call to a (seemingly) global function, also named listen.
listen(self, null, null, null);
Where is this javascript method/function defined? I've scoured all the javascript files in the code-base and can't seem to find it.
(There's no specific task I'm trying to accomplish here, other than tracing node's execution path and trying to understand the patterns in use deep in the system.)
It's defined farther down in net.js. As of 0.11.5, it's at line 1089:
function listen(self, address, port, addressType, backlog, fd) {
if (!cluster) cluster = require('cluster');
if (cluster.isMaster) {
self._listen2(address, port, addressType, backlog, fd);
return;
}
// ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With