Add idle connection test
[platform/upstream/nodejs.git] / benchmark / idle_server.js
1 net = require('net');
2 connections = 0;
3
4 var errors = 0;
5
6 server = net.Server(function (socket) {
7
8   socket.on('end', function () {
9     socket.end();
10   });
11
12   socket.on('error', function () {
13     errors++; 
14   });
15
16 });
17
18 server.listen(9000);
19
20 var oldConnections, oldErrors;
21
22 setInterval(function () {
23   if (oldConnections != server.connections) {
24     oldConnections = server.connections;
25     console.log("SERVER %d connections: %d", process.pid, server.connections);
26   }
27
28   if (oldErrors != errors) {
29     oldErrors = errors;
30     console.log("SERVER %d errors: %d", process.pid, errors);
31   }
32 }, 1000);
33