2013-10-18 16:35:54 +02:00
|
|
|
zmq_proxy_steerable(3)
|
|
|
|
======================
|
|
|
|
|
|
|
|
NAME
|
|
|
|
----
|
2014-05-20 15:42:09 +02:00
|
|
|
zmq_proxy_steerable - built-in 0MQ proxy with control flow
|
2013-10-18 16:35:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
--------
|
|
|
|
*int zmq_proxy_steerable (const void '*frontend', const void '*backend',
|
2013-12-23 13:14:32 +01:00
|
|
|
const void '*capture', const void '*control');*
|
2013-10-18 16:35:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
|
|
|
The _zmq_proxy_steerable()_ function starts the built-in 0MQ proxy in the
|
|
|
|
current application thread, as _zmq_proxy()_ do. Please, refer to this function
|
|
|
|
for the general description and usage. We describe here only the additional
|
|
|
|
control flow provided by the socket passed as the fourth argument "control".
|
|
|
|
|
|
|
|
If the control socket is not NULL, the proxy supports control flow. If
|
2013-12-17 15:27:55 +03:00
|
|
|
'PAUSE' is received on this socket, the proxy suspends its activities. If
|
|
|
|
'RESUME' is received, it goes on. If 'TERMINATE' is received, it terminates
|
2017-10-17 11:08:09 +02:00
|
|
|
smoothly. If 'STATISTICS' is received, the proxy will reply on the control socket
|
2017-10-17 13:20:34 +01:00
|
|
|
sending a multipart message with 8 frames, each with an unsigned integer 64-bit
|
|
|
|
wide that provide in the following order:
|
2017-10-17 11:08:09 +02:00
|
|
|
- number of messages received by the frontend socket
|
|
|
|
- number of bytes received by the frontend socket
|
|
|
|
- number of messages sent out the frontend socket
|
|
|
|
- number of bytes sent out the frontend socket
|
|
|
|
- number of messages received by the backend socket
|
|
|
|
- number of bytes received by the backend socket
|
|
|
|
- number of messages sent out the backend socket
|
|
|
|
- number of bytes sent out the backend socket
|
2013-10-18 16:35:54 +02:00
|
|
|
|
2017-10-17 11:08:09 +02:00
|
|
|
At start, the proxy runs normally as if zmq_proxy was used.
|
|
|
|
|
|
|
|
If the control socket is NULL, the function behave exactly as if linkzmq:zmq_proxy[3]
|
2013-10-18 16:35:54 +02:00
|
|
|
had been called.
|
|
|
|
|
|
|
|
|
|
|
|
Refer to linkzmq:zmq_socket[3] for a description of the available socket types.
|
|
|
|
Refer to linkzmq:zmq_proxy[3] for a description of the zmq_proxy.
|
|
|
|
|
|
|
|
EXAMPLE USAGE
|
|
|
|
-------------
|
|
|
|
cf zmq_proxy
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
------------
|
|
|
|
The _zmq_proxy_steerable()_ function returns 0 if TERMINATE is sent to its
|
2017-01-03 15:34:08 +01:00
|
|
|
control socket. Otherwise, it returns `-1` and 'errno' set to *ETERM* or
|
|
|
|
*EINTR* (the 0MQ 'context' associated with either of the specified sockets was
|
|
|
|
terminated).
|
2013-10-18 16:35:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
EXAMPLE
|
|
|
|
-------
|
|
|
|
.Creating a shared queue proxy
|
|
|
|
----
|
|
|
|
// Create frontend, backend and control sockets
|
|
|
|
void *frontend = zmq_socket (context, ZMQ_ROUTER);
|
|
|
|
assert (backend);
|
|
|
|
void *backend = zmq_socket (context, ZMQ_DEALER);
|
|
|
|
assert (frontend);
|
|
|
|
void *control = zmq_socket (context, ZMQ_SUB);
|
|
|
|
assert (control);
|
2013-12-23 13:14:32 +01:00
|
|
|
|
2013-10-18 16:35:54 +02:00
|
|
|
// Bind sockets to TCP ports
|
|
|
|
assert (zmq_bind (frontend, "tcp://*:5555") == 0);
|
|
|
|
assert (zmq_bind (backend, "tcp://*:5556") == 0);
|
|
|
|
assert (zmq_connect (control, "tcp://*:5557") == 0);
|
2013-12-23 13:14:32 +01:00
|
|
|
|
2013-10-18 16:35:54 +02:00
|
|
|
// Subscribe to the control socket since we have chosen SUB here
|
|
|
|
assert (zmq_setsockopt (control, ZMQ_SUBSCRIBE, "", 0));
|
2013-12-23 13:14:32 +01:00
|
|
|
|
|
|
|
// Start the queue proxy, which runs until ETERM or "TERMINATE"
|
|
|
|
// received on the control socket
|
2013-11-15 15:31:09 +01:00
|
|
|
zmq_proxy_steerable (frontend, backend, NULL, control);
|
2013-10-18 16:35:54 +02:00
|
|
|
----
|
|
|
|
.Set up a controller in another node, process or whatever
|
|
|
|
----
|
|
|
|
void *control = zmq_socket (context, ZMQ_PUB);
|
|
|
|
assert (control);
|
|
|
|
assert (zmq_bind (control, "tcp://*:5557") == 0);
|
2013-12-23 13:14:32 +01:00
|
|
|
|
2013-12-17 15:27:55 +03:00
|
|
|
// pause the proxy
|
|
|
|
assert (zmq_send (control, "PAUSE", 5, 0) == 0);
|
2013-12-23 13:14:32 +01:00
|
|
|
|
2013-10-18 16:35:54 +02:00
|
|
|
// resume the proxy
|
2013-12-17 15:27:55 +03:00
|
|
|
assert (zmq_send (control, "RESUME", 6, 0) == 0);
|
2013-12-23 13:14:32 +01:00
|
|
|
|
2013-10-18 16:35:54 +02:00
|
|
|
// terminate the proxy
|
2013-12-17 15:27:55 +03:00
|
|
|
assert (zmq_send (control, "TERMINATE", 9, 0) == 0);
|
2013-10-18 16:35:54 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
SEE ALSO
|
|
|
|
--------
|
|
|
|
linkzmq:zmq_proxy[3]
|
|
|
|
linkzmq:zmq_bind[3]
|
|
|
|
linkzmq:zmq_connect[3]
|
|
|
|
linkzmq:zmq_socket[3]
|
|
|
|
linkzmq:zmq[7]
|
|
|
|
|
|
|
|
|
|
|
|
AUTHORS
|
|
|
|
-------
|
|
|
|
This page was written by the 0MQ community. To make a change please
|
|
|
|
read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.
|