[zeromq-dev] zproject python binding mixing with pyZMQ

Arnaud Loonstra arnaud at sphaero.org
Tue Jun 2 13:56:42 CEST 2015

On 2015-05-03 16:25, Arnaud Loonstra wrote:
> Hi all,
> I'm testing the new python bindings from zproject. As a test I was
> trying the Zyre bindings. In Zyre you can retrieve the socket using
> socket() in case you want to add it to a poller. However the socket
> method returns a  <class 'zyre.LP_zsock_t'> type which not hashable 
> and
> probably won't be understood by pyZMQ.
> Any ideas how to deal with this? I think it would make sense if the
> binding is inter operable with PyZMQ.
> Rg,
> Arnaud

To make this work the generator needs to address for the socket types 
beginning with:
--- a/bindings/python/zyre.py
+++ b/bindings/python/zyre.py
@@ -45,6 +45,14 @@ zyre_p = POINTER(zyre_t)

  class zsock_t(Structure):
      pass # Empty - only for type checking
+        ("tag", c_uint),
+        ("handle", c_void_p),
+        ("endpoint", c_char_p),
+        ("cache", c_char_p),
+        ("type", c_int),
+        ("cache_size", c_size_t)
+    ]
  zsock_p = POINTER(zsock_t)

The handle is an actual zmq socket. We only need to get to it's file 
descriptor to be able to use it in a select/poll.

Perphaps the handle can be converted to a PyZMQ socket type?



More information about the zeromq-dev mailing list