Skip to content

Instantly share code, notes, and snippets.

@einaros
einaros / gist:1452218
Created December 9, 2011 16:24
ws server example
var WebSocketServer = require('ws').Server
, wss = new WebSocketServer({port: 8080});
wss.on('connection', function(ws) {
ws.on('message', function(message) {
console.log('received: %s', message);
});
ws.send('something');
});

Text payload

Roundtrips of 64 B text payloads: node-0.7.12 6% faster
Roundtrips of 16 kB text payloads: node-0.7.12 26% faster
Roundtrips of 128 kB text payloads: node-0.7.12 34% faster
Roundtrips of 1 MB text payloads: node-0.7.12 35% faster

Binary payload

Roundtrips of 64 B binary payloads: node-0.7.12 4% faster

@einaros
einaros / gist:1452010
Created December 9, 2011 15:35
wscat example
$ npm install -g ws
$ wscat -c ws://echo.websocket.org -p 8
connected (press CTRL+C to quit)
> hi there
< hi there
> are you a happy parrot?
< are you a happy parrot?