Closed goranach closed 7 years ago
It's not the same. The current code covers Node.js v4 (no listening
property) and up.
isOpen()
{
// Not listening. TcpListener destroyed.
if (this.server === null)
{
return false;
}
// server.listening is available in Node.js version >=5
if (typeof this.server.listening === 'boolean')
{
return this.server.listening;
}
// Fallback to checking for the existence of a private variable in Node.js v4
if (typeof this.server._handle !== 'undefined')
{
return !!this.server._handle;
}
// Otherwise, assume the server is listening.
return true;
}
!!undefined == false
nodejs/lib/net.js
Object.defineProperty(Server.prototype, 'listening', { get: function() { return !!this._handle; }, configurable: true, enumerable: true });