doc: add tls server.close() callback docs
Also, tests to confirm its existence. PR-URL: https://github.com/iojs/io.js/pull/217 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
63005ee10b
commit
b42c0853ae
@ -602,11 +602,11 @@ when the server has been bound.
|
|||||||
See `net.Server` for more information.
|
See `net.Server` for more information.
|
||||||
|
|
||||||
|
|
||||||
### server.close()
|
### server.close([callback])
|
||||||
|
|
||||||
Stops the server from accepting new connections. This function is
|
Stops the server from accepting new connections. This function is
|
||||||
asynchronous, the server is finally closed when the server emits a `'close'`
|
asynchronous, the server is finally closed when the server emits a `'close'`
|
||||||
event.
|
event. Optionally, you can pass a callback to listen for the `'close'` event.
|
||||||
|
|
||||||
### server.address()
|
### server.address()
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ var fs = require('fs');
|
|||||||
|
|
||||||
var clientConnected = 0;
|
var clientConnected = 0;
|
||||||
var serverConnected = 0;
|
var serverConnected = 0;
|
||||||
|
var serverCloseCallbacks = 0;
|
||||||
|
var serverCloseEvents = 0;
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
||||||
@ -34,7 +36,12 @@ var options = {
|
|||||||
|
|
||||||
var server = tls.Server(options, function(socket) {
|
var server = tls.Server(options, function(socket) {
|
||||||
if (++serverConnected === 2) {
|
if (++serverConnected === 2) {
|
||||||
server.close();
|
server.close(function() {
|
||||||
|
++serverCloseCallbacks;
|
||||||
|
});
|
||||||
|
server.on('close', function() {
|
||||||
|
++serverCloseEvents;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -60,4 +67,6 @@ server.listen(common.PORT, function() {
|
|||||||
process.on('exit', function() {
|
process.on('exit', function() {
|
||||||
assert.equal(clientConnected, 2);
|
assert.equal(clientConnected, 2);
|
||||||
assert.equal(serverConnected, 2);
|
assert.equal(serverConnected, 2);
|
||||||
|
assert.equal(serverCloseCallbacks, 1);
|
||||||
|
assert.equal(serverCloseEvents, 1);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user