'\" t .\" Title: zmq .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 11/23/2012 .\" Manual: 0MQ Manual .\" Source: 0MQ 3.2.1 .\" Language: English .\" .TH "ZMQ" "7" "11/23/2012" "0MQ 3\&.2\&.1" "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 \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 you must create a 0MQ \fIcontext\fR\&. When you exit your application you must destroy the \fIcontext\fR\&. These functions let you work with \fIcontexts\fR: .PP Create a new 0MQ context .RS 4 \fBzmq_ctx_new\fR(3) .RE .PP Work with context properties .RS 4 \fBzmq_ctx_set\fR(3) \fBzmq_ctx_get\fR(3) .RE .PP Destroy a 0MQ context .RS 4 \fBzmq_ctx_destroy\fR(3) .RE .PP Monitor a 0MQ context .RS 4 \fBzmq_ctx_set_monitor\fR(3) .RE .sp These deprecated functions let you create and destroy \fIcontexts\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 Sending and receiving a message .RS 4 \fBzmq_msg_send\fR(3) \fBzmq_msg_recv\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) \fBzmq_msg_more\fR(3) .RE .PP Work with message properties .RS 4 \fBzmq_msg_get\fR(3) \fBzmq_msg_set\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_msg_send\fR(3) \fBzmq_msg_recv\fR(3) \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 "Proxies" .sp 0MQ provides \fIproxies\fR to create fanout and fan\-in topologies\&. A proxy connects a \fIfrontend\fR socket to a \fIbackend\fR socket and switches all messages between the two sockets, opaquely\&. A proxy may optionally capture all traffic to a third socket\&. To start a proxy in an application thread, use \fBzmq_proxy\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\&. .sp Language bindings (C++, Python, PHP, 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>, Martin Lucina <\m[blue]\fBmartin@lucina\&.net\fR\m[]\&\s-2\u[2]\d\s+2>, and Pieter Hintjens <\m[blue]\fBph@imatix\&.com\fR\m[]\&\s-2\u[3]\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[4]\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 martin@lucina.net .RS 4 \%mailto:martin@lucina.net .RE .IP " 3." 4 ph@imatix.com .RS 4 \%mailto:ph@imatix.com .RE .IP " 4." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE