Created
January 9, 2014 14:07
-
-
Save taotetek/8334625 to your computer and use it in GitHub Desktop.
playing with node bindings for zeromq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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