~ubuntu-branches/ubuntu/saucy/zeromq3/saucy

« back to all changes in this revision

Viewing changes to doc/zmq_proxy.txt

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2012-10-16 19:49:30 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20121016194930-98r0bi746eoaa4iv
Tags: 3.2.1~rc2+dfsg-1
* New upstream RC release (Closes: #690704)
* Bump Standards-Version to 3.9.4 (no changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
zmq_proxy(3)
 
2
============
 
3
 
 
4
NAME
 
5
----
 
6
zmq_proxy - start built-in 0MQ proxy
 
7
 
 
8
 
 
9
SYNOPSIS
 
10
--------
 
11
*int zmq_proxy (const void '*frontend', const void '*backend', const void '*capture');*
 
12
 
 
13
 
 
14
DESCRIPTION
 
15
-----------
 
16
The _zmq_proxy()_ function starts the built-in 0MQ proxy in the current
 
17
application thread.
 
18
 
 
19
The proxy connects a frontend socket to a backend socket. Conceptually, data
 
20
flows from frontend to backend. Depending on the socket types, replies may flow
 
21
in the opposite direction. The direction is conceptual only; the proxy is fully
 
22
symmetric and there is no technical difference between frontend and backend.
 
23
 
 
24
Before calling _zmq_proxy()_ you must set any socket options, and connect or
 
25
bind both frontend and backend sockets. The two conventional proxy models are:
 
26
 
 
27
_zmq_proxy()_ runs in the current thread and returns only if/when the current
 
28
context is closed.
 
29
 
 
30
If the capture socket is not NULL, the proxy shall send all messages, received
 
31
on both frontend and backend, to the capture socket. The capture socket should
 
32
be a 'ZMQ_PUB', 'ZMQ_DEALER', 'ZMQ_PUSH', or 'ZMQ_PAIR' socket.
 
33
 
 
34
Refer to linkzmq:zmq_socket[3] for a description of the available socket types.
 
35
 
 
36
EXAMPLE USAGE
 
37
-------------
 
38
 
 
39
Shared Queue
 
40
~~~~~~~~~~~~
 
41
 
 
42
When the frontend is a ZMQ_ROUTER socket, and the backend is a ZMQ_DEALER
 
43
socket, the proxy shall act as a shared queue that collects requests from a
 
44
set of clients, and distributes these fairly among a set of services.
 
45
Requests shall be fair-queued from frontend connections and distributed evenly
 
46
across backend connections. Replies shall automatically return to the client
 
47
that made the original request.
 
48
 
 
49
Forwarder
 
50
~~~~~~~~~
 
51
 
 
52
When the frontend is a ZMQ_XSUB socket, and the backend is a ZMQ_XPUB socket,
 
53
the proxy shall act as a message forwarder that collects messages from a set
 
54
of publishers and forwards these to a set of subscribers. This may be used to
 
55
bridge networks transports, e.g. read on tcp:// and forward on pgm://.
 
56
 
 
57
Streamer
 
58
~~~~~~~~
 
59
 
 
60
When the frontend is a ZMQ_PULL socket, and the backend is a ZMQ_PUSH socket,
 
61
the proxy shall collect tasks from a set of clients and forwards these to a set
 
62
of workers using the pipeline pattern.
 
63
 
 
64
RETURN VALUE
 
65
------------
 
66
The _zmq_proxy()_ function always returns `-1` and 'errno' set to *ETERM* (the
 
67
0MQ 'context' associated with either of the specified sockets was terminated).
 
68
 
 
69
 
 
70
EXAMPLE
 
71
-------
 
72
.Creating a shared queue proxy
 
73
----
 
74
//  Create frontend and backend sockets
 
75
void *frontend = zmq_socket (context, ZMQ_ROUTER);
 
76
assert (backend);
 
77
void *backend = zmq_socket (context, ZMQ_DEALER);
 
78
assert (frontend);
 
79
//  Bind both sockets to TCP ports
 
80
assert (zmq_bind (frontend, "tcp://*:5555") == 0);
 
81
assert (zmq_bind (backend, "tcp://*:5556") == 0);
 
82
//  Start the queue proxy, which runs until ETERM
 
83
zmq_proxy (frontend, backend, NULL);
 
84
----
 
85
 
 
86
 
 
87
SEE ALSO
 
88
--------
 
89
linkzmq:zmq_bind[3]
 
90
linkzmq:zmq_connect[3]
 
91
linkzmq:zmq_socket[3]
 
92
linkzmq:zmq[7]
 
93
 
 
94
 
 
95
AUTHORS
 
96
-------
 
97
This 0MQ manual page was written by Pieter Hintjens <ph@imatix.com>