Note: This wrapper was written and tested with ZeroMQ version 4.2.0. Older versions may not work.
ZeroMQ API Reference can be found here : http://api.zeromq.org/4-2:_start
$ nimble install zmq
import zmq
var responder = zmq.listen("tcp://127.0.0.1:5555", REP)
for i in 0..10:
var request = receive(responder)
echo("Received: ", request)
send(responder, "World")
close(responder)
import zmq
var requester = zmq.connect("tcp://127.0.0.1:5555", REQ)
for i in 0..10:
send(requester, "Hello")
var reply = receive(requester)
echo("Received: ", reply)
close(requester)
For more examples demonstrating many functionalities and patterns that ZMQ offers, see the tests/
and examples/
folder.
The examples are commented to better understand how zmq works.
Sometimes EAGAIN error happens in ZMQ context; typically this is a non-ctritical error that can be ignored. Nonetheless, if you desire to log or display such error, it is possible to enable it using the enableLogEagain
and disable it with disableLogEagain
.
The default flag passed to send / receive is NOFLAGS. This can be overriden by defining -d:defaultFlagDontWait