mirror of https://github.com/lukechilds/node.git
Browse Source
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>process-exit-stdio-flushing
José Moreira
9 years ago
committed by
Evan Lucas
5 changed files with 50 additions and 0 deletions
@ -0,0 +1,16 @@ |
|||
'use strict'; |
|||
const common = require('../common'); |
|||
const assert = require('assert'); |
|||
const http = require('http'); |
|||
|
|||
const server = http.createServer(); |
|||
|
|||
assert.strictEqual(server.listening, false); |
|||
|
|||
server.listen(common.PORT, common.mustCall(() => { |
|||
assert.strictEqual(server.listening, true); |
|||
|
|||
server.close(common.mustCall(() => { |
|||
assert.strictEqual(server.listening, false); |
|||
})); |
|||
})); |
@ -0,0 +1,16 @@ |
|||
'use strict'; |
|||
const common = require('../common'); |
|||
const assert = require('assert'); |
|||
const net = require('net'); |
|||
|
|||
const server = net.createServer(); |
|||
|
|||
assert.strictEqual(server.listening, false); |
|||
|
|||
server.listen(common.PORT, common.mustCall(() => { |
|||
assert.strictEqual(server.listening, true); |
|||
|
|||
server.close(common.mustCall(() => { |
|||
assert.strictEqual(server.listening, false); |
|||
})); |
|||
})); |
Loading…
Reference in new issue