SYNOPSIS
#include <zmq.hpp>
c++ [flags] files -lzmq [libraries]
DESCRIPTION
This manual page describes how the ØMQ C++ language binding maps to the underlying ØMQ C library functions.
All ØMQ constants defined by zmq.h are also available to the C++ language binding.
The following classes are provided in the zmq namespace:
Context
The context_t class encapsulates functionality dealing with the initialisation and termination of a ØMQ context.
Constructor
Maps to the zmq_init() function, as described in zmq_init(3).
Destructor
Maps to the zmq_term() function, as described in zmq_term(3).
Methods
None.
Socket
The socket_t class encapsulates a ØMQ socket.
Constructor
Maps to the zmq_socket() function, as described in zmq_socket(3).
Destructor
Calls the zmq_close() function, as described in zmq_close(3).
Methods
Maps to the zmq_getsockopt() function, as described in zmq_getsockopt(3).
Maps to the zmq_setsockopt() function, as described in zmq_setsockopt(3).
Maps to the zmq_bind() function, as described in zmq_bind(3).
Maps to the zmq_connect() function, as described in zmq_connect(3).
Maps to the zmq_send() function, as described in zmq_send(3). Returns true if message is successfully sent, false if it is not.
Maps to the zmq_recv() function, as described in zmq_recv(3). Returns true if message is successfully received, false if it is not.
Message
The zmq::message_t class encapsulates the zmq_msg_t structure and functions to construct, destruct and manipulate ØMQ messages.
Constructor
These map to the zmq_msg_init(), zmq_msg_init_size() and zmq_msg_init_data() functions, described in zmq_msg_init(3), zmq_msg_init_size(3) and zmq_msg_init_data(3) respectively.
Destructor
Calls the zmq_msg_close() function, as described in zmq_msg_close(3).
Methods
Maps to the zmq_msg_data() function, as described in zmq_msg_data(3).
Maps to the zmq_msg_size() function, as described in zmq_msg_size(3).
Maps to the zmq_msg_copy() function, as described in zmq_msg_copy(3).
Maps to the zmq_msg_move() function, as described in zmq_msg_move(3).
Equivalent to calling the zmq_msg_close() function followed by the corresponding zmq_msg_init() function.
Input/output multiplexing
The poll() function is a namespaced equivalent of the zmq_poll() function, as described in zmq_poll(3).
Note
|
To obtain a ØMQ socket for use in a zmq_pollitem_t structure, you should cast an instance of the socket_t class to (void *). |
ERROR HANDLING
All errors reported by the underlying ØMQ C library functions are automatically converted to exceptions by the C++ language binding. The zmq::error_t class is derived from the std::exception class and uses the zmq_strerror() function to convert the error code to human-readable string.
EXAMPLE
zmq::context_t ctx (1); zmq::socket_t s (ctx, ZMQ_PUB); s.connect ("tcp://192.168.0.115:5555"); zmq::message_t msg (100); memset (msg.data (), 0, 100); s.send (msg);
SEE ALSO
AUTHORS
This ØMQ manual page was written by Martin Sustrik <sustrik@250bpm.com> and Martin Lucina <mato@kotelna.sk>.