Skip to content

Instantly share code, notes, and snippets.

@squaremo
Created October 15, 2010 17:06
Show Gist options
  • Select an option

  • Save squaremo/628551 to your computer and use it in GitHub Desktop.

Select an option

Save squaremo/628551 to your computer and use it in GitHub Desktop.
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!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment