Skip to content

Instantly share code, notes, and snippets.

View squaremo's full-sized avatar
💭
how does computer

Michael Bridgen squaremo

💭
how does computer
  • London, formerly EU
View GitHub Profile
@squaremo
squaremo / README.md
Created May 3, 2012 20:49
Socket handoff in Node.JS

Same idea as https://gist.github.com/2500291, with node.js. Do

$ node forkpeer.js

It'll print out its pid. Then

$ curl http://localhost:8000/

To reload it, use

@squaremo
squaremo / pubsub
Created October 15, 2010 17:06
Using pub and sub message streams
var msg = require('./messages'), net = require('net');
s1 = new msg.MessageStream(net.createConnection(9000));
s1.send('pub');
s2 = new msg.MessageStream(net.createConnection(9000));
s2.send('sub');
s2.on('message', function(m) { console.log(m.toString()); });
s1.send('Hello world!');