1var net = require('net'); 2 3var PHRASE = "hello world"; 4var write = function(socket) { 5 socket.write(PHRASE, 'utf8'); 6} 7 8for (var i = 0; i < 1000; i++) { 9(function() { 10 var socket = net.connect(7000, 'localhost', function() { 11 socket.on('data', function(reply) { 12 if (reply.toString().indexOf(PHRASE) != 0) 13 console.error("Problem! '" + reply + "'" + " '" + PHRASE + "'"); 14 else 15 write(socket); 16 }); 17 write(socket); 18 }); 19})(); 20} 21