[zeromq-dev] ctypes python bindings
dholth at gmail.com
Sat Feb 19 06:22:27 CET 2011
Anyone else interested in ctypes style ZeroMQ 2.1.0 bindings for Python?
I wanted to play with ZeroMQ in pypy and I didn't feel like writing a
version of Cython that compiles to Python, so I made a little ctypes
binding: http://paste.lisp.org/display/119829 .
One way to finish this would be to take the pyzmq unit tests and make them
pass with this code but I probably don't need more than a tiny subset of
Without the higher-level pyzmq wrappers the code winds up looking very much
like the C version. Unlike the C version the return values are checked and
will raise an exception if ZeroMQ sets errno.
from _zmq import *
context = zmq_init(1)
responder = zmq_socket(context, REP)
request = zmq_msg_t()
zmq_recv(responder, byref(request), 0)
data = zmq_msg_data(request)
size = zmq_msg_size(request)
print "Received message: %s" % (ctypes.string_at(data, size))
# ... etc
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the zeromq-dev