Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFelix Geisendörfer <felix@debuggable.com>2011-07-25 11:01:44 +0400
committerFelix Geisendörfer <felix@debuggable.com>2011-07-26 13:07:17 +0400
commit09ee29318f32fdbe68d04188795bb6c760f4835c (patch)
treef5da2b1971af4b4fdadaf6a2f72ef9a7e74c7e01 /test
parentdf3a8fcb62e44fa1b1c592f04a872648d26ec08c (diff)
Emit 'close' after all connections have closed
Fixes #1383
Diffstat (limited to 'test')
-rw-r--r--test/simple/test-net-server-close.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/simple/test-net-server-close.js b/test/simple/test-net-server-close.js
new file mode 100644
index 00000000000..08f11194146
--- /dev/null
+++ b/test/simple/test-net-server-close.js
@@ -0,0 +1,39 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var common = require('../common');
+var assert = require('assert');
+var net = require('net');
+
+var server = net.createServer(function(socket) {
+ server.close();
+ process.nextTick(function() {
+ socket.destroy();
+ });
+});
+
+server.listen(common.PORT, function() {
+ net.createConnection(common.PORT);
+});
+
+server.on('close', function() {
+ assert.equal(server.connections, 0);
+});