The code I'm looking at does not have "require('event')" anywhere, and yet I see this code
server.on('error', function (e) {
if (e.code == 'EADDRINUSE') {
console.log('Address in use, retrying...');
setTimeout(function () {
//server.close();
server.listen(port);//PORT, HOST);
}, 1000);
}
else{ .......
That uses "on".
And looking at this line
var net = require('net')
and this line
var server = net.createServer();
makes me think that doing require('net') already includes doing require('event').
Is this right?
The documentation makes it quite clear that net.Server
is an EventEmitter
, so EventEmitter
's properties and methods (including .on()
) are inherited.
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