Chicken Scheme bindings for the lightweight ZMQ-alternative, nanomsg. There exists Chicken ZMQ bindings, but this turned out to be a little troublesome with zmq_poll blocking other srfi-18 threads.
Nanomsg is smaller, written in C, has a simplified API (sockets are simple ints), no multipart messages, and has explicit support for poll on a socket's recv file-descriptor.
This egg requires nanomsg-0.4-beta. Not tested on nanomsg-0.5-beta.
These bindings are incomplete. All protocols and transport types
should be supported. However, socket options (nn_setsockopt
and
nn_getsockopt
) aren't supported with the exception of
nn-subscribe
. If you're missing something, please create github
issues!
Currently supported:
nn-socket
records types with finalizernn-bind
andnn-connect
nn-send
andnn-recv
- non-blocking
nn-recv
with(thread-wait-for-i/o!)
- nn-subscribe for
(nn-socket 'sub)
sockets
Favored TODO's:
- support socket options
- bundle nanomsg itself?
All of nanomsg's protocols are supported:
- Request/reply protocol (req rep)
- Publish/subscribe protocol (pub sub)
- Survey protocol (survey respondent)
- Pipeline protocol (push pull)
- One-to-one protocol (pair)
- Message bus protocol (bus)
;; test.scm
(use nanomsg)
(define s (nn-socket 'rep))
(nn-bind s "tcp://127.0.0.1:22022")
(let loop ((n 0))
(nn-send s (conc (nn-recv s) " " n))
(loop (add1 n)))
(nn-close s)
then test with the brilliant nanocat
util that comes with nanomsg:
$ csi -s test.scm &
$ nanocat --req -l22022 -D"bottles of beer:" -A --interval 1