zmqd – a thin wrapper around the low-level C API of the
ZeroMQ messaging framework.
Most functions in this module have a one-to-one relationship with functions
in the underlying C API. Some adaptations have been made to make the API
safer, easier and more pleasant to use; most importantly:
Errors are signalled by means of exceptions rather than return
codes. The ZmqException class provides
a standard textual message for any error condition, but it also
provides access to the errno code set by the C function
that reported the error.
Functions are marked with @safe, pure and nothrow
as appropriate, thus facilitating their use in high-level D code.
Memory and resources (i.e. contexts, sockets and messages) are
automatically managed, thus preventing leaks.
Context, socket and message options are implemented as properties.
The names of functions and types in zmqd are very similar to those in
ZeroMQ, but they follow the D naming conventions. Thus, the library should
feel both familiar to ZeroMQ users and natural to D users. A notable
deviation from the C API is that message parts are consistently called
"frames". For example, zmq_msg_send() becomes zmqd.Frame.send()
and so on. (Multipart messages were a late addition to ZeroMQ, and the "msg"
function names were well established at that point. The library's
developers have admitted that this is somewhat confusing, and the newer
CZMQ API consistently uses "frame" in function names.)
Due to the close correspondence with the C API, this documentation has
intentionally been kept sparse. There is really no reason to repeat the
contents of the ZeroMQ reference manual here.
Instead, the documentation for each function contains a "Corresponds to"
section that links to the appropriate pages in the ZeroMQ reference. Any
details given in the present documentation mostly concern the D-specific
adaptations that have been made.
Also note that the examples generally only use the INPROC transport. The
reason for this is that the examples double as unittests, and we want to
avoid firewall troubles and other issues that could arise with the use of
network protocols such as TCP, PGM, etc., and the IPC protocol is not
supported on Windows. Anyway, they are only short
snippets that demonstrate the syntax; for more comprehensive and realistic
examples, please refer to the ZeroMQ Guide. Many of the examples in the Guide have been translated to
D, and can be found in the
examples
subdirectory of the zmqd source repository.