zmqd

A thin wrapper around the low-level C API of the ∅MQ messaging framework, for the D programming language.

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, namely:

  • Errors are signalled by means of exceptions rather than return codes. In particular, 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 appropriately marked with @safe, pure and nothrow, thus easing 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 $(ZMQ)D are very similar to those in ∅MQ , but they follow the D naming conventions. For example, zmq_msg_send() becomes zmqd.Message.send() and so on. Thus, the library should feel both familiar to ∅MQ users and natural to D users.

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 $(LINK2 http://api.zeromq.org/3-2:__start,∅MQ reference manual) here. Instead, the documentation for each function contains a "Corresponds to" section that links to the appropriate page in the ∅MQ reference. Any details given in the present documentation mostly concern the D-specific adaptations that have been made.

Also note that the examples only use the INPROC and IPC transports. 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. Anyway, they are only short snippets that demonstrate the syntax; for more comprehensive and realistic examples, please refer to the ∅MQ Guide.

Members

Aliases

SOCKET
alias SOCKET = size_t
Undocumented in source.

Classes

ZmqException
class ZmqException

A class for exceptions thrown when any of the underlying $(ZMQ) C functions report an error.

Enums

SocketType
enum SocketType

The various socket types.

Functions

asString
inout(char)[] asString(inout(ubyte)[] data)

Utility function which interprets and validates a byte array as a UTF-8 string.

defaultContext
Context defaultContext()

A global context which is used by default by all sockets, unless they are explicitly constructed with a different context.

proxy
void proxy(Socket frontend, Socket backend)
void proxy(Socket frontend, Socket backend, Socket capture)

Starts the built-in $(ZMQ) proxy.

zmqVersion
Tuple!(int, "major", int, "minor", int, "patch") zmqVersion()

Reports the $(ZMQ) library version.

Structs

Context
struct Context

An object that encapsulates a $(ZMQ) context.

Message
struct Message

An object that encapsulates a $(ZMQ) message.

Socket
struct Socket

An object that encapsulates a $(ZMQ) socket.

Meta

Version

0.1 ( ∅MQ 3.2 compatible)

License

$(ZMQ)D is released under a BSD licence (see LICENCE.txt for details).
Please refer to the ∅MQ site for details about ∅MQ licensing.