zmqd

$(EM 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 $(EM 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 $(LINK2 http://api.zeromq.org/4-3:__start,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 $(EM zmqd) source repository.

Members

Aliases

FD
alias FD = PlatformFD

The native socket file descriptor type.

Message
deprecated alias Message = Frame
Undocumented in source.
PlatformFD
alias PlatformFD = SOCKET
Undocumented in source.
PlatformFD
alias PlatformFD = int
Undocumented in source.

Classes

InvalidEventException
class InvalidEventException

Exception thrown by $(FREF receiveEvent) on failure to interpret a received message as an event description.

ZmqException
class ZmqException

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

Enums

EventType
enum EventType

Socket event types.

PollFlags
enum PollFlags

$(FREF poll) event flags.

ProtocolError
enum ProtocolError

Protocol error codes.

Security
enum Security

Security mechanisms.

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.

curveKeyPair
Tuple!(char[], "publicKey", char[], "secretKey") curveKeyPair(char[] publicKeyBuf, char[] secretKeyBuf)

Generates a new Curve key pair.

defaultContext
Context defaultContext()

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

poll
deprecated uint poll(zmq_pollitem_t[] items, Duration timeout)
Undocumented in source. Be warned that the author may not have intended to support it.
poll
uint poll(PollItem[] items, Duration timeout)

Input/output multiplexing.

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

Starts the built-in $(ZMQ) proxy.

ptr
T* ptr(T[] arr)
Undocumented in source. Be warned that the author may not have intended to support it.
receiveEvent
Event receiveEvent(Socket socket)

Receives a message on the given _socket and interprets it as a _socket state change event.

steerableProxy
void steerableProxy(Socket frontend, Socket backend, Socket control)
void steerableProxy(Socket frontend, Socket backend, Socket control, Socket capture)

Starts the built-in $(ZMQ) proxy with _control flow.

z85Decode
ubyte[] z85Decode(char[] text, ubyte[] dest)
ubyte[] z85Decode(char[] text)

Decodes a binary key from Z85 printable _text.

z85Encode
char[] z85Encode(ubyte[] data, char[] dest)
char[] z85Encode(ubyte[] data)

Encodes a binary key as Z85 printable text.

zmqHas
bool zmqHas(char[] capability)

Checks for a $(ZMQ) capability.

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

Reports the $(ZMQ) library version.

Manifest constants

infiniteDuration
enum infiniteDuration;

A special $(COREF time,Duration) value used to signify an infinite timeout or time interval in certain contexts.

Structs

Context
struct Context

An object that encapsulates a $(ZMQ) context.

Event
struct Event

Information about a socket state change.

Frame
struct Frame

An object that encapsulates a $(ZMQ) message frame.

PollItem
struct PollItem

A structure that specifies a socket to be monitored by $(FREF poll) as well as the events to poll for, and, when $(FREF poll) returns, the events that occurred.

Socket
struct Socket

An object that encapsulates a $(ZMQ) socket.

Meta

Version

1.3.0 (compatible with ZeroMQ >= 4.3.0)

License

$(EM zmqd) is released under the terms of the Mozilla Public License v. 2.0.
Please refer to the ZeroMQ site for details about ZeroMQ licensing.