[zeromq-dev] polling fd with czmq

Arnaud Loonstra arnaud at sphaero.org
Thu Oct 24 15:35:19 CEST 2019

Hi all,

I'm wondering what is the best approach to polling a non-zmq socket 
using czmq. It doesn't seem documented?

I can add a fd as follows:

s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
zpoller_add(poller, &s);

If I then poll zpoller_wait returns on activity however it's not a valid 
zsock_t instance:

zsock_t *which = (zsock_t *)zpoller_wait(poller, -1);

zsock_is(which) will return false. I've found 'which' is just what you 
added to the poller so if I cast to an int it will resolve to the 
correct filedescriptor number.

So either I cast it back to an int or I keep checking the pointer 
addresses. However casting an int to zsock_t doesn't feel safe.

So question is what is best/safest approach?



More information about the zeromq-dev mailing list