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
those conveniences.
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)
zmq_bind(responder, "tcp://*:5555")
while True:
request = zmq_msg_t()
zmq_msg_init(byref(request))
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))
zmq_msg_close(request)
# ... etc
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev