Module zmqd

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:

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.

Version

1.3.0 (compatible with ZeroMQ >= 4.3.0)

Functions

NameDescription
asString(data) Utility function which interprets and validates a byte array as a UTF-8 string.
curveKeyPair(publicKeyBuf, secretKeyBuf) Generates a new Curve key pair.
defaultContext() A global context which is used by default by all sockets, unless they are explicitly constructed with a different context.
poll(items, timeout) Input/output multiplexing.
proxy(frontend, backend) Starts the built-in ZeroMQ proxy.
receiveEvent(socket) Receives a message on the given socket and interprets it as a socket state change event.
steerableProxy(frontend, backend, control) Starts the built-in ZeroMQ proxy with control flow.
z85Decode(text, dest) Decodes a binary key from Z85 printable text.
z85Encode(data, dest) Encodes a binary key as Z85 printable text.
zmqHas(capability) Checks for a ZeroMQ capability.
zmqVersion() Reports the ZeroMQ library version.

Classes

NameDescription
InvalidEventException Exception thrown by receiveEvent() on failure to interpret a received message as an event description.
ZmqException A class for exceptions thrown when any of the underlying ZeroMQ C functions report an error.

Structs

NameDescription
Context An object that encapsulates a ZeroMQ context.
Event Information about a socket state change.
Frame An object that encapsulates a ZeroMQ message frame.
PollItem A structure that specifies a socket to be monitored by poll() as well as the events to poll for, and, when poll() returns, the events that occurred.
Socket An object that encapsulates a ZeroMQ socket.

Enums

NameDescription
EventType Socket event types.
PollFlags poll() event flags.
ProtocolError Protocol error codes.
Security Security mechanisms.
SocketType The various socket types.

Manifest constants

NameTypeDescription
infiniteDuration A special core.time.Duration value used to signify an infinite timeout or time interval in certain contexts.

Aliases

NameTypeDescription
FD int The native socket file descriptor type.