Skip to content

Instantly share code, notes, and snippets.

@taotetek
Created January 9, 2014 14:07
Show Gist options
  • Save taotetek/8334625 to your computer and use it in GitHub Desktop.
Save taotetek/8334625 to your computer and use it in GitHub Desktop.
playing with node bindings for zeromq
var zmq = require('zmq');
// SUBSCRIBER
subsock = zmq.socket('sub');
subsock.connect ('ipc:///tmp/node.ipc');
subsock.subscribe('HELLOWORLD:');
console.log('Subscriber connected to ipc:///tmp/node.ipc');
subsock.on('message', function(msg) {
console.log('RECEIVED: %s', msg.toString());
});
// PUBLISHER
pubsock = zmq.socket ('pub');
pubsock.bindSync('ipc:///tmp/node.ipc');
console.log ('Publisher bound to ipc:///tmp/node.ipc');
setInterval (function() {
console.log ('sending a message');
pubsock.send ('HELLOWORLD: hello there');
}, 500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment