[zeromq-dev] czmq python binding Zpoller
Arnaud Loonstra
arnaud at sphaero.org
Thu Nov 5 12:20:03 CET 2015
On 2015-11-05 02:50, Johan Philips wrote:
> How can I get the actual socket out of it, because Zpoller seems to
> return a c_void_p which I cannot compare to my Zsock object I added
> to
> the poller.
>
> Minimal example using zyre nodes:
> Python 2.7.9 (default, Apr 2 2015, 15:33:21)
> [GCC 4.9.2] on linux2
> Type "help", "copyright", "credits" or "license" for more
> information.
> >>> from zyre import Zyre
> >>> from czmq import Zsock, Zpoller
> >>> n1 = Zyre("n1")
> >>> n2 = Zyre("n2")
> >>> n1.start()
> 0
> >>> n2.start()
> 0
> >>> poller = Zpoller(n1.socket(),n2.socket(), None)
> >>> sock = poller.wait(100)
> >>> print sock
> c_void_p(27301232)
> >>> print n1.socket(), n2.socket()
> <czmq.Zsock object at 0x7fbd0968cfd0> <czmq.Zsock object at
> 0x7fbd0968cfd0>
> >>>
>
> Do I need to add cast or POINTER or is there a more convenient way?
> Zsock(result, True) does not work since it will create a new object.
>
> Thanks!
>
> Johan
I haven't found the best approach yet. First of all you can use
ZyreEvents. See the test.py file for an example.
I've used the zyre binding with PyZMQ. I had to wrap the binding to
cast the pointer to a PyZMQ socket object. I don't have the code here so
can't provide how it is done. I might have posted it on this ML though.
I haven't used CZMQ for this.... yet. I'd need to look into this.
Perhaps some else knows a better way because indeed it is essential.
Rg,
Arnaud
More information about the zeromq-dev
mailing list