ZeroMQ介面函式之 :zmq_proxy_steerable – 以STOP/RESUME/TERMINATE控制方式開啟內建的ZMQ代理
—————————————————————————————————————
zmq_proxy_steerable(3) ØMQ Manual - ØMQ/4.1.0
Name
zmq_proxy_steerable – 以STOP/RESUME/TERMINATE控制方式開啟內建的ZMQ代理
Synopsis
int zmq_proxy_steerable (const void *frontend, const void *backend, const void *capture, const void *control);
Description
zmq_proxy_steerable()函式會在當前的應用執行緒中開啟ZMQ內建的代理,就和zmq_proxy()一樣。請草考這個函式的一般描述和使用。我們只在這裡只討論新增加的第四個引數“control”。如果控制socket不為NULL,這個代理支援後續的控制操作。如果這個socket接收到SUSPEND\0
如果控制socket為NULL,此函式和zmq_proxy的工作方式一樣。
參見zmq_socket(3)函式獲取可用socket型別的描述。zmq_proxy(3)章節獲取對zmq_proxy的描述。
Example usage
Return value
當控制socket接收到TERMINATE時zmq_proxy_steerable()函式返回0,。否則,返回 -1,並且設定errno為ETERM
Example
建立一個共享的代理佇列
// 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 (frontend, backend, NULL, control);
在另一個節點上建立一個控制器,程序或者其它
void *control = zmq_socket (context, ZMQ_PUB);
assert (control);
assert (zmq_bind (control, "tcp://*:5557") == 0);
// stop the proxy
assert (zmq_send (control, "STOP", 5, 0) == 0);
// resume the proxy
assert (zmq_send (control, "RESUME", 7, 0) == 0);
// terminate the proxy
assert (zmq_send (control, "TERMINATE", 10, 0) == 0);
See also
zmq_proxy(3) zmq_bind(3) zmq_connect(3) zmq_socket(3) zmq(7)
Authors
This page was written by the ØMQ community. To make a change please read the ØMQ Contribution Policy at http://www.zeromq.org/docs:contributing.
Web site design and content is copyright (c) 2007-2012 iMatix Corporation. Contact us for professional support. Site content licensed under the Creative Commons Attribution-Share Alike 3.0 License. ØMQ is copyright (c) Copyright (c) 2007-2012 iMatix Corporation and Contributors. ØMQ is free software licensed under the LGPL. ØMQ, ZeroMQ, and 0MQ are trademarks of iMatix Corporation. Terms of Use — Privacy
Policy
翻譯:風波
mail : [email protected]