https://github.com/nim-lang/nim-zmq
Nim ZMQ wrapper
https://github.com/nim-lang/nim-zmq
hacktoberfest nim zmq
Last synced: 20 days ago
JSON representation
Nim ZMQ wrapper
- Host: GitHub
- URL: https://github.com/nim-lang/nim-zmq
- Owner: nim-lang
- License: mit
- Created: 2014-08-13T19:34:38.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-12-09T08:56:39.000Z (5 months ago)
- Last Synced: 2025-04-09T16:12:31.514Z (20 days ago)
- Topics: hacktoberfest, nim, zmq
- Language: Nim
- Homepage: https://nim-lang.github.io/nim-zmq/zmq.html
- Size: 198 KB
- Stars: 69
- Watchers: 14
- Forks: 17
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nim ZeroMQ wrapper

**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
```nim
import zmqvar 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
```nim
import zmqvar 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``