1ZMQ_DEVICE(3)                     0MQ Manual                     ZMQ_DEVICE(3)
2
3
4

NAME

6       zmq_device - start built-in 0MQ device
7

SYNOPSIS

9       int zmq_device (int device, const void *frontend, const void *backend);
10

DESCRIPTION

12       The zmq_device() function starts a built-in 0MQ device. The device
13       argument is one of:
14
15       ZMQ_QUEUE
16           starts a queue device
17
18       ZMQ_FORWARDER
19           starts a forwarder device
20
21       ZMQ_STREAMER
22           starts a streamer device
23
24       The device connects a frontend socket to a backend socket.
25       Conceptually, data flows from frontend to backend. Depending on the
26       socket types, replies may flow in the opposite direction.
27
28       Before calling zmq_device() you must set any socket options, and
29       connect or bind both frontend and backend sockets. The two conventional
30       device models are:
31
32       proxy
33           bind frontend socket to an endpoint, and connect backend socket to
34           downstream components. A proxy device model does not require
35           changes to the downstream topology but that topology is static (any
36           changes require reconfiguring the device).
37
38       broker
39           bind frontend socket to one endpoint and bind backend socket to a
40           second endpoint. Downstream components must now connect into the
41           device. A broker device model allows a dynamic downstream topology
42           (components can come and go at any time).
43
44       zmq_device() runs in the current thread and returns only if/when the
45       current context is closed.
46

QUEUE DEVICE

48       ZMQ_QUEUE creates a shared queue that collects requests from a set of
49       clients, and distributes these fairly among a set of services. Requests
50       are fair-queued from frontend connections and load-balanced between
51       backend connections. Replies automatically return to the client that
52       made the original request.
53
54       This device is part of the request-reply pattern. The frontend speaks
55       to clients and the backend speaks to services. You should use ZMQ_QUEUE
56       with a ZMQ_XREP socket for the frontend and a ZMQ_XREQ socket for the
57       backend. Other combinations are not documented.
58
59       Refer to zmq_socket(3) for a description of these socket types.
60

FORWARDER DEVICE

62       ZMQ_FORWARDER collects messages from a set of publishers and forwards
63       these to a set of subscribers. You will generally use this to bridge
64       networks, e.g. read on TCP unicast and forward on multicast.
65
66       This device is part of the publish-subscribe pattern. The frontend
67       speaks to publishers and the backend speaks to subscribers. You should
68       use ZMQ_FORWARDER with a ZMQ_SUB socket for the frontend and a ZMQ_PUB
69       socket for the backend. Other combinations are not documented.
70
71       Refer to zmq_socket(3) for a description of these socket types.
72

STREAMER DEVICE

74       ZMQ_STREAMER collects tasks from a set of pushers and forwards these to
75       a set of pullers. You will generally use this to bridge networks.
76       Messages are fair-queued from pushers and load-balanced to pullers.
77
78       This device is part of the pipeline pattern. The frontend speaks to
79       pushers and the backend speaks to pullers. You should use ZMQ_STREAMER
80       with a ZMQ_PULL socket for the frontend and a ZMQ_PUSH socket for the
81       backend. Other combinations are not documented.
82
83       Refer to zmq_socket(3) for a description of these socket types.
84

RETURN VALUE

86       The zmq_device() function always returns -1 and errno set to ETERM (the
87       0MQ context associated with either of the specified sockets was
88       terminated).
89

EXAMPLE

91       Creating a queue broker.
92
93           //  Create frontend and backend sockets
94           void *frontend = zmq_socket (context, ZMQ_XREP);
95           assert (backend);
96           void *backend = zmq_socket (context, ZMQ_XREQ);
97           assert (frontend);
98           //  Bind both sockets to TCP ports
99           assert (zmq_bind (frontend, "tcp://*:5555") == 0);
100           assert (zmq_bind (backend, "tcp://*:5556") == 0);
101           //  Start a queue device
102           zmq_device (ZMQ_QUEUE, frontend, backend);
103
104

SEE ALSO

106       zmq_bind(3) zmq_connect(3) zmq_socket(3) zmq(7)
107

AUTHORS

109       This 0MQ manual page was written by Pieter Hintjens <ph@imatix.com[1]>
110

RESOURCES

112       Main web site: http://www.zeromq.org/
113
114       Report bugs to the 0MQ development mailing list:
115       <zeromq-dev@lists.zeromq.org[2]>
116

COPYING

118       Free use of this software is granted under the terms of the GNU Lesser
119       General Public License (LGPL). For details see the files COPYING and
120       COPYING.LESSER included with the 0MQ distribution.
121

NOTES

123        1. ph@imatix.com
124           mailto:ph@imatix.com
125
126        2. zeromq-dev@lists.zeromq.org
127           mailto:zeromq-dev@lists.zeromq.org
128
129
130
1310MQ 2.1.4                         03/30/2011                     ZMQ_DEVICE(3)
Impressum