Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ZeroMQ rep socket example for node.js
var zmq = require('zmq');
var responder = zmq.socket('rep');
responder.on('message', function(payload)
{
var data = JSON.parse(payload);
var response = {};
var keys = Object.keys(data);
for (var i = 0; i < keys.length; i++)
{
response[data[keys[i]]] = keys[i];
}
responder.send(JSON.stringify(response));
});
var endpoint = 'tcp://127.0.0.1:3010';
responder.connect(endpoint);
console.log('listening on ' + endpoint);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.