On 25-10-2019 10:25, Luca Boccassi wrote:
On Thu, 2019-10-24 at 15:35 +0200, Arnaud Loonstra wrote:
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, );
...
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?
Rg,
Arnaud
Strange, that should work - the zpoller_add documentation is missing
it, but the zpoller_new doc clearly says a file handle is supported,
and the implementation confirms it - you should be able to pass it a
file descriptor as you are doing.
Did you by any chance compile libzmq with draft apis and the new
zmq_poller APIs? That changes the implementation quite a bit, and there
might be regressions yet unspotted.
It does work, Luca. It just wasn't clear. I submitted a PR:
https://github.com/zeromq/czmq/pull/2028
Rg,
Arnaud
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev