No description
Find a file
2025-11-25 18:27:24 +08:00
.github Bump actions/checkout from 5 to 6 2025-11-24 23:29:31 +00:00
docs trying to add links to docs 2021-07-26 12:23:14 +02:00
examples added tryReceiveAsync, receiveAllAsync 2024-12-05 22:25:30 +08:00
tests fix async tests using blocking version; add logging / echo mechanism to display errno behind a define; start work on overriding default send / receive flags with NOWAIT in async context 2024-05-10 11:55:35 +02:00
zmq added tryReceiveAsync, receiveAllAsync 2024-12-05 22:25:30 +08:00
.gitignore try another way of compiling examples 2021-03-18 19:05:32 +01:00
LICENSE Updated to work with ZeroMQ version 4 2014-08-30 20:25:24 +02:00
README.md Move eagain logging to run-time switch instead of compile-time switch 2024-05-12 18:11:36 +02:00
zmq.nim network testing is too volatile on CI; don't execute examples 2021-07-26 16:16:42 +02:00
zmq.nimble bump nimble version 2024-11-04 13:52:51 +01:00

Nim ZeroMQ wrapper

example workflow

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

Installation

$ nimble install zmq

Examples

Simple client/server

server

  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)

client

  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)

Advanced usage

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.

Log EAGAIN errno

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.

Setting default flag as DONTWAIT

The default flag passed to send / receive is NOFLAGS. This can be overriden by defining -d:defaultFlagDontWait