Skip to content

Instantly share code, notes, and snippets.

@nicokaiser
Created November 23, 2011 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicokaiser/1390119 to your computer and use it in GitHub Desktop.
Save nicokaiser/1390119 to your computer and use it in GitHub Desktop.
websocket.io Issue #6
var util = require('util')
, WebSocket = require('websocket-server').WebSocket;
var CONCURRENCY = 200;
var SERVER = 'ws://localhost:3000/';
for (var i = 0; i < CONCURRENCY; i++) {
createConnection();
}
function createConnection() {
var ws = new WebSocket(SERVER);
ws.on('open', function() {
ws.send('hello world');
setTimeout(function() { ws.close(); }, 2000);
console.log('connection');
});
}
require('v8-profiler');
var ws = require('websocket.io')
, server = ws.listen(3000)
server.on('connection', function(client) {
client.on('message', function(msg) {
console.log(msg);
client.send(msg);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment