summaryrefslogtreecommitdiff
path: root/benchmark/idle_server.js
blob: 5d08897d199c48141d57acd483a30b7b078e034b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
net = require('net');
connections = 0;

var errors = 0;

server = net.Server(function (socket) {

  socket.on('end', function () {
    socket.end();
  });

  socket.on('error', function () {
    errors++; 
  });

});

server.listen(9000);

var oldConnections, oldErrors;

setInterval(function () {
  if (oldConnections != server.connections) {
    oldConnections = server.connections;
    console.log("SERVER %d connections: %d", process.pid, server.connections);
  }

  if (oldErrors != errors) {
    oldErrors = errors;
    console.log("SERVER %d errors: %d", process.pid, errors);
  }
}, 1000);