'\" t .\" Title: zmq_proxy_steerable .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 10/14/2014 .\" Manual: 0MQ Manual .\" Source: 0MQ 4.0.5 .\" Language: English .\" .TH "ZMQ_PROXY_STEERABLE" "3" "10/14/2014" "0MQ 4\&.0\&.5" "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_proxy_steerable \- start built\-in 0MQ proxy with PAUSE/RESUME/TERMINATE control flow .SH "SYNOPSIS" .sp \fBint zmq_proxy_steerable (const void \fR\fB\fI*frontend\fR\fR\fB, const void \fR\fB\fI*backend\fR\fR\fB, const void \fR\fB\fI*capture\fR\fR\fB, const void \fR\fB\fI*control\fR\fR\fB);\fR .SH "DESCRIPTION" .sp The \fIzmq_proxy_steerable()\fR function starts the built\-in 0MQ proxy in the current application thread, as \fIzmq_proxy()\fR 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"\&. .sp If the control socket is not NULL, the proxy supports control flow\&. If \fIPAUSE\fR is received on this socket, the proxy suspends its activities\&. If \fIRESUME\fR is received, it goes on\&. If \fITERMINATE\fR is received, it terminates smoothly\&. At start, the proxy runs normally as if zmq_proxy was used\&. .sp If the control socket is NULL, the function behave exactly as if zmq_proxy had been called\&. .sp Refer to \fBzmq_socket\fR(3) for a description of the available socket types\&. Refer to \fBzmq_proxy\fR(3) for a description of the zmq_proxy\&. .SH "EXAMPLE USAGE" .sp cf zmq_proxy .SH "RETURN VALUE" .sp The \fIzmq_proxy_steerable()\fR function returns 0 if TERMINATE is sent to its control socket\&. Otherwise, it returns \-1 and \fIerrno\fR set to \fBETERM\fR (the 0MQ \fIcontext\fR associated with either of the specified sockets was terminated)\&. .SH "EXAMPLE" .PP \fBCreating a shared queue proxy\fR. .sp .if n \{\ .RS 4 .\} .nf // 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); // 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); // Subscribe to the control socket since we have chosen SUB here assert (zmq_setsockopt (control, ZMQ_SUBSCRIBE, "", 0)); // Start the queue proxy, which runs until ETERM or "TERMINATE" // received on the control socket zmq_proxy_steerable (frontend, backend, NULL, control); .fi .if n \{\ .RE .\} .PP \fBSet up a controller in another node, process or whatever\fR. .sp .if n \{\ .RS 4 .\} .nf void *control = zmq_socket (context, ZMQ_PUB); assert (control); assert (zmq_bind (control, "tcp://*:5557") == 0); // pause the proxy assert (zmq_send (control, "PAUSE", 5, 0) == 0); // resume the proxy assert (zmq_send (control, "RESUME", 6, 0) == 0); // terminate the proxy assert (zmq_send (control, "TERMINATE", 9, 0) == 0); \-\-\- SEE ALSO .fi .if n \{\ .RE .\} .sp \fBzmq_proxy\fR(3) \fBzmq_bind\fR(3) \fBzmq_connect\fR(3) \fBzmq_socket\fR(3) \fBzmq\fR(7) .SH "AUTHORS" .sp This page was written by the 0MQ community\&. To make a change please read the 0MQ Contribution Policy at \m[blue]\fBhttp://www\&.zeromq\&.org/docs:contributing\fR\m[]\&.