Created
June 2, 2020 16:14
-
-
Save hmahadik/33c17080227d02ed36edd852485bf68c to your computer and use it in GitHub Desktop.
ZMQ Router Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
./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