diff options
author | José Moreira <jose.moreira@findhit.com> | 2016-01-18 13:36:48 +0000 |
---|---|---|
committer | Evan Lucas <evanlucas@me.com> | 2016-01-21 16:34:35 -0600 |
commit | 5ef9989bd6f980bccae8a186c93b974f51791a4d (patch) | |
tree | 4ee9a7c470ab2a09655eafce8f29c9f8b59fab6c /lib/net.js | |
parent | 8221917e8563b3dff40c4d87c7b50608ffa45912 (diff) | |
download | android-node-v8-5ef9989bd6f980bccae8a186c93b974f51791a4d.tar.gz android-node-v8-5ef9989bd6f980bccae8a186c93b974f51791a4d.tar.bz2 android-node-v8-5ef9989bd6f980bccae8a186c93b974f51791a4d.zip |
net: add net.listening boolean property over a getter
Added a listening property into net.Server.prototype indicating
if the server is listening or not for connections.
Other Server constructors that rely on net.Server should also
gain access to this property.
Also included tests for net and http subsystems.
PR-URL: https://github.com/nodejs/node/pull/4743
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'lib/net.js')
-rw-r--r-- | lib/net.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/net.js b/lib/net.js index da2c6eb278..aa3b994311 100644 --- a/lib/net.js +++ b/lib/net.js @@ -1389,6 +1389,14 @@ Server.prototype.listen = function() { return self; }; +Object.defineProperty(Server.prototype, 'listening', { + get: function() { + return !!this._handle; + }, + configurable: true, + enumerable: true +}); + Server.prototype.address = function() { if (this._handle && this._handle.getsockname) { var out = {}; |