Skip to content

Instantly share code, notes, and snippets.

@ysimonson
Created July 24, 2012 23:10
Show Gist options
  • Save ysimonson/3173269 to your computer and use it in GitHub Desktop.
Save ysimonson/3173269 to your computer and use it in GitHub Desktop.
ZMQ bug (failing script)
var util = require("util"),
zmq = require("zmq"),
events = require("events");
function Socket(zmqSocket) {
var self = this;
self._zmqSocket = zmqSocket;
self._zmqSocket.on("error", function(error) {
self.emit("error", error);
});
self._zmqSocket.on("message", function(envelope, _, msg) {
self.emit("message", envelope, msg.toString());
});
}
util.inherits(Socket, events.EventEmitter);
Socket.prototype.send = function(envelope, msg) {
console
this._zmqSocket.send([envelope, new Buffer(0), msg]);
};
Socket.prototype.bind = function(endpoint) {
this._zmqSocket.bindSync(endpoint);
}
var socket = new Socket(zmq.socket("xrep"));
socket.bind("ipc:///tmp/zmq-issue");
socket.on("message", function(envelope, name) {
socket.send(envelope, "Hello, " + name);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment