1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
'\" t
.\" Title: zmq
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: 05/06/2011
.\" Manual: 0MQ Manual
.\" Source: 0MQ 2.1.6
.\" Language: English
.\"
.TH "ZMQ" "7" "05/06/2011" "0MQ 2\&.1\&.6" "0MQ Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
zmq \- 0MQ lightweight messaging kernel
.SH "SYNOPSIS"
.sp
\fB#include <zmq\&.h>\fR
.sp
\fBcc\fR [\fIflags\fR] \fIfiles\fR \fB\-lzmq\fR [\fIlibraries\fR]
.SH "DESCRIPTION"
.sp
The 0MQ lightweight messaging kernel is a library which extends the standard socket interfaces with features traditionally provided by specialised \fImessaging middleware\fR products\&. 0MQ sockets provide an abstraction of asynchronous \fImessage queues\fR, multiple \fImessaging patterns\fR, message filtering (\fIsubscriptions\fR), seamless access to multiple \fItransport protocols\fR and more\&.
.sp
This documentation presents an overview of 0MQ concepts, describes how 0MQ abstracts standard sockets and provides a reference manual for the functions provided by the 0MQ library\&.
.SS "Context"
.sp
Before using any 0MQ library functions the caller must initialise a 0MQ \fIcontext\fR using \fIzmq_init()\fR\&. The following functions are provided to handle initialisation and termination of a \fIcontext\fR:
.PP
Initialise 0MQ context
.RS 4
\fBzmq_init\fR(3)
.RE
.PP
Terminate 0MQ context
.RS 4
\fBzmq_term\fR(3)
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBThread safety\fR
.RS 4
.sp
A 0MQ \fIcontext\fR is thread safe and may be shared among as many application threads as necessary, without any additional locking required on the part of the caller\&.
.sp
Individual 0MQ \fIsockets\fR are \fInot\fR thread safe except in the case where full memory barriers are issued when migrating a socket from one thread to another\&. In practice this means applications can create a socket in one thread with \fIzmq_socket()\fR and then pass it to a \fInewly created\fR thread as part of thread initialization, for example via a structure passed as an argument to \fIpthread_create()\fR\&.
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBMultiple contexts\fR
.RS 4
.sp
Multiple \fIcontexts\fR may coexist within a single application\&. Thus, an application can use 0MQ directly and at the same time make use of any number of additional libraries or components which themselves make use of 0MQ as long as the above guidelines regarding thread safety are adhered to\&.
.RE
.SS "Messages"
.sp
A 0MQ message is a discrete unit of data passed between applications or components of the same application\&. 0MQ messages have no internal structure and from the point of view of 0MQ itself they are considered to be opaque binary data\&.
.sp
The following functions are provided to work with messages:
.PP
Initialise a message
.RS 4
\fBzmq_msg_init\fR(3)
\fBzmq_msg_init_size\fR(3)
\fBzmq_msg_init_data\fR(3)
.RE
.PP
Release a message
.RS 4
\fBzmq_msg_close\fR(3)
.RE
.PP
Access message content
.RS 4
\fBzmq_msg_data\fR(3)
\fBzmq_msg_size\fR(3)
.RE
.PP
Message manipulation
.RS 4
\fBzmq_msg_copy\fR(3)
\fBzmq_msg_move\fR(3)
.RE
.SS "Sockets"
.sp
0MQ sockets present an abstraction of a asynchronous \fImessage queue\fR, with the exact queueing semantics depending on the socket type in use\&. See \fBzmq_socket\fR(3) for the socket types provided\&.
.sp
The following functions are provided to work with sockets:
.PP
Creating a socket
.RS 4
\fBzmq_socket\fR(3)
.RE
.PP
Closing a socket
.RS 4
\fBzmq_close\fR(3)
.RE
.PP
Manipulating socket options
.RS 4
\fBzmq_getsockopt\fR(3)
\fBzmq_setsockopt\fR(3)
.RE
.PP
Establishing a message flow
.RS 4
\fBzmq_bind\fR(3)
\fBzmq_connect\fR(3)
.RE
.PP
Sending and receiving messages
.RS 4
\fBzmq_send\fR(3)
\fBzmq_recv\fR(3)
.RE
.PP
\fBInput/output multiplexing\fR. 0MQ provides a mechanism for applications to multiplex input/output events over a set containing both 0MQ sockets and standard sockets\&. This mechanism mirrors the standard
\fIpoll()\fR
system call, and is described in detail in
\fBzmq_poll\fR(3)\&.
.SS "Transports"
.sp
A 0MQ socket can use multiple different underlying transport mechanisms\&. Each transport mechanism is suited to a particular purpose and has its own advantages and drawbacks\&.
.sp
The following transport mechanisms are provided:
.PP
Unicast transport using TCP
.RS 4
\fBzmq_tcp\fR(7)
.RE
.PP
Reliable multicast transport using PGM
.RS 4
\fBzmq_pgm\fR(7)
.RE
.PP
Local inter\-process communication transport
.RS 4
\fBzmq_ipc\fR(7)
.RE
.PP
Local in\-process (inter\-thread) communication transport
.RS 4
\fBzmq_inproc\fR(7)
.RE
.SS "Devices"
.sp
0MQ provides \fIdevices\fR, which are building blocks that act as intermediate nodes in complex messaging topologies\&. Devices can act as brokers that other nodes connect to, proxies that connect through to other nodes, or any mix of these two models\&.
.sp
You can start a device in an application thread, see \fBzmq_device\fR(3)\&.
.SH "ERROR HANDLING"
.sp
The 0MQ library functions handle errors using the standard conventions found on POSIX systems\&. Generally, this means that upon failure a 0MQ library function shall return either a NULL value (if returning a pointer) or a negative value (if returning an integer), and the actual error code shall be stored in the \fIerrno\fR variable\&.
.sp
On non\-POSIX systems some users may experience issues with retrieving the correct value of the \fIerrno\fR variable\&. The \fIzmq_errno()\fR function is provided to assist in these cases; for details refer to \fBzmq_errno\fR(3)\&.
.sp
The \fIzmq_strerror()\fR function is provided to translate 0MQ\-specific error codes into error message strings; for details refer to \fBzmq_strerror\fR(3)\&.
.SH "MISCELLANEOUS"
.sp
The following miscellaneous functions are provided:
.PP
Report 0MQ library version
.RS 4
\fBzmq_version\fR(3)
.RE
.SH "LANGUAGE BINDINGS"
.sp
The 0MQ library provides interfaces suitable for calling from programs in any language; this documentation documents those interfaces as they would be used by C programmers\&. The intent is that programmers using 0MQ from other languages shall refer to this documentation alongside any documentation provided by the vendor of their language binding\&.
.SS "C++ language binding"
.sp
The 0MQ distribution includes a C++ language binding, which is documented separately in \fBzmq_cpp\fR(7)\&.
.SS "Other language bindings"
.sp
Other language bindings (Python, Ruby, Java and more) are provided by members of the 0MQ community and pointers can be found on the 0MQ website\&.
.SH "AUTHORS"
.sp
This 0MQ manual page was written by Martin Sustrik <\m[blue]\fBsustrik@250bpm\&.com\fR\m[]\&\s-2\u[1]\d\s+2> and Martin Lucina <\m[blue]\fBmato@kotelna\&.sk\fR\m[]\&\s-2\u[2]\d\s+2>\&.
.SH "RESOURCES"
.sp
Main web site: \m[blue]\fBhttp://www\&.zeromq\&.org/\fR\m[]
.sp
Report bugs to the 0MQ development mailing list: <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[3]\d\s+2>
.SH "COPYING"
.sp
Free use of this software is granted under the terms of the GNU Lesser General Public License (LGPL)\&. For details see the files COPYING and COPYING\&.LESSER included with the 0MQ distribution\&.
.SH "NOTES"
.IP " 1." 4
sustrik@250bpm.com
.RS 4
\%mailto:sustrik@250bpm.com
.RE
.IP " 2." 4
mato@kotelna.sk
.RS 4
\%mailto:mato@kotelna.sk
.RE
.IP " 3." 4
zeromq-dev@lists.zeromq.org
.RS 4
\%mailto:zeromq-dev@lists.zeromq.org
.RE
|