[zeromq-dev] zmq_poll not working on Windows

Mikko Koppanen mikko at kuut.io
Tue Oct 4 17:30:29 CEST 2011


On Tue, Oct 4, 2011 at 4:12 PM,  <Marko.Dieckmann at gmx.de> wrote:
> Hello everyone,
>
> I tried to make zmq_poll work in my zmq 2.1.9 sample application for Windows
> 7 (x64), but without success.
>
> For this test I have a PUB/SUB setup between 2 threads.
>
>          // open INPROC socket to communicate with main thread
>         m_pInprocSocket = new zmq::socket_t(m_pZMQContext, ZMQ_SUB);
>         m_pInprocSocket->connect("inproc://thread_com");
>         m_pInprocSocket->setsockopt(ZMQ_SUBSCRIBE, "", 0);
>
> Then in thread that opened the SUB socket I want to poll, like:
>
>     zmq_pollitem_t pi[] = { m_pInprocSocket, 0, ZMQ_POLLIN, 0 };

Hi,

if you look at the poll examples carefully
(http://zguide.zeromq.org/cpp:mspoller) you need to pass the actual
object to the poll_item_t rather than a pointer to it. Try:

zmq_pollitem_t pi[] = { *m_pInprocSocket, 0, ZMQ_POLLIN, 0 };

thanks,
mikko



More information about the zeromq-dev mailing list