Skip to content

Instantly share code, notes, and snippets.

@hmahadik
Created June 2, 2020 16:14
Show Gist options
  • Save hmahadik/33c17080227d02ed36edd852485bf68c to your computer and use it in GitHub Desktop.
Save hmahadik/33c17080227d02ed36edd852485bf68c to your computer and use it in GitHub Desktop.
ZMQ Router Sample
/*
./zmqrouter
identity: SinkFrame
msg: Connect
identity: SinkFrame
msg: Connect
identity: SinkFrame
msg: Connect
*/
#include "streamproc/zhelpers.hpp"
int main() {
zmq::context_t context(1);
zmq::socket_t router(context, ZMQ_ROUTER);
router.bind("tcp://*:5555");
while(1) {
std::string identity = s_recv(router);
std::string msg = s_recv(router);
std::cout << "identity: " << identity << "\n";
std::cout << "msg: " << msg << "\n";
s_sendmore(router, identity);
s_sendmore(router, std::string("OK"));
if (msg == "Q")
break;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment