mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
4126441013
Constant declaration for `net` is omitted in `idle_server.js` Add a constant declaration for constant `net` PR-URL: https://github.com/nodejs/node/pull/3950 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
32 lines
599 B
JavaScript
32 lines
599 B
JavaScript
'use strict';
|
|
|
|
const net = require('net');
|
|
var connections = 0;
|
|
var errors = 0;
|
|
|
|
var server = net.Server(function (socket) {
|
|
|
|
socket.on('error', function () {
|
|
errors++;
|
|
});
|
|
|
|
});
|
|
|
|
//server.maxConnections = 128;
|
|
|
|
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);
|