| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8221917 commit 5ef9989
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -560,6 +560,11 @@ parameter is 511 (not 512). | |||
| 560 | 560 | This function is asynchronous. The last parameter `callback` will be added as | |
| 561 | 561 | a listener for the `'listening'` event. See also [`net.Server.listen(port)`][]. | |
| 562 | 562 | ||
| 563 | + ### server.listening | ||
| 564 | + | ||
| 565 | + A Boolean indicating whether or not the server is listening for | ||
| 566 | + connections. | ||
| 567 | + | ||
| 563 | 568 | ### server.maxHeadersCount | |
| 564 | 569 | ||
| 565 | 570 | Limits maximum incoming headers count, equal to 1000 by default. If set to 0 - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -202,6 +202,11 @@ server.on('error', (e) => { | |||
| 202 | 202 | ||
| 203 | 203 | (Note: All sockets in Node.js set `SO_REUSEADDR` already) | |
| 204 | 204 | ||
| 205 | + ### server.listening | ||
| 206 | + | ||
| 207 | + A Boolean indicating whether or not the server is listening for | ||
| 208 | + connections. | ||
| 209 | + | ||
| 205 | 210 | ### server.maxConnections | |
| 206 | 211 | ||
| 207 | 212 | Set this property to reject connections when the server's connection count gets | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1389,6 +1389,14 @@ Server.prototype.listen = function() { | |||
| 1389 | 1389 | return self; | |
| 1390 | 1390 | }; | |
| 1391 | 1391 | ||
| 1392 | + Object.defineProperty(Server.prototype, 'listening', { | ||
| 1393 | + get: function() { | ||
| 1394 | + return !!this._handle; | ||
| 1395 | + }, | ||
| 1396 | + configurable: true, | ||
| 1397 | + enumerable: true | ||
| 1398 | + }); | ||
| 1399 | + | ||
| 1392 | 1400 | Server.prototype.address = function() { | |
| 1393 | 1401 | if (this._handle && this._handle.getsockname) { | |
| 1394 | 1402 | var out = {}; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,16 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const http = require('http'); | ||
| 5 | + | ||
| 6 | + const server = http.createServer(); | ||
| 7 | + | ||
| 8 | + assert.strictEqual(server.listening, false); | ||
| 9 | + | ||
| 10 | + server.listen(common.PORT, common.mustCall(() => { | ||
| 11 | + assert.strictEqual(server.listening, true); | ||
| 12 | + | ||
| 13 | + server.close(common.mustCall(() => { | ||
| 14 | + assert.strictEqual(server.listening, false); | ||
| 15 | + })); | ||
| 16 | + })); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,16 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const net = require('net'); | ||
| 5 | + | ||
| 6 | + const server = net.createServer(); | ||
| 7 | + | ||
| 8 | + assert.strictEqual(server.listening, false); | ||
| 9 | + | ||
| 10 | + server.listen(common.PORT, common.mustCall(() => { | ||
| 11 | + assert.strictEqual(server.listening, true); | ||
| 12 | + | ||
| 13 | + server.close(common.mustCall(() => { | ||
| 14 | + assert.strictEqual(server.listening, false); | ||
| 15 | + })); | ||
| 16 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments