table of contents
ZMQ_DEVICE(3) | 0MQ Manual | ZMQ_DEVICE(3) |
NAME¶
zmq_device - start built-in 0MQ deviceSYNOPSIS¶
int zmq_device (int device, const void *frontend , const void *backend);DESCRIPTION¶
The zmq_device() function starts a built-in 0MQ device. The device argument is one of: ZMQ_QUEUEstarts a queue device
ZMQ_FORWARDER
starts a forwarder device
ZMQ_STREAMER
starts a streamer device
bind frontend socket to an endpoint, and
connect backend socket to downstream components. A proxy device model does not
require changes to the downstream topology but that topology is static (any
changes require reconfiguring the device).
broker
bind frontend socket to one endpoint and bind
backend socket to a second endpoint. Downstream components must now connect
into the device. A broker device model allows a dynamic downstream topology
(components can come and go at any time).
QUEUE DEVICE¶
ZMQ_QUEUE creates a shared queue that collects requests from a set of clients, and distributes these fairly among a set of services. Requests are fair-queued from frontend connections and load-balanced between backend connections. Replies automatically return to the client that made the original request.FORWARDER DEVICE¶
ZMQ_FORWARDER collects messages from a set of publishers and forwards these to a set of subscribers. You will generally use this to bridge networks, e.g. read on TCP unicast and forward on multicast.STREAMER DEVICE¶
ZMQ_STREAMER collects tasks from a set of pushers and forwards these to a set of pullers. You will generally use this to bridge networks. Messages are fair-queued from pushers and load-balanced to pullers.RETURN VALUE¶
The zmq_device() function always returns -1 and errno set to ETERM (the 0MQ context associated with either of the specified sockets was terminated).EXAMPLE¶
Creating a queue broker.// Create frontend and backend sockets void *frontend = zmq_socket (context, ZMQ_XREP); assert (backend); void *backend = zmq_socket (context, ZMQ_XREQ); assert (frontend); // Bind both sockets to TCP ports assert (zmq_bind (frontend, "tcp://*:5555") == 0); assert (zmq_bind (backend, "tcp://*:5556") == 0); // Start a queue device zmq_device (ZMQ_QUEUE, frontend, backend);
SEE ALSO¶
zmq_bind(3) zmq_connect(3) zmq_socket(3) zmq(7)AUTHORS¶
This manual page was written by the 0MQ community.04/04/2012 | 0MQ 2.2.0 |