Skip to content

🔜 Prebuilt Node.js bindings to the zeromq library

License

Notifications You must be signed in to change notification settings

jdfreder/zmq-prebuilt

 
 

Repository files navigation

zmq-prebuilt   Build Status  Build status

ØMQ bindings for node.js.

Installation

$ npm install zmq-prebuilt

We rely on prebuild. Prepare to be amazed at the wonders of binaries.

Supported operating systems

  • OS X/Darwin 64-bit
  • Linux 64-bit
  • Windows (we'll get this one up soon!)

Usage

Everywhere you used require(zmq) in your code base before, replace it with zmq-prebuilt.

Examples

Push/Pull

// producer.js
var zmq = require('zmq-prebuilt')
  , sock = zmq.socket('push');

sock.bindSync('tcp://127.0.0.1:3000');
console.log('Producer bound to port 3000');

setInterval(function(){
  console.log('sending work');
  sock.send('some work');
}, 500);
// worker.js
var zmq = require('zmq-prebuilt')
  , sock = zmq.socket('pull');

sock.connect('tcp://127.0.0.1:3000');
console.log('Worker connected to port 3000');

sock.on('message', function(msg){
  console.log('work: %s', msg.toString());
});

Pub/Sub

// pubber.js
var zmq = require('zmq-prebuilt')
  , sock = zmq.socket('pub');

sock.bindSync('tcp://127.0.0.1:3000');
console.log('Publisher bound to port 3000');

setInterval(function(){
  console.log('sending a multipart message envelope');
  sock.send(['kitty cats', 'meow!']);
}, 500);
// subber.js
var zmq = require('zmq-prebuilt')
  , sock = zmq.socket('sub');

sock.connect('tcp://127.0.0.1:3000');
sock.subscribe('kitty cats');
console.log('Subscriber connected to port 3000');

sock.on('message', function(topic, message) {
  console.log('received a message related to:', topic, 'containing message:', message);
});

About

🔜 Prebuilt Node.js bindings to the zeromq library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 51.3%
  • C++ 32.8%
  • C 13.9%
  • Python 1.1%
  • Other 0.9%