2 var common = require('../common');
3 var assert = require('assert');
5 var net = require('net');
7 var s = new net.Stream();
9 // test that destroy called on a stream with a server only ever decrements the
10 // server connection count once
12 s.server = new net.Server();
13 s.server.connections = 10;
16 assert.equal(10, s.server.connections);
18 assert.equal(9, s.server.connections);
20 assert.equal(9, s.server.connections);
24 var buf = new Buffer(SIZE);
25 buf.fill(0x61); // 'a'
27 var server = net.createServer(function(socket) {
30 socket.on('error', function(err) {
32 }).on('close', function() {
36 for (var i = 0; i < N; ++i) {
37 socket.write(buf, function() { });
41 }).listen(common.PORT, function() {
42 var conn = net.connect(common.PORT);
43 conn.on('data', function(buf) {
45 setTimeout(function() {
51 process.on('exit', function() {
52 assert.equal(server.connections, 0);