Pub-Sub envelope subscriber in C++
//
// Pubsub envelope subscriber
//
// Olivier Chamoux <moc.puorgselaht.rf|xuomahc.reivilo#moc.puorgselaht.rf|xuomahc.reivilo>
#include "zhelpers.hpp"
int main () {
// Prepare our context and subscriber
zmq::context_t context(1);
zmq::socket_t subscriber (context, ZMQ_SUB);
subscriber.connect("tcp://localhost:5563");
subscriber.setsockopt( ZMQ_SUBSCRIBE, "B", 1);
while (1) {
// Read envelope with address
std::string address = s_recv (subscriber);
// Read message contents
std::string contents = s_recv (subscriber);
std::cout << "[" << address << "] " << contents << std::endl;
}
return 0;
}