Multiple socket poller in C++

//
// Reading from multiple sockets in C++
// This version uses zmq_poll()
//
// Olivier Chamoux <moc.puorgselaht.rf|xuomahc.reivilo#moc.puorgselaht.rf|xuomahc.reivilo>

#include "zhelpers.hpp"

int main (int argc, char *argv[])
{
zmq::context_t context(1);

// Connect to task ventilator
zmq::socket_t receiver(context, ZMQ_PULL);
receiver.connect("tcp://localhost:5557");

// Connect to weather server
zmq::socket_t subscriber(context, ZMQ_SUB);
subscriber.connect("tcp://localhost:5556");
subscriber.setsockopt(ZMQ_SUBSCRIBE, "10001 ", 6);

// Initialize poll set
zmq::pollitem_t items [] = {
{ static_cast<void*>(receiver), 0, ZMQ_POLLIN, 0 },
{ static_cast<void*>(subscriber), 0, ZMQ_POLLIN, 0 }
};
// Process messages from both sockets
while (1) {
zmq::message_t message;
zmq::poll (&items [0], 2, -1);

if (items [0].revents & ZMQ_POLLIN) {
receiver.recv(&message);
// Process task
}
if (items [1].revents & ZMQ_POLLIN) {
subscriber.recv(&message);
// Process weather update
}
}
return 0;
}