title: ZeroMQ: How to cast a pollitem_t item, used in Poller, back to a ZeroMQ socket?
body: <p>As title says, when using <strong><code>zmq::poll</code></strong> with <code>cppzmq</code>, I'd love to avoid  hardcoding the translation of ZeroMQ sockets into <code>pollitem_t item</code>(s) for polling.</p>
  <p>But it seems that I'm not allowed to convert a <code>void*</code> <code>pollitem_t::socket</code> back to a zmq socket.</p>
  <p>I noticed that the official sample code just hardcoded the socket after polling.</p>
  <pre class="lang-cpp prettyprint-override"><code>//
  //  Reading from multiple sockets in C++
  //  This version uses zmq_poll()
  //
  // Olivier Chamoux &lt;olivier.chamoux@fr.thalesgroup.com&gt;
  
  #include &quot;zhelpers.hpp&quot;
  
  int main (int argc, char *argv[])
  {
      zmq::context_t context(1);
  
      //  Connect to task ventilator
      zmq::socket_t receiver(context, ZMQ_PULL);
      receiver.connect(&quot;tcp://localhost:5557&quot;);
  
      //  Connect to weather server
      zmq::socket_t subscriber(context, ZMQ_SUB);
      subscriber.connect(&quot;tcp://localhost:5556&quot;);
      subscriber.setsockopt(ZMQ_SUBSCRIBE, &quot;10001 &quot;, 6);
  
      //  Initialize poll set
      zmq::pollitem_t items [] = {
          { static_cast&lt;void*&gt;(receiver), 0, ZMQ_POLLIN, 0 },
          { static_cast&lt;void*&gt;(subscriber), 0, ZMQ_POLLIN, 0 }
      };
      //  Process messages from both sockets
      while (1) {
          zmq::message_t message;
          zmq::poll (&amp;items [0], 2, -1);
          
          if (items [0].revents &amp; ZMQ_POLLIN) {
              receiver.recv(&amp;message);
              //  Process task
          }
          if (items [1].revents &amp; ZMQ_POLLIN) {
              subscriber.recv(&amp;message);
              //  Process weather update
          }
      }
      return 0;
  }
  </code></pre>
  <h2>Hence the question:</h2>
  <p>Is it impossible to avoid hardcoding sockets in this case?</p>