Created
June 14, 2012 16:50
-
-
Save igorzi/2931446 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var net = require('net'); | |
var serverConnections = 0; | |
var clientConnections = 0; | |
// Server: accept connections and set keep-alive | |
net.createServer(function(socket) { | |
socket.setKeepAlive(true, 0); // <----- | |
serverConnections++; | |
console.log(serverConnections); | |
}).listen(8080); | |
// Client: make 1000 connections | |
(function connect() { | |
net.connect(8080, function(err){ | |
clientConnections++; | |
if (err) console.log(err); | |
if (clientConnections < 1000) { | |
connect(); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thx