Skip to content

Instantly share code, notes, and snippets.

@csquared
Created June 10, 2013 17:28
Show Gist options
  • Select an option

  • Save csquared/5750637 to your computer and use it in GitHub Desktop.

Select an option

Save csquared/5750637 to your computer and use it in GitHub Desktop.
Push-Pull ZMQ Broker to act as a proxy/intermediary between multiple PUSH and PULL sockets.
#include <stdio.h>
#include "zhelpers.h"
int main(void)
{
void *context = zmq_ctx_new();
void *reciever = zmq_socket(context, ZMQ_PULL);
zmq_bind(reciever, "tcp://127.0.0.1:5557");
puts("reciever on tcp://127.0.0.1:5557");
void *sender = zmq_socket(context, ZMQ_PUSH);
zmq_bind(sender, "tcp://127.0.0.1:5558");
puts("sender on tcp://127.0.0.1:5558");
zmq_proxy(reciever, sender, NULL);
zmq_close(reciever);
zmq_close(sender);
zmq_ctx_destroy(context);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment