rbczmq 1.7.1 → 1.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitmodules +1 -1
- data/CHANGELOG.rdoc +4 -0
- data/Gemfile.lock +1 -1
- data/README.rdoc +5 -4
- data/ext/czmq/.gitignore +5 -0
- data/ext/czmq/.travis.yml +10 -1
- data/ext/czmq/AUTHORS +2 -0
- data/ext/czmq/COPYING.LESSER +3 -0
- data/ext/czmq/Makefile.am +13 -3
- data/ext/czmq/NEWS +132 -0
- data/ext/czmq/README.md +1553 -615
- data/ext/czmq/README.txt +188 -72
- data/ext/czmq/addons/Makefile.am +9 -0
- data/ext/czmq/addons/makecert.c +72 -0
- data/ext/czmq/builds/mingw32/Makefile.mingw32 +11 -3
- data/ext/czmq/builds/msvc/.gitignore +4 -1
- data/ext/czmq/builds/msvc/czmq.vcproj +4 -0
- data/ext/czmq/builds/msvc/czmq.vcxproj +6 -1
- data/ext/czmq/builds/msvc/czmq.vcxproj.filters +4 -1
- data/ext/{zeromq/cmake/Modules/zmq_version.cpp → czmq/builds/msvc/platform.h} +10 -9
- data/ext/czmq/configure.ac +64 -5
- data/ext/czmq/doc/Makefile.am +8 -1
- data/ext/czmq/doc/mkmans +17 -0
- data/ext/czmq/doc/zauth.txt +191 -0
- data/ext/czmq/doc/zbeacon.txt +13 -22
- data/ext/czmq/doc/zcert.txt +122 -0
- data/ext/czmq/doc/zcertstore.txt +107 -0
- data/ext/czmq/doc/zchunk.txt +77 -0
- data/ext/czmq/doc/zclock.txt +8 -0
- data/ext/czmq/doc/zconfig.txt +9 -63
- data/ext/czmq/doc/zctx.txt +26 -7
- data/ext/czmq/doc/zdir.txt +83 -0
- data/ext/czmq/doc/zfile.txt +130 -35
- data/ext/czmq/doc/zframe.txt +6 -39
- data/ext/czmq/doc/zhash.txt +55 -10
- data/ext/czmq/doc/zlist.txt +2 -4
- data/ext/czmq/doc/zloop.txt +7 -1
- data/ext/czmq/doc/zmsg.txt +75 -32
- data/ext/czmq/doc/zpoller.txt +88 -0
- data/ext/czmq/doc/zsocket.txt +50 -1
- data/ext/czmq/doc/zsockopt.txt +185 -251
- data/ext/czmq/doc/zstr.txt +14 -3
- data/ext/czmq/doc/zsys.txt +89 -1
- data/ext/czmq/doc/ztree.txt +21 -11
- data/ext/czmq/examples/security/LICENSE +18 -0
- data/ext/czmq/examples/security/README.txt +9 -0
- data/ext/czmq/examples/security/grasslands.c +29 -0
- data/ext/czmq/examples/security/hello.c +10 -0
- data/ext/czmq/examples/security/ironhouse.c +55 -0
- data/ext/czmq/examples/security/ironhouse2.c +103 -0
- data/ext/czmq/examples/security/stonehouse.c +51 -0
- data/ext/czmq/examples/security/strawhouse.c +44 -0
- data/ext/czmq/examples/security/woodhouse.c +40 -0
- data/ext/czmq/images/README_1.png +0 -0
- data/ext/czmq/images/README_2.png +0 -0
- data/ext/czmq/include/czmq.h +10 -4
- data/ext/czmq/include/czmq_prelude.h +42 -42
- data/ext/czmq/include/zauth.h +97 -0
- data/ext/czmq/include/zbeacon.h +0 -5
- data/ext/czmq/include/zcert.h +118 -0
- data/ext/czmq/include/zcertstore.h +78 -0
- data/ext/czmq/include/zchunk.h +87 -0
- data/ext/czmq/include/zclock.h +4 -0
- data/ext/czmq/include/zconfig.h +21 -12
- data/ext/czmq/include/zctx.h +34 -11
- data/ext/czmq/include/zdir.h +90 -0
- data/ext/czmq/include/zfile.h +104 -25
- data/ext/czmq/include/zframe.h +7 -20
- data/ext/czmq/include/zhash.h +13 -0
- data/ext/czmq/include/zlist.h +0 -4
- data/ext/czmq/include/zloop.h +5 -5
- data/ext/czmq/include/zmsg.h +59 -29
- data/ext/czmq/include/zmutex.h +5 -0
- data/ext/czmq/include/zpoller.h +72 -0
- data/ext/czmq/include/zsocket.h +12 -15
- data/ext/czmq/include/zsockopt.h +124 -121
- data/ext/czmq/include/zstr.h +12 -9
- data/ext/czmq/include/zsys.h +50 -2
- data/ext/czmq/mkdoc +1 -1
- data/ext/czmq/model/sockopts.xml +101 -21
- data/ext/czmq/scripts/sockopts.gsl +95 -41
- data/ext/czmq/src/Makefile.am +13 -0
- data/ext/czmq/src/czmq_selftest.c +16 -10
- data/ext/czmq/src/selftest +2 -2
- data/ext/czmq/src/zauth.c +714 -0
- data/ext/czmq/src/zbeacon.c +27 -35
- data/ext/czmq/src/zcert.c +463 -0
- data/ext/czmq/src/zcertstore.c +265 -0
- data/ext/czmq/src/zchunk.c +207 -0
- data/ext/czmq/src/zclock.c +18 -0
- data/ext/czmq/src/zconfig.c +116 -99
- data/ext/czmq/src/zctx.c +103 -18
- data/ext/czmq/src/zdir.c +409 -0
- data/ext/czmq/src/zfile.c +421 -130
- data/ext/czmq/src/zframe.c +28 -127
- data/ext/czmq/src/zhash.c +255 -139
- data/ext/czmq/src/zlist.c +2 -8
- data/ext/czmq/src/zloop.c +40 -13
- data/ext/czmq/src/zmsg.c +109 -141
- data/ext/czmq/src/zmutex.c +27 -1
- data/ext/czmq/src/zpoller.c +218 -0
- data/ext/czmq/src/zsocket.c +53 -66
- data/ext/czmq/src/zsockopt.c +2337 -682
- data/ext/czmq/src/zstr.c +48 -118
- data/ext/czmq/src/zsys.c +270 -3
- data/ext/czmq/src/zthread.c +2 -2
- data/ext/czmq/src/ztree.c +179 -180
- data/ext/rbczmq/beacon.c +1 -1
- data/ext/rbczmq/context.c +12 -3
- data/ext/rbczmq/context.h +7 -0
- data/ext/rbczmq/extconf.rb +13 -4
- data/ext/rbczmq/pollitem.c +1 -1
- data/ext/rbczmq/socket.c +34 -24
- data/ext/rbczmq/socket.h +3 -2
- data/ext/zeromq/AUTHORS +17 -3
- data/ext/zeromq/CMakeLists.txt +742 -339
- data/ext/zeromq/COPYING.LESSER +2 -0
- data/ext/zeromq/Makefile.am +3 -3
- data/ext/zeromq/NEWS +130 -1
- data/ext/zeromq/{README → README.md} +8 -9
- data/ext/zeromq/builds/cmake/Modules/FindAsciiDoc.cmake +24 -0
- data/ext/zeromq/builds/cmake/Modules/TestZMQVersion.cmake +18 -0
- data/ext/zeromq/builds/cmake/Modules/ZMQSourceRunChecks.cmake +129 -0
- data/ext/zeromq/{cmake → builds/cmake}/NSIS.template32.in +1 -1
- data/ext/zeromq/{cmake → builds/cmake}/NSIS.template64.in +1 -1
- data/ext/zeromq/builds/cmake/platform.hpp.in +88 -0
- data/ext/zeromq/builds/mingw32/Makefile.mingw32 +47 -0
- data/ext/zeromq/{src/i_msg_sink.hpp → builds/mingw32/platform.hpp} +10 -21
- data/ext/zeromq/builds/msvc/Makefile.am +5 -2
- data/ext/zeromq/builds/msvc/c_local_lat/c_local_lat.vcxproj +1 -1
- data/ext/zeromq/builds/msvc/c_local_lat/c_local_lat11.vcxproj +91 -0
- data/ext/zeromq/builds/msvc/c_local_thr/c_local_thr.vcproj +2 -0
- data/ext/zeromq/builds/msvc/c_local_thr/c_local_thr.vcxproj +21 -1
- data/ext/zeromq/builds/msvc/c_local_thr/c_local_thr11.vcxproj +111 -0
- data/ext/zeromq/builds/msvc/c_remote_lat/c_remote_lat.vcxproj +1 -1
- data/ext/zeromq/builds/msvc/c_remote_lat/c_remote_lat11.vcxproj +91 -0
- data/ext/zeromq/builds/msvc/c_remote_thr/c_remote_thr.vcproj +2 -0
- data/ext/zeromq/builds/msvc/c_remote_thr/c_remote_thr.vcxproj +21 -1
- data/ext/zeromq/builds/msvc/c_remote_thr/c_remote_thr11.vcxproj +111 -0
- data/ext/zeromq/builds/msvc/errno.cpp +1 -1
- data/ext/zeromq/builds/msvc/errno.hpp +1 -1
- data/ext/zeromq/builds/msvc/inproc_lat/inproc_lat.vcproj +176 -174
- data/ext/zeromq/builds/msvc/inproc_lat/inproc_lat.vcxproj +21 -1
- data/ext/zeromq/builds/msvc/inproc_lat/inproc_lat11.vcxproj +110 -0
- data/ext/zeromq/builds/msvc/inproc_thr/inproc_thr.vcproj +176 -174
- data/ext/zeromq/builds/msvc/inproc_thr/inproc_thr.vcxproj +21 -1
- data/ext/zeromq/builds/msvc/inproc_thr/inproc_thr11.vcxproj +110 -0
- data/ext/zeromq/builds/msvc/libzmq/libzmq.vcproj +997 -804
- data/ext/zeromq/builds/msvc/libzmq/libzmq.vcxproj +78 -2
- data/ext/zeromq/builds/msvc/libzmq/libzmq.vcxproj.filters +42 -6
- data/ext/zeromq/builds/msvc/libzmq/libzmq11.vcxproj +362 -0
- data/ext/zeromq/builds/msvc/msvc.sln +6 -0
- data/ext/zeromq/builds/msvc/msvc10.sln +36 -2
- data/ext/zeromq/builds/msvc/msvc11.sln +150 -0
- data/ext/zeromq/builds/msvc/properties/Static.props +15 -0
- data/ext/zeromq/builds/msvc/properties/ZeroMQ.props +0 -1
- data/ext/zeromq/builds/msvc/properties/ZeroMQ_Static.props +23 -0
- data/ext/zeromq/builds/redhat/zeromq.spec.in +2 -1
- data/ext/zeromq/{configure.in → configure.ac} +74 -15
- data/ext/zeromq/doc/Makefile.am +6 -4
- data/ext/zeromq/doc/zmq.txt +30 -3
- data/ext/zeromq/doc/zmq_bind.txt +2 -2
- data/ext/zeromq/doc/zmq_close.txt +2 -2
- data/ext/zeromq/doc/zmq_connect.txt +9 -7
- data/ext/zeromq/doc/zmq_ctx_destroy.txt +4 -3
- data/ext/zeromq/doc/zmq_ctx_get.txt +8 -3
- data/ext/zeromq/doc/zmq_ctx_new.txt +3 -2
- data/ext/zeromq/doc/zmq_ctx_set.txt +13 -1
- data/ext/zeromq/doc/zmq_ctx_shutdown.txt +52 -0
- data/ext/zeromq/doc/zmq_ctx_term.txt +67 -0
- data/ext/zeromq/doc/zmq_curve.txt +92 -0
- data/ext/zeromq/doc/zmq_curve_keypair.txt +56 -0
- data/ext/zeromq/doc/zmq_disconnect.txt +2 -2
- data/ext/zeromq/doc/zmq_epgm.txt +5 -4
- data/ext/zeromq/doc/zmq_errno.txt +2 -2
- data/ext/zeromq/doc/zmq_getsockopt.txt +149 -24
- data/ext/zeromq/doc/zmq_init.txt +2 -2
- data/ext/zeromq/doc/zmq_inproc.txt +2 -2
- data/ext/zeromq/doc/zmq_ipc.txt +10 -5
- data/ext/zeromq/doc/zmq_msg_close.txt +4 -3
- data/ext/zeromq/doc/zmq_msg_copy.txt +2 -2
- data/ext/zeromq/doc/zmq_msg_data.txt +2 -2
- data/ext/zeromq/doc/zmq_msg_get.txt +3 -3
- data/ext/zeromq/doc/zmq_msg_init.txt +2 -2
- data/ext/zeromq/doc/zmq_msg_init_data.txt +2 -2
- data/ext/zeromq/doc/zmq_msg_init_size.txt +2 -2
- data/ext/zeromq/doc/zmq_msg_more.txt +6 -4
- data/ext/zeromq/doc/zmq_msg_move.txt +2 -2
- data/ext/zeromq/doc/zmq_msg_recv.txt +3 -4
- data/ext/zeromq/doc/zmq_msg_send.txt +10 -7
- data/ext/zeromq/doc/zmq_msg_set.txt +2 -1
- data/ext/zeromq/doc/zmq_msg_size.txt +2 -2
- data/ext/zeromq/doc/zmq_null.txt +27 -0
- data/ext/zeromq/doc/zmq_pgm.txt +5 -4
- data/ext/zeromq/doc/zmq_plain.txt +37 -0
- data/ext/zeromq/doc/zmq_poll.txt +2 -6
- data/ext/zeromq/doc/zmq_proxy.txt +2 -1
- data/ext/zeromq/doc/zmq_recv.txt +2 -5
- data/ext/zeromq/doc/zmq_recvmsg.txt +3 -5
- data/ext/zeromq/doc/zmq_send.txt +9 -7
- data/ext/zeromq/doc/zmq_send_const.txt +103 -0
- data/ext/zeromq/doc/zmq_sendmsg.txt +8 -8
- data/ext/zeromq/doc/zmq_setsockopt.txt +291 -37
- data/ext/zeromq/doc/zmq_socket.txt +92 -21
- data/ext/zeromq/doc/zmq_socket_monitor.txt +102 -131
- data/ext/zeromq/doc/zmq_strerror.txt +3 -2
- data/ext/zeromq/doc/zmq_tcp.txt +4 -2
- data/ext/zeromq/doc/zmq_term.txt +3 -3
- data/ext/zeromq/doc/zmq_unbind.txt +2 -2
- data/ext/zeromq/doc/zmq_version.txt +3 -2
- data/ext/zeromq/doc/zmq_z85_decode.txt +50 -0
- data/ext/zeromq/doc/zmq_z85_encode.txt +57 -0
- data/ext/zeromq/foreign/openpgm/libpgm-5.2.122~dfsg.tar.gz +0 -0
- data/ext/zeromq/include/zmq.h +179 -136
- data/ext/zeromq/include/zmq_utils.h +44 -3
- data/ext/zeromq/perf/inproc_lat.cpp +2 -4
- data/ext/zeromq/perf/inproc_thr.cpp +1 -1
- data/ext/zeromq/perf/local_lat.cpp +1 -3
- data/ext/zeromq/perf/local_thr.cpp +1 -3
- data/ext/zeromq/perf/remote_lat.cpp +1 -3
- data/ext/zeromq/perf/remote_thr.cpp +1 -8
- data/ext/zeromq/src/Makefile.am +26 -7
- data/ext/zeromq/src/address.cpp +7 -8
- data/ext/zeromq/src/address.hpp +1 -2
- data/ext/zeromq/src/array.hpp +1 -3
- data/ext/zeromq/src/atomic_counter.hpp +11 -3
- data/ext/zeromq/src/atomic_ptr.hpp +9 -3
- data/ext/zeromq/src/blob.hpp +2 -2
- data/ext/zeromq/src/clock.cpp +3 -4
- data/ext/zeromq/src/clock.hpp +1 -2
- data/ext/zeromq/src/command.hpp +2 -3
- data/ext/zeromq/src/config.hpp +1 -3
- data/ext/zeromq/src/ctx.cpp +154 -15
- data/ext/zeromq/src/ctx.hpp +34 -3
- data/ext/zeromq/src/curve_client.cpp +410 -0
- data/ext/zeromq/src/curve_client.hpp +109 -0
- data/ext/zeromq/src/curve_server.cpp +629 -0
- data/ext/zeromq/src/curve_server.hpp +120 -0
- data/ext/zeromq/src/dbuffer.hpp +134 -0
- data/ext/zeromq/src/dealer.cpp +52 -60
- data/ext/zeromq/src/dealer.hpp +12 -26
- data/ext/zeromq/src/decoder.hpp +27 -102
- data/ext/zeromq/src/devpoll.cpp +1 -3
- data/ext/zeromq/src/devpoll.hpp +1 -3
- data/ext/zeromq/src/dist.cpp +17 -15
- data/ext/zeromq/src/dist.hpp +5 -6
- data/ext/zeromq/src/encoder.hpp +32 -52
- data/ext/zeromq/src/epoll.cpp +1 -3
- data/ext/zeromq/src/epoll.hpp +1 -3
- data/ext/zeromq/src/err.cpp +2 -4
- data/ext/zeromq/src/err.hpp +7 -4
- data/ext/zeromq/src/fd.hpp +1 -2
- data/ext/zeromq/src/fq.cpp +2 -5
- data/ext/zeromq/src/fq.hpp +2 -4
- data/ext/zeromq/src/i_decoder.hpp +11 -9
- data/ext/zeromq/src/i_encoder.hpp +7 -11
- data/ext/zeromq/src/i_engine.hpp +3 -3
- data/ext/zeromq/src/i_poll_events.hpp +1 -3
- data/ext/zeromq/src/io_object.cpp +1 -3
- data/ext/zeromq/src/io_object.hpp +1 -3
- data/ext/zeromq/src/io_thread.cpp +1 -3
- data/ext/zeromq/src/io_thread.hpp +1 -3
- data/ext/zeromq/src/ip.cpp +46 -5
- data/ext/zeromq/src/ip.hpp +7 -4
- data/ext/zeromq/src/ipc_address.cpp +13 -2
- data/ext/zeromq/src/ipc_address.hpp +1 -2
- data/ext/zeromq/src/ipc_connecter.cpp +3 -3
- data/ext/zeromq/src/ipc_connecter.hpp +1 -2
- data/ext/zeromq/src/ipc_listener.cpp +15 -10
- data/ext/zeromq/src/ipc_listener.hpp +1 -2
- data/ext/zeromq/src/kqueue.cpp +11 -3
- data/ext/zeromq/src/kqueue.hpp +7 -3
- data/ext/zeromq/src/lb.cpp +13 -11
- data/ext/zeromq/src/lb.hpp +10 -5
- data/ext/zeromq/src/libzmq.pc.cmake.in +10 -0
- data/ext/zeromq/src/likely.hpp +1 -2
- data/ext/zeromq/src/mailbox.cpp +1 -4
- data/ext/zeromq/src/mailbox.hpp +8 -3
- data/ext/zeromq/src/mechanism.cpp +163 -0
- data/ext/zeromq/src/mechanism.hpp +101 -0
- data/ext/zeromq/src/msg.cpp +38 -18
- data/ext/zeromq/src/msg.hpp +19 -7
- data/ext/zeromq/src/mtrie.cpp +16 -14
- data/ext/zeromq/src/mtrie.hpp +1 -3
- data/ext/zeromq/src/mutex.hpp +42 -3
- data/ext/zeromq/src/null_mechanism.cpp +282 -0
- data/ext/zeromq/src/null_mechanism.hpp +65 -0
- data/ext/zeromq/src/object.cpp +29 -3
- data/ext/zeromq/src/object.hpp +8 -5
- data/ext/zeromq/src/options.cpp +557 -485
- data/ext/zeromq/src/options.hpp +38 -24
- data/ext/zeromq/src/own.cpp +1 -2
- data/ext/zeromq/src/own.hpp +1 -2
- data/ext/zeromq/src/pair.cpp +8 -25
- data/ext/zeromq/src/pair.hpp +5 -22
- data/ext/zeromq/src/pgm_receiver.cpp +80 -67
- data/ext/zeromq/src/pgm_receiver.hpp +11 -10
- data/ext/zeromq/src/pgm_sender.cpp +37 -16
- data/ext/zeromq/src/pgm_sender.hpp +12 -6
- data/ext/zeromq/src/pgm_socket.cpp +8 -8
- data/ext/zeromq/src/pgm_socket.hpp +1 -4
- data/ext/zeromq/src/pipe.cpp +110 -72
- data/ext/zeromq/src/pipe.hpp +36 -27
- data/ext/zeromq/src/plain_mechanism.cpp +482 -0
- data/ext/zeromq/src/plain_mechanism.hpp +88 -0
- data/ext/zeromq/src/poll.cpp +1 -3
- data/ext/zeromq/src/poll.hpp +1 -3
- data/ext/zeromq/src/poller.hpp +1 -3
- data/ext/zeromq/src/poller_base.cpp +3 -3
- data/ext/zeromq/src/poller_base.hpp +1 -2
- data/ext/zeromq/src/precompiled.cpp +1 -2
- data/ext/zeromq/src/precompiled.hpp +1 -2
- data/ext/zeromq/src/proxy.cpp +1 -2
- data/ext/zeromq/src/proxy.hpp +1 -2
- data/ext/zeromq/src/pub.cpp +2 -16
- data/ext/zeromq/src/pub.hpp +2 -19
- data/ext/zeromq/src/pull.cpp +7 -24
- data/ext/zeromq/src/pull.hpp +4 -21
- data/ext/zeromq/src/push.cpp +8 -22
- data/ext/zeromq/src/push.hpp +4 -21
- data/ext/zeromq/src/random.cpp +1 -2
- data/ext/zeromq/src/random.hpp +1 -2
- data/ext/zeromq/src/raw_decoder.cpp +63 -0
- data/ext/zeromq/src/raw_decoder.hpp +66 -0
- data/ext/zeromq/src/raw_encoder.cpp +40 -0
- data/ext/zeromq/src/raw_encoder.hpp +60 -0
- data/ext/zeromq/src/reaper.cpp +12 -2
- data/ext/zeromq/src/reaper.hpp +6 -2
- data/ext/zeromq/src/rep.cpp +7 -21
- data/ext/zeromq/src/rep.hpp +3 -20
- data/ext/zeromq/src/req.cpp +132 -38
- data/ext/zeromq/src/req.hpp +27 -8
- data/ext/zeromq/src/router.cpp +109 -65
- data/ext/zeromq/src/router.hpp +9 -23
- data/ext/zeromq/src/select.cpp +1 -3
- data/ext/zeromq/src/select.hpp +1 -3
- data/ext/zeromq/src/session_base.cpp +164 -118
- data/ext/zeromq/src/session_base.hpp +29 -22
- data/ext/zeromq/src/signaler.cpp +127 -19
- data/ext/zeromq/src/signaler.hpp +20 -3
- data/ext/zeromq/src/socket_base.cpp +167 -134
- data/ext/zeromq/src/socket_base.hpp +18 -20
- data/ext/zeromq/src/stdint.hpp +1 -2
- data/ext/zeromq/src/stream.cpp +257 -0
- data/ext/zeromq/src/stream.hpp +97 -0
- data/ext/zeromq/src/stream_engine.cpp +405 -157
- data/ext/zeromq/src/stream_engine.hpp +72 -23
- data/ext/zeromq/src/sub.cpp +5 -18
- data/ext/zeromq/src/sub.hpp +2 -19
- data/ext/zeromq/src/tcp.cpp +23 -3
- data/ext/zeromq/src/tcp.hpp +7 -3
- data/ext/zeromq/src/tcp_address.cpp +35 -46
- data/ext/zeromq/src/tcp_address.hpp +7 -12
- data/ext/zeromq/src/tcp_connecter.cpp +10 -5
- data/ext/zeromq/src/tcp_connecter.hpp +1 -3
- data/ext/zeromq/src/tcp_listener.cpp +19 -8
- data/ext/zeromq/src/tcp_listener.hpp +1 -3
- data/ext/zeromq/src/thread.cpp +2 -4
- data/ext/zeromq/src/thread.hpp +1 -3
- data/ext/zeromq/src/trie.cpp +122 -125
- data/ext/zeromq/src/trie.hpp +1 -4
- data/ext/zeromq/src/v1_decoder.cpp +77 -91
- data/ext/zeromq/src/v1_decoder.hpp +10 -21
- data/ext/zeromq/src/v1_encoder.cpp +24 -62
- data/ext/zeromq/src/v1_encoder.hpp +7 -18
- data/ext/zeromq/src/v2_decoder.cpp +142 -0
- data/ext/zeromq/src/v2_decoder.hpp +57 -0
- data/ext/zeromq/src/v2_encoder.cpp +67 -0
- data/ext/zeromq/src/{i_msg_source.hpp → v2_encoder.hpp} +20 -15
- data/ext/zeromq/src/{v1_protocol.hpp → v2_protocol.hpp} +7 -11
- data/ext/zeromq/src/windows.hpp +2 -4
- data/ext/zeromq/src/wire.hpp +5 -6
- data/ext/zeromq/src/xpub.cpp +37 -46
- data/ext/zeromq/src/xpub.hpp +7 -23
- data/ext/zeromq/src/xsub.cpp +26 -40
- data/ext/zeromq/src/xsub.hpp +5 -21
- data/ext/zeromq/src/ypipe.hpp +3 -4
- data/ext/zeromq/src/ypipe_base.hpp +44 -0
- data/ext/zeromq/src/ypipe_conflate.hpp +127 -0
- data/ext/zeromq/src/yqueue.hpp +3 -7
- data/ext/zeromq/src/zmq.cpp +76 -96
- data/ext/zeromq/src/zmq_utils.cpp +146 -8
- data/ext/zeromq/tests/Makefile.am +56 -8
- data/ext/zeromq/tests/test_abstract_ipc.cpp +57 -0
- data/ext/zeromq/tests/test_conflate.cpp +75 -0
- data/ext/zeromq/tests/test_connect_resolve.cpp +14 -15
- data/ext/zeromq/tests/test_ctx_destroy.cpp +90 -0
- data/ext/zeromq/tests/test_ctx_options.cpp +52 -0
- data/ext/zeromq/tests/test_disconnect_inproc.cpp +35 -30
- data/ext/zeromq/tests/test_fork.cpp +81 -0
- data/ext/zeromq/tests/test_hwm.cpp +251 -35
- data/ext/zeromq/tests/test_immediate.cpp +229 -0
- data/ext/zeromq/tests/test_inproc_connect.cpp +339 -0
- data/ext/zeromq/tests/test_invalid_rep.cpp +9 -13
- data/ext/zeromq/tests/test_iov.cpp +106 -0
- data/ext/zeromq/tests/test_issue_566.cpp +85 -0
- data/ext/zeromq/tests/test_last_endpoint.cpp +14 -18
- data/ext/zeromq/tests/test_linger.cpp +93 -0
- data/ext/zeromq/tests/test_monitor.cpp +112 -129
- data/ext/zeromq/tests/test_msg_flags.cpp +17 -16
- data/ext/zeromq/tests/test_pair_inproc.cpp +25 -7
- data/ext/zeromq/tests/test_pair_ipc.cpp +4 -7
- data/ext/zeromq/tests/test_pair_tcp.cpp +4 -8
- data/ext/zeromq/tests/test_probe_router.cpp +72 -0
- data/ext/zeromq/tests/test_req_correlate.cpp +177 -0
- data/ext/zeromq/tests/test_req_relaxed.cpp +116 -0
- data/ext/zeromq/tests/test_reqrep_device.cpp +9 -17
- data/ext/zeromq/tests/test_reqrep_inproc.cpp +4 -7
- data/ext/zeromq/tests/test_reqrep_ipc.cpp +4 -7
- data/ext/zeromq/tests/test_reqrep_tcp.cpp +4 -8
- data/ext/zeromq/tests/test_router_mandatory.cpp +41 -22
- data/ext/zeromq/tests/test_security_curve.cpp +212 -0
- data/ext/zeromq/tests/test_security_null.cpp +148 -0
- data/ext/zeromq/tests/test_security_plain.cpp +150 -0
- data/ext/zeromq/tests/test_shutdown_stress.cpp +10 -23
- data/ext/zeromq/tests/test_spec_dealer.cpp +254 -0
- data/ext/zeromq/tests/test_spec_pushpull.cpp +293 -0
- data/ext/zeromq/tests/test_spec_rep.cpp +155 -0
- data/ext/zeromq/tests/test_spec_req.cpp +253 -0
- data/ext/zeromq/tests/test_spec_router.cpp +204 -0
- data/ext/zeromq/tests/test_stream.cpp +228 -0
- data/ext/zeromq/tests/test_sub_forward.cpp +14 -22
- data/ext/zeromq/tests/test_system.cpp +82 -0
- data/ext/zeromq/tests/test_term_endpoint.cpp +17 -31
- data/ext/zeromq/tests/test_timeo.cpp +34 -78
- data/ext/zeromq/tests/testutil.hpp +211 -26
- data/ext/zeromq/tools/Makefile.am +9 -0
- data/ext/zeromq/tools/curve_keygen.c +58 -0
- data/lib/zmq/version.rb +1 -1
- data/test/test_socket.rb +4 -3
- metadata +114 -15
- data/ext/zeromq/cmake/Modules/TestZMQVersion.cmake +0 -35
- data/ext/zeromq/foreign/openpgm/libpgm-5.1.118~dfsg.tar.gz +0 -0
- data/ext/zeromq/src/decoder.cpp +0 -166
- data/ext/zeromq/src/encoder.cpp +0 -102
- data/ext/zeromq/tests/test_connect_delay.cpp +0 -260
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTFkZjRmNzg3MjRiYTliZmZkZjYxYTY0MTU1Y2M5NzM0ZDJhMWM1Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWM5YTFmMTBhOWNmMjNjZWY0Y2EzZjM1NTM0MmI2NTc1MDI2MWIyZg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWM2NzNjZmIyN2I1MzAzMjAwNGZmZDZjNjZmMmU2OWJlNDYyMzRjN2RlNmEx
|
10
|
+
MTMwZTkwNTIxMjNmZWM5NzkxYjM2MzM4ZWNlNWRlNGI3NzY4MDQzOTViMmQx
|
11
|
+
NWNlMjQ3YWQ1NTVmMWU5MDk1NjVmNWRlOTA5Mjc4NGE2ZDBkODM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDc4OWZhNjQ0Njk1OTQ4ZDI5MDAxNGI0YjllNWQyNWUwMTllMGJlYjM4N2Fl
|
14
|
+
ZDQ3MDJlYzRlMDc4NWRiZjU1ZjVlODg0YTBhYjI3NTljOGFlOTc2NjBhN2Jh
|
15
|
+
NTgwYjcwNGJjZjI2NGExODcyZGMwZDFkMTNkOTI5OTlkYTU1Yzc=
|
data/.gitmodules
CHANGED
data/CHANGELOG.rdoc
CHANGED
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= rbczmq - binding for the high level ZeroMQ C API {<img src="https://secure.travis-ci.org/methodmissing/rbczmq.png" alt="Build Status" />}[http://travis-ci.org/methodmissing/rbczmq]
|
2
2
|
|
3
|
-
(c) 2011 Lourens Naudé (methodmissing), James Tucker (raggi) with API guidance from the czmq (http://czmq.zeromq.org/) project.
|
3
|
+
(c) 2011-2013 Lourens Naudé (methodmissing), James Tucker (raggi), Matt Connolly (mattconnolly) with API guidance from the czmq (http://czmq.zeromq.org/) project.
|
4
4
|
|
5
5
|
http://github.com/methodmissing/rbczmq
|
6
6
|
|
@@ -203,9 +203,10 @@ Here's a few basic examples. Please refer to documentation (http://methodmissing
|
|
203
203
|
|
204
204
|
== Requirements
|
205
205
|
|
206
|
-
* A POSIX compliant OS, known to work well on Linux, BSD variants
|
207
|
-
* Ruby MRI 1.
|
206
|
+
* A POSIX compliant OS, known to work well on Linux, BSD variants, Mac OS X and SmartOS.
|
207
|
+
* Ruby MRI 1.9, 2.0 or Rubinius (JRuby capi support forthcoming)
|
208
208
|
* A C compiler
|
209
|
+
* This is a "fat" gem, including its own source code for both ZeroMQ and CZMQ libraries. No system installation if either library is required.
|
209
210
|
|
210
211
|
== Installation
|
211
212
|
|
@@ -241,7 +242,6 @@ This gem uses the "zmq" and "czmq" libraries, both of which are licensed under t
|
|
241
242
|
|
242
243
|
* ZMQ::Message#save && ZMQ::Message.load
|
243
244
|
* Optimize zloop handler callbacks (perftools)
|
244
|
-
* OS X leaks utility - http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/leaks.1.html
|
245
245
|
* Handle GC issue with timers in loop callbacks
|
246
246
|
* czmq send methods aren't non-blocking by default
|
247
247
|
* Revisit the ZMQ::Loop API
|
@@ -252,6 +252,7 @@ This gem uses the "zmq" and "czmq" libraries, both of which are licensed under t
|
|
252
252
|
* Do not clobber local scope from macros (James's commit in master)
|
253
253
|
* Incorporate examples into CI as well
|
254
254
|
* Zero-copy semantics for frames
|
255
|
+
* Enable use of a system installed ZeroMQ/CZMQ libraries.
|
255
256
|
|
256
257
|
== Contact, feedback and bugs
|
257
258
|
|
data/ext/czmq/.gitignore
CHANGED
data/ext/czmq/.travis.yml
CHANGED
@@ -2,9 +2,18 @@
|
|
2
2
|
|
3
3
|
language: c
|
4
4
|
|
5
|
-
# Build required
|
5
|
+
# Build required projects first
|
6
6
|
before_script:
|
7
7
|
|
8
|
+
# libsodium
|
9
|
+
- git clone git://github.com/jedisct1/libsodium.git
|
10
|
+
- cd libsodium
|
11
|
+
- ./autogen.sh
|
12
|
+
- ./configure && make check
|
13
|
+
- sudo make install
|
14
|
+
- sudo ldconfig
|
15
|
+
- cd ..
|
16
|
+
|
8
17
|
# libzmq
|
9
18
|
- git clone git://github.com/zeromq/libzmq.git
|
10
19
|
- cd libzmq
|
data/ext/czmq/AUTHORS
CHANGED
data/ext/czmq/COPYING.LESSER
CHANGED
@@ -176,3 +176,6 @@ linked independent module, the terms and conditions of the license of that
|
|
176
176
|
module. An independent module is a module which is not derived from or based on
|
177
177
|
this library. If you modify this library, you must extend this exception to your
|
178
178
|
version of the library.
|
179
|
+
|
180
|
+
Note: this exception relieves you of any obligations under sections 4 and 5
|
181
|
+
of this license, and section 6 of the GNU General Public License.
|
data/ext/czmq/Makefile.am
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
ACLOCAL_AMFLAGS = -I config
|
2
2
|
|
3
|
-
SUBDIRS = src doc
|
3
|
+
SUBDIRS = src doc addons
|
4
4
|
|
5
|
-
DIST_SUBDIRS = src doc
|
5
|
+
DIST_SUBDIRS = src doc addons
|
6
6
|
|
7
7
|
EXTRA_DIST = \
|
8
8
|
builds/android/Android.mk \
|
@@ -19,4 +19,14 @@ EXTRA_DIST = \
|
|
19
19
|
builds/msvc/czmq.vcproj \
|
20
20
|
builds/msvc/czmq.vcxproj \
|
21
21
|
builds/msvc/czmq.vcxproj.filters \
|
22
|
-
builds/msvc/README.txt
|
22
|
+
builds/msvc/README.txt \
|
23
|
+
builds/msvc/platform.h \
|
24
|
+
examples/security/grasslands.c \
|
25
|
+
examples/security/strawhouse.c \
|
26
|
+
examples/security/woodhouse.c \
|
27
|
+
examples/security/stonehouse.c \
|
28
|
+
examples/security/ironhouse.c \
|
29
|
+
examples/security/ironhouse2.c \
|
30
|
+
examples/security/README.txt \
|
31
|
+
examples/security/LICENSE
|
32
|
+
|
data/ext/czmq/NEWS
CHANGED
@@ -1,3 +1,135 @@
|
|
1
|
+
CZMQ version 2.0.1 (rc2), released on 2013/09/21
|
2
|
+
================================================
|
3
|
+
|
4
|
+
Updated to support ZeroMQ v4.x. If you are using an older version of CZMQ
|
5
|
+
it will not build correctly with ZeroMQ v4.x. Sorry about that.
|
6
|
+
|
7
|
+
Added support for the new socket options:
|
8
|
+
|
9
|
+
* zsocket_set_req_relaxed ()
|
10
|
+
* zsocket_set_req_correlate ()
|
11
|
+
* zsocket_set_conflate ()
|
12
|
+
|
13
|
+
|
14
|
+
CZMQ version 2.0.0 (rc1), released on 2013/09/19
|
15
|
+
================================================
|
16
|
+
|
17
|
+
The changes are mainly tools to support encryption via the libzmq CURVE
|
18
|
+
mechanism, but also some new API constructs to make it simpler to do
|
19
|
+
common messaging work.
|
20
|
+
|
21
|
+
Bug fixes and cleanups of codebase:
|
22
|
+
|
23
|
+
* zconfig_load () failed if the ZPL file contained a blank line.
|
24
|
+
|
25
|
+
* zconfig_locate () allows and ignores initial '/' on pathname.
|
26
|
+
|
27
|
+
* Added zsys_vprintf () to centralize all variable string formatting;
|
28
|
+
this code was duplicated many times across the project.
|
29
|
+
|
30
|
+
* Updated zmsg interface documentation to be more detailed.
|
31
|
+
|
32
|
+
* Removed deprecated zstr_sendfm () method.
|
33
|
+
|
34
|
+
* Removed deprecated zstr_sendf () method.
|
35
|
+
|
36
|
+
* Removed definition of ZMQ_IGNERR and added zloop_set_tolerant ()
|
37
|
+
to configure a specific poller as error-tolerant.
|
38
|
+
|
39
|
+
* Removed deprecated zframe and zmsg zero-copy methods; this API was
|
40
|
+
too complex and split over several classes, and IMO if we want this
|
41
|
+
optimization it should be in a new zero-copy class with a clean API.
|
42
|
+
|
43
|
+
* Removed deprecated zsocket zero-copy methods, for above reason.
|
44
|
+
|
45
|
+
* Removed deprecated zlist_copy method.
|
46
|
+
|
47
|
+
* Renamed zframe_print_to_stream to zframe_fprint and kept old name
|
48
|
+
as deprecated macro.
|
49
|
+
|
50
|
+
* Removed (not deprecated) zctx_set_hwm () as its semantics were not
|
51
|
+
consistent, and confusing to people.
|
52
|
+
|
53
|
+
* Removed (not deprecated) zctx_hwm (). We now have separate HWMs for
|
54
|
+
normal socket SND and RCV, and for inter-thread pipes. There is no
|
55
|
+
need to provide accessor methods for these.
|
56
|
+
|
57
|
+
New API methods to simplify common messaging tasks:
|
58
|
+
|
59
|
+
* Added zpoller class to provide new minimalist interface to zmq_poll.
|
60
|
+
This class makes it very simple to read off a set of sockets, which
|
61
|
+
is an 80% usecase.
|
62
|
+
|
63
|
+
* Added zstr_sendx () to send multiple strings in one call. Inspired
|
64
|
+
by PyZMQ's multipart send method.
|
65
|
+
|
66
|
+
* Added zstr_recvx () to receive multiple strings in one call. We do
|
67
|
+
a lot of multipart string reads; this makes it simpler for simple
|
68
|
+
cases.
|
69
|
+
|
70
|
+
* Added zclock_timestr () to provide date/time as printable string.
|
71
|
+
|
72
|
+
* Added zmsg_append () that nullifies caller's frame reference; this
|
73
|
+
is more consistent with the API style than zmsg_add (), which is
|
74
|
+
deprecated.
|
75
|
+
|
76
|
+
New classes used for security infrastructure:
|
77
|
+
|
78
|
+
* Added zchunk class (from FileMQ), for managing memory blocks.
|
79
|
+
This is a simpler model than zframes, which are optimized for
|
80
|
+
message data.
|
81
|
+
|
82
|
+
* Added zhash_comment () to add comments to a serialized zhash file.
|
83
|
+
|
84
|
+
* Added zhash_refresh () to reload a backing file if modified on disk.
|
85
|
+
|
86
|
+
* Added zconfig_comment () to add comments to saved config file, and
|
87
|
+
added code to save such comments from file when loading it.
|
88
|
+
|
89
|
+
* Moved zfile (char *filename) methods to zsys, to make place for
|
90
|
+
a new zfile class based on the CLASS object model. The old methods
|
91
|
+
are still provided but are deprecated.
|
92
|
+
|
93
|
+
* Added zfile class (from FileMQ), for managing files. This provides
|
94
|
+
a rich file class with metadata and operations. This is a component
|
95
|
+
for directory management (zdir).
|
96
|
+
|
97
|
+
* Added zdir class (from FileMQ), for managing directories. This lets
|
98
|
+
us work with filesystem directories. I wanted this to be able to
|
99
|
+
load certificates for security authentication.
|
100
|
+
|
101
|
+
* The zdir and zfile classes are slightly stripped down from their
|
102
|
+
FileMQ originals; no symbolic links, no directory difference tools.
|
103
|
+
|
104
|
+
* Unfortunately to keep the old zfile_size and zfile_time methods, I
|
105
|
+
had to use zfile_cursize and zfile_modified in the new class. This
|
106
|
+
is a little clumsy.
|
107
|
+
|
108
|
+
* Added zsys_file_modified () to return timestamp for a filename.
|
109
|
+
|
110
|
+
* Added zcert class to work with Curve certificates. A certificate is
|
111
|
+
a public + secret key pair, plus metadata like name, email, etc. and
|
112
|
+
is saved as two files, a public text file and a secret text file.
|
113
|
+
Certificates are stored in ZPL (ZMQ RFC 4) configuration file format.
|
114
|
+
|
115
|
+
* Added zauth class to automate ZAP authenticators. This class does a
|
116
|
+
simple plug and play authentication of clients against certificates
|
117
|
+
stored in the $HOME/.curve directory. This can be extended over time
|
118
|
+
with other designs.
|
119
|
+
|
120
|
+
* Added zcertstore class to work with Curve certificate stores. This is
|
121
|
+
a directory or in-memory store holding a set of certificates.
|
122
|
+
|
123
|
+
* Extended zsockopt generation to allow use of binary keys in CURVE
|
124
|
+
key options (e.g. zsocket_set_curve_secretkey_bin ()).
|
125
|
+
|
126
|
+
* Added addons/makecert.c tool to generate CURVE certificates.
|
127
|
+
|
128
|
+
* Added examples/security directory with several examples.
|
129
|
+
|
130
|
+
For full details, see git log.
|
131
|
+
|
132
|
+
|
1
133
|
CZMQ version 1.4.1 (stable), released on 2013/05/01
|
2
134
|
===================================================
|
3
135
|
|
data/ext/czmq/README.md
CHANGED
@@ -4,46 +4,56 @@
|
|
4
4
|
|
5
5
|
[![Build Status](https://travis-ci.org/zeromq/czmq.png?branch=master)](https://travis-ci.org/zeromq/czmq)
|
6
6
|
|
7
|
-
<A name="toc2-
|
7
|
+
<A name="toc2-8" title="Contents" />
|
8
8
|
## Contents
|
9
9
|
|
10
10
|
|
11
|
-
**<a href="#toc2-
|
12
|
-
 <a href="#toc3-
|
13
|
-
 <a href="#toc3-
|
14
|
-
 <a href="#toc3-
|
15
|
-
 <a href="#toc3-
|
16
|
-
|
17
|
-
**<a href="#toc2-
|
18
|
-
 <a href="#toc3-
|
19
|
-
 <a href="#toc3-
|
20
|
-
 <a href="#toc3-
|
21
|
-
 <a href="#toc4-
|
22
|
-
 <a href="#toc4-
|
23
|
-
 <a href="#toc4-
|
24
|
-
 <a href="#toc4-
|
25
|
-
 <a href="#toc4-
|
26
|
-
 <a href="#toc4-
|
27
|
-
 <a href="#toc4-
|
28
|
-
 <a href="#toc4-
|
29
|
-
 <a href="#toc4-
|
30
|
-
 <a href="#toc4-
|
31
|
-
 <a href="#toc4-
|
32
|
-
 <a href="#toc4-
|
33
|
-
 <a href="#toc4-
|
34
|
-
|
35
|
-
|
36
|
-
 <a href="#
|
37
|
-
 <a href="#
|
38
|
-
 <a href="#
|
39
|
-
 <a href="#
|
40
|
-
 <a href="#
|
41
|
-
 <a href="#
|
42
|
-
|
43
|
-
|
11
|
+
**<a href="#toc2-13">Overview</a>**
|
12
|
+
 <a href="#toc3-16">Scope and Goals</a>
|
13
|
+
 <a href="#toc3-57">Ownership and License</a>
|
14
|
+
 <a href="#toc3-62">Commercial Support</a>
|
15
|
+
 <a href="#toc3-67">Contributing</a>
|
16
|
+
|
17
|
+
**<a href="#toc2-76">Using CZMQ</a>**
|
18
|
+
 <a href="#toc3-79">Building and Installing</a>
|
19
|
+
 <a href="#toc3-123">Linking with an Application</a>
|
20
|
+
 <a href="#toc3-130">API Summary</a>
|
21
|
+
 <a href="#toc4-133">zauth - authentication for ZeroMQ security mechanisms</a>
|
22
|
+
 <a href="#toc4-144">zbeacon - LAN service announcement and discovery</a>
|
23
|
+
 <a href="#toc4-155">zcert - work with CURVE security certificates</a>
|
24
|
+
 <a href="#toc4-166">zcertstore - work with CURVE security certificate stores</a>
|
25
|
+
 <a href="#toc4-177">zchunk - work with memory chunks</a>
|
26
|
+
 <a href="#toc4-188">zclock - millisecond clocks and delays</a>
|
27
|
+
 <a href="#toc4-199">zconfig - work with config files written in rfc.zeromq.org/spec:4/ZPL.</a>
|
28
|
+
 <a href="#toc4-210">zctx - working with ØMQ contexts</a>
|
29
|
+
 <a href="#toc4-221">zdir - work with file-system directories</a>
|
30
|
+
 <a href="#toc4-232">zfile - work with files</a>
|
31
|
+
 <a href="#toc4-243">zframe - working with single message frames</a>
|
32
|
+
 <a href="#toc4-254">zhash - generic hash table container</a>
|
33
|
+
 <a href="#toc4-265">zlist - generic list container</a>
|
34
|
+
 <a href="#toc4-276">zloop - event-driven reactor</a>
|
35
|
+
 <a href="#toc4-287">zmsg - working with multipart messages</a>
|
36
|
+
 <a href="#toc4-298">zmutex - wrap lightweight mutexes</a>
|
37
|
+
 <a href="#toc4-309">zpoller - trivial socket poller class</a>
|
38
|
+
 <a href="#toc4-320">zsocket - working with ØMQ sockets</a>
|
39
|
+
 <a href="#toc4-331">zsockopt - working with ØMQ socket options</a>
|
40
|
+
 <a href="#toc4-342">zstr - sending and receiving strings</a>
|
41
|
+
 <a href="#toc4-367">zsys - system-level methods</a>
|
42
|
+
 <a href="#toc4-378">zthread - working with system threads</a>
|
43
|
+
 <a href="#toc4-389">ztree - generic red-black tree container</a>
|
44
|
+
|
45
|
+
**<a href="#toc2-400">Under the Hood</a>**
|
46
|
+
 <a href="#toc3-403">Adding a New Class</a>
|
47
|
+
 <a href="#toc3-415">Documentation</a>
|
48
|
+
 <a href="#toc3-454">Development</a>
|
49
|
+
 <a href="#toc3-464">Porting CZMQ</a>
|
50
|
+
 <a href="#toc3-475">Code Generation</a>
|
51
|
+
 <a href="#toc3-480">This Document</a>
|
52
|
+
|
53
|
+
<A name="toc2-13" title="Overview" />
|
44
54
|
## Overview
|
45
55
|
|
46
|
-
<A name="toc3-
|
56
|
+
<A name="toc3-16" title="Scope and Goals" />
|
47
57
|
### Scope and Goals
|
48
58
|
|
49
59
|
CZMQ has these goals:
|
@@ -51,6 +61,8 @@ CZMQ has these goals:
|
|
51
61
|
* To wrap the ØMQ core API in semantics that are natural and lead to shorter, more readable applications.
|
52
62
|
* To hide the differences between versions of ØMQ, particularly 2.x and 3.x.
|
53
63
|
* To provide a space for development of more sophisticated API semantics.
|
64
|
+
* To wrap the ØMQ security features with high-level tools and APIs.
|
65
|
+
* To become the basis for other language bindings built on top of CZMQ.
|
54
66
|
|
55
67
|
CZMQ grew out of concepts developed in [ØMQ - The Guide](http://zguide.zeromq.org).
|
56
68
|
|
@@ -58,27 +70,17 @@ CZMQ grew out of concepts developed in [ØMQ - The Guide](http://zguide.zeromq.o
|
|
58
70
|
<img src="https://github.com/zeromq/czmq/raw/master/images/README_1.png" alt="1">
|
59
71
|
</center>
|
60
72
|
|
61
|
-
<A name="toc3-
|
62
|
-
### Highlights
|
63
|
-
|
64
|
-
* Single API hides differences between ØMQ/2.x, and ØMQ/3.x.
|
65
|
-
* Work with messages as strings, individual frames, or multipart messages.
|
66
|
-
* Automatic closure of any open sockets at context termination.
|
67
|
-
* Automatic LINGER configuration of all sockets for context termination.
|
68
|
-
* Portable API for creating child threads and ØMQ pipes to talk to them.
|
69
|
-
* Simple reactor with one-off and repeated timers, and socket readers.
|
70
|
-
* System clock functions for sleeping and calculating timers.
|
71
|
-
* Easy API to get/set all socket options.
|
72
|
-
* Portable to Linux, UNIX, OS X, Windows (porting is not yet complete).
|
73
|
-
* Includes generic hash and list containers.
|
74
|
-
* Full self tests on all classes.
|
75
|
-
|
76
|
-
<A name="toc3-68" title="Ownership and License" />
|
73
|
+
<A name="toc3-57" title="Ownership and License" />
|
77
74
|
### Ownership and License
|
78
75
|
|
79
76
|
CZMQ's contributors are listed in the AUTHORS file. It is held by the ZeroMQ organization at github.com. The authors of CZMQ grant you use of this software under the terms of the GNU Lesser General Public License (LGPL). For details see the files `COPYING` and `COPYING.LESSER` in this directory.
|
80
77
|
|
81
|
-
<A name="toc3-
|
78
|
+
<A name="toc3-62" title="Commercial Support" />
|
79
|
+
### Commercial Support
|
80
|
+
|
81
|
+
CZMQ is actively developed and maintained by iMatix Corporation, who provide support to commercial users that need it. Contact Pieter Hintjens vai ph@imatix.com for more information. Note that CZMQ is licensed exclusively under the same LGPLv3 + static link exception as libzmq. This lets you use CZMQ freely in any application, with the requirement that you publish patches to the code.
|
82
|
+
|
83
|
+
<A name="toc3-67" title="Contributing" />
|
82
84
|
### Contributing
|
83
85
|
|
84
86
|
CZMQ uses the [C4.1 (Collective Code Construction Contract)](http://rfc.zeromq.org/spec:22) process for contributions.
|
@@ -87,41 +89,450 @@ CZMQ uses the [CLASS (C Language Style for Scalabilty)](http://rfc.zeromq.org/sp
|
|
87
89
|
|
88
90
|
To report an issue, use the [CZMQ issue tracker](https://github.com/zeromq/czmq/issues) at github.com.
|
89
91
|
|
90
|
-
<A name="toc2-
|
92
|
+
<A name="toc2-76" title="Using CZMQ" />
|
91
93
|
## Using CZMQ
|
92
94
|
|
93
|
-
<A name="toc3-
|
95
|
+
<A name="toc3-79" title="Building and Installing" />
|
94
96
|
### Building and Installing
|
95
97
|
|
96
|
-
|
98
|
+
Here's how to build CZMQ from GitHub (building from packages is very similar, you don't clone a repo but unpack a tarball), including the libsodium (for security) and libzmq (ZeroMQ core) libraries:
|
99
|
+
|
100
|
+
git clone git://github.com/jedisct1/libsodium.git
|
101
|
+
cd libsodium
|
102
|
+
./autogen.sh
|
103
|
+
./configure && make check
|
104
|
+
sudo make install
|
105
|
+
sudo ldconfig
|
106
|
+
cd ..
|
107
|
+
|
108
|
+
git clone git://github.com/zeromq/libzmq.git
|
109
|
+
cd libzmq
|
110
|
+
./autogen.sh
|
111
|
+
./configure && make check
|
112
|
+
sudo make install
|
113
|
+
sudo ldconfig
|
114
|
+
cd ..
|
97
115
|
|
98
116
|
git clone git://github.com/zeromq/czmq.git
|
99
117
|
cd czmq
|
100
|
-
|
101
|
-
./configure
|
102
|
-
make all
|
118
|
+
./autogen.sh
|
119
|
+
./configure && make check
|
103
120
|
sudo make install
|
104
121
|
sudo ldconfig
|
122
|
+
cd ..
|
123
|
+
|
124
|
+
In general CZMQ works best with the latest libzmq master. If you already have an older version of libzmq installed on your system, e.g. in /usr/, then you can install libzmq master to your home directory ($HOME/local):
|
105
125
|
|
106
|
-
|
126
|
+
# Building libzmq in our home directory
|
127
|
+
./configure --prefix=$HOME/local
|
107
128
|
|
108
|
-
|
129
|
+
And then to build CZMQ against this installation of libzmq:
|
109
130
|
|
110
|
-
|
131
|
+
export CFLAGS=-I$HOME/local/include
|
132
|
+
export LDFLAGS=-L$HOME/local/lib64
|
133
|
+
./configure
|
134
|
+
|
135
|
+
You will need the libtool and autotools packages. After building, run the CZMQ selftests:
|
111
136
|
|
112
137
|
make check
|
113
138
|
|
114
|
-
<A name="toc3-
|
139
|
+
<A name="toc3-123" title="Linking with an Application" />
|
115
140
|
### Linking with an Application
|
116
141
|
|
117
142
|
Include `czmq.h` in your application and link with libczmq. Here is a typical gcc link command:
|
118
143
|
|
119
144
|
gcc -lczmq -lzmq myapp.c -o myapp
|
120
145
|
|
121
|
-
<A name="toc3-
|
146
|
+
<A name="toc3-130" title="API Summary" />
|
122
147
|
### API Summary
|
123
148
|
|
124
|
-
<A name="toc4-
|
149
|
+
<A name="toc4-133" title="zauth - authentication for ZeroMQ security mechanisms" />
|
150
|
+
#### zauth - authentication for ZeroMQ security mechanisms
|
151
|
+
|
152
|
+
A zauth object takes over authentication for all incoming connections in
|
153
|
+
its context. Note that libzmq provides four levels of security: default
|
154
|
+
NULL (which zauth does not see), and authenticated NULL, PLAIN, and CURVE,
|
155
|
+
which zauth can see.
|
156
|
+
|
157
|
+
This is the class interface:
|
158
|
+
|
159
|
+
#define CURVE_ALLOW_ANY "*"
|
160
|
+
|
161
|
+
// Constructor
|
162
|
+
// Install authentication for the specified context. Returns a new zauth
|
163
|
+
// object that you can use to configure authentication. Note that until you
|
164
|
+
// add policies, all incoming NULL connections are allowed (classic ZeroMQ
|
165
|
+
// behaviour), and all PLAIN and CURVE connections are denied. If there was
|
166
|
+
// an error during initialization, returns NULL.
|
167
|
+
CZMQ_EXPORT zauth_t *
|
168
|
+
zauth_new (zctx_t *ctx);
|
169
|
+
|
170
|
+
// Allow (whitelist) a single IP address. For NULL, all clients from this
|
171
|
+
// address will be accepted. For PLAIN and CURVE, they will be allowed to
|
172
|
+
// continue with authentication. You can call this method multiple times
|
173
|
+
// to whitelist multiple IP addresses. If you whitelist a single address,
|
174
|
+
// any non-whitelisted addresses are treated as blacklisted.
|
175
|
+
CZMQ_EXPORT void
|
176
|
+
zauth_allow (zauth_t *self, char *address);
|
177
|
+
|
178
|
+
// Deny (blacklist) a single IP address. For all security mechanisms, this
|
179
|
+
// rejects the connection without any further authentication. Use either a
|
180
|
+
// whitelist, or a blacklist, not not both. If you define both a whitelist
|
181
|
+
// and a blacklist, only the whitelist takes effect.
|
182
|
+
CZMQ_EXPORT void
|
183
|
+
zauth_deny (zauth_t *self, char *address);
|
184
|
+
|
185
|
+
// Configure PLAIN authentication for a given domain. PLAIN authentication
|
186
|
+
// uses a plain-text password file. The filename is treated as a printf
|
187
|
+
// format. To cover all domains, use "*". You can modify the password file
|
188
|
+
// at any time; it is reloaded automatically.
|
189
|
+
CZMQ_EXPORT void
|
190
|
+
zauth_configure_plain (zauth_t *self, char *domain, char *filename, ...);
|
191
|
+
|
192
|
+
// Configure CURVE authentication for a given domain. CURVE authentication
|
193
|
+
// uses a directory that holds all public client certificates, i.e. their
|
194
|
+
// public keys. The certificates must be in zcert_save () format. The
|
195
|
+
// location is treated as a printf format. To cover all domains, use "*".
|
196
|
+
// You can add and remove certificates in that directory at any time.
|
197
|
+
// To allow all client keys without checking, specify CURVE_ALLOW_ANY
|
198
|
+
// for the location.
|
199
|
+
CZMQ_EXPORT void
|
200
|
+
zauth_configure_curve (zauth_t *self, char *domain, char *location, ...);
|
201
|
+
|
202
|
+
// Enable verbose tracing of commands and activity
|
203
|
+
CZMQ_EXPORT void
|
204
|
+
zauth_set_verbose (zauth_t *self, bool verbose);
|
205
|
+
|
206
|
+
// Destructor
|
207
|
+
CZMQ_EXPORT void
|
208
|
+
zauth_destroy (zauth_t **self_p);
|
209
|
+
|
210
|
+
// Selftest
|
211
|
+
CZMQ_EXPORT int
|
212
|
+
zauth_test (bool verbose);
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
<A name="toc4-144" title="zbeacon - LAN service announcement and discovery" />
|
217
|
+
#### zbeacon - LAN service announcement and discovery
|
218
|
+
|
219
|
+
The zbeacon class implements a peer-to-peer discovery service for local
|
220
|
+
networks. A beacon can broadcast and/or capture service announcements
|
221
|
+
using UDP messages on the local area network. This implementation uses
|
222
|
+
IPv4 UDP broadcasts. You can define the format of your outgoing beacons,
|
223
|
+
and set a filter that validates incoming beacons. Beacons are sent and
|
224
|
+
received asynchronously in the background. The zbeacon API provides a
|
225
|
+
incoming beacons on a ZeroMQ socket (the pipe) that you can configure,
|
226
|
+
poll on, and receive messages on. Incoming beacons are always delivered
|
227
|
+
as two frames: the ipaddress of the sender (a string), and the beacon
|
228
|
+
data itself (binary, as published).
|
229
|
+
|
230
|
+
This is the class interface:
|
231
|
+
|
232
|
+
// Create a new beacon on a certain UDP port
|
233
|
+
CZMQ_EXPORT zbeacon_t *
|
234
|
+
zbeacon_new (int port_nbr);
|
235
|
+
|
236
|
+
// Destroy a beacon
|
237
|
+
CZMQ_EXPORT void
|
238
|
+
zbeacon_destroy (zbeacon_t **self_p);
|
239
|
+
|
240
|
+
// Return our own IP address as printable string
|
241
|
+
CZMQ_EXPORT char *
|
242
|
+
zbeacon_hostname (zbeacon_t *self);
|
243
|
+
|
244
|
+
// Set broadcast interval in milliseconds (default is 1000 msec)
|
245
|
+
CZMQ_EXPORT void
|
246
|
+
zbeacon_set_interval (zbeacon_t *self, int interval);
|
247
|
+
|
248
|
+
// Filter out any beacon that looks exactly like ours
|
249
|
+
CZMQ_EXPORT void
|
250
|
+
zbeacon_noecho (zbeacon_t *self);
|
251
|
+
|
252
|
+
// Start broadcasting beacon to peers at the specified interval
|
253
|
+
CZMQ_EXPORT void
|
254
|
+
zbeacon_publish (zbeacon_t *self, byte *transmit, size_t size);
|
255
|
+
|
256
|
+
// Stop broadcasting beacons
|
257
|
+
CZMQ_EXPORT void
|
258
|
+
zbeacon_silence (zbeacon_t *self);
|
259
|
+
|
260
|
+
// Start listening to other peers; zero-sized filter means get everything
|
261
|
+
CZMQ_EXPORT void
|
262
|
+
zbeacon_subscribe (zbeacon_t *self, byte *filter, size_t size);
|
263
|
+
|
264
|
+
// Stop listening to other peers
|
265
|
+
CZMQ_EXPORT void
|
266
|
+
zbeacon_unsubscribe (zbeacon_t *self);
|
267
|
+
|
268
|
+
// Get beacon ZeroMQ socket, for polling or receiving messages
|
269
|
+
CZMQ_EXPORT void *
|
270
|
+
zbeacon_socket (zbeacon_t *self);
|
271
|
+
|
272
|
+
// Self test of this class
|
273
|
+
CZMQ_EXPORT void
|
274
|
+
zbeacon_test (bool verbose);
|
275
|
+
|
276
|
+
|
277
|
+
<A name="toc4-155" title="zcert - work with CURVE security certificates" />
|
278
|
+
#### zcert - work with CURVE security certificates
|
279
|
+
|
280
|
+
The zcert class provides a way to create and work with security
|
281
|
+
certificates for the ZMQ CURVE mechanism. A certificate contains a
|
282
|
+
public + secret key pair, plus metadata. It can be used as a
|
283
|
+
temporary object in memory, or persisted to disk. On disk, a
|
284
|
+
certificate is stored as two files. One is public and contains only
|
285
|
+
the public key. The second is secret and contains both keys. The
|
286
|
+
two have the same filename, with the secret file adding "_secret".
|
287
|
+
To exchange certificates, send the public file via some secure route.
|
288
|
+
Certificates are not signed but are text files that can be verified by
|
289
|
+
eye.
|
290
|
+
|
291
|
+
This is the class interface:
|
292
|
+
|
293
|
+
|
294
|
+
// Create and initialize a new certificate in memory
|
295
|
+
CZMQ_EXPORT zcert_t *
|
296
|
+
zcert_new (void);
|
297
|
+
|
298
|
+
// Constructor, accepts public/secret key pair from caller
|
299
|
+
CZMQ_EXPORT zcert_t *
|
300
|
+
zcert_new_from (byte *public_key, byte *secret_key);
|
301
|
+
|
302
|
+
// Destroy a certificate in memory
|
303
|
+
CZMQ_EXPORT void
|
304
|
+
zcert_destroy (zcert_t **self_p);
|
305
|
+
|
306
|
+
// Return public part of key pair as 32-byte binary string
|
307
|
+
CZMQ_EXPORT byte *
|
308
|
+
zcert_public_key (zcert_t *self);
|
309
|
+
|
310
|
+
// Return secret part of key pair as 32-byte binary string
|
311
|
+
CZMQ_EXPORT byte *
|
312
|
+
zcert_secret_key (zcert_t *self);
|
313
|
+
|
314
|
+
// Return public part of key pair as Z85 armored string
|
315
|
+
CZMQ_EXPORT char *
|
316
|
+
zcert_public_txt (zcert_t *self);
|
317
|
+
|
318
|
+
// Return secret part of key pair as Z85 armored string
|
319
|
+
CZMQ_EXPORT char *
|
320
|
+
zcert_secret_txt (zcert_t *self);
|
321
|
+
|
322
|
+
// Set certificate metadata from formatted string.
|
323
|
+
CZMQ_EXPORT void
|
324
|
+
zcert_set_meta (zcert_t *self, char *name, char *format, ...);
|
325
|
+
|
326
|
+
// Get metadata value from certificate; if the metadata value doesn't
|
327
|
+
// exist, returns NULL.
|
328
|
+
CZMQ_EXPORT char *
|
329
|
+
zcert_meta (zcert_t *self, char *name);
|
330
|
+
|
331
|
+
// Load certificate from file (constructor)
|
332
|
+
// The filename is treated as a printf format specifier.
|
333
|
+
CZMQ_EXPORT zcert_t *
|
334
|
+
zcert_load (char *filename, ...);
|
335
|
+
|
336
|
+
// Save full certificate (public + secret) to file for persistent storage
|
337
|
+
// This creates one public file and one secret file (filename + "_secret").
|
338
|
+
// The filename is treated as a printf format specifier.
|
339
|
+
CZMQ_EXPORT int
|
340
|
+
zcert_save (zcert_t *self, char *filename, ...);
|
341
|
+
|
342
|
+
// Save public certificate only to file for persistent storage
|
343
|
+
// The filename is treated as a printf format specifier.
|
344
|
+
CZMQ_EXPORT int
|
345
|
+
zcert_save_public (zcert_t *self, char *filename, ...);
|
346
|
+
|
347
|
+
// Apply certificate to socket, i.e. use for CURVE security on socket.
|
348
|
+
// If certificate was loaded from public file, the secret key will be
|
349
|
+
// undefined, and this certificate will not work successfully.
|
350
|
+
CZMQ_EXPORT void
|
351
|
+
zcert_apply (zcert_t *self, void *zocket);
|
352
|
+
|
353
|
+
// Return copy of certificate
|
354
|
+
CZMQ_EXPORT zcert_t *
|
355
|
+
zcert_dup (zcert_t *self);
|
356
|
+
|
357
|
+
// Return true if two certificates have the same keys
|
358
|
+
CZMQ_EXPORT bool
|
359
|
+
zcert_eq (zcert_t *self, zcert_t *compare);
|
360
|
+
|
361
|
+
// Dump certificate contents to stderr for debugging
|
362
|
+
CZMQ_EXPORT void
|
363
|
+
zcert_dump (zcert_t *self);
|
364
|
+
|
365
|
+
// Self test of this class
|
366
|
+
CZMQ_EXPORT int
|
367
|
+
zcert_test (bool verbose);
|
368
|
+
|
369
|
+
Certificates are stored in the ZPL (ZMQ RFC 4) format. They have two
|
370
|
+
sections, "metadata" and "curve". The first contains a list of 'name =
|
371
|
+
value' pairs, one per line. Values may be enclosed in quotes. The curve
|
372
|
+
section has a 'public-key = keyvalue' and, for secret certificates, a
|
373
|
+
'secret-key = keyvalue' line. The keyvalue is a Z85-encoded CURVE key.
|
374
|
+
|
375
|
+
<A name="toc4-166" title="zcertstore - work with CURVE security certificate stores" />
|
376
|
+
#### zcertstore - work with CURVE security certificate stores
|
377
|
+
|
378
|
+
To authenticate new clients using the ZeroMQ CURVE security mechanism,
|
379
|
+
we have to check that the client's public key matches a key we know and
|
380
|
+
accept. There are numerous ways to store accepted client public keys.
|
381
|
+
The mechanism CZMQ implements is "certificates" (plain text files) held
|
382
|
+
in a "certificate store" (a disk directory). This class works with such
|
383
|
+
certificate stores, and lets you easily load them from disk, and check
|
384
|
+
if a given client public key is known or not. The zcert class does the
|
385
|
+
work of managing a single certificate.
|
386
|
+
|
387
|
+
This is the class interface:
|
388
|
+
|
389
|
+
|
390
|
+
// Create a new certificate store from a disk directory, loading and
|
391
|
+
// indexing all certificates in that location. The directory itself may be
|
392
|
+
// absent, and created later, or modified at any time. The certificate store
|
393
|
+
// is automatically refreshed on any zcertstore_lookup() call. If the
|
394
|
+
// location is specified as NULL, creates a pure-memory store, which you
|
395
|
+
// can work with by inserting certificates at runtime. The location is
|
396
|
+
// treated as a printf format.
|
397
|
+
CZMQ_EXPORT zcertstore_t *
|
398
|
+
zcertstore_new (char *location, ...);
|
399
|
+
|
400
|
+
// Destroy a certificate store object in memory. Does not affect anything
|
401
|
+
// stored on disk.
|
402
|
+
CZMQ_EXPORT void
|
403
|
+
zcertstore_destroy (zcertstore_t **self_p);
|
404
|
+
|
405
|
+
// Look up certificate by public key, returns zcert_t object if found,
|
406
|
+
// else returns NULL. The public key is provided in Z85 text format.
|
407
|
+
CZMQ_EXPORT zcert_t *
|
408
|
+
zcertstore_lookup (zcertstore_t *self, char *public_key);
|
409
|
+
|
410
|
+
// Insert certificate into certificate store in memory. Note that this
|
411
|
+
// does not save the certificate to disk. To do that, use zcert_save()
|
412
|
+
// directly on the certificate. Takes ownership of zcert_t object.
|
413
|
+
CZMQ_EXPORT void
|
414
|
+
zcertstore_insert (zcertstore_t *self, zcert_t **cert_p);
|
415
|
+
|
416
|
+
// Print out list of certificates in store to stdout, for debugging
|
417
|
+
// purposes.
|
418
|
+
CZMQ_EXPORT void
|
419
|
+
zcertstore_dump (zcertstore_t *self);
|
420
|
+
|
421
|
+
// Self test of this class
|
422
|
+
CZMQ_EXPORT int
|
423
|
+
zcertstore_test (bool verbose);
|
424
|
+
|
425
|
+
The certificate store can be memory-only, in which case you can load it
|
426
|
+
yourself by inserting certificate objects one by one, or it can be loaded
|
427
|
+
from disk, in which case you can add, modify, or remove certificates on
|
428
|
+
disk at any time, and the store will detect such changes and refresh
|
429
|
+
itself automatically. In most applications you won't use this class
|
430
|
+
directly but through the zauth class, which provides a high-level API for
|
431
|
+
authentication (and manages certificate stores for you). To actually
|
432
|
+
create certificates on disk, use the zcert class in code, or the
|
433
|
+
tools/makecert.c command line tool, or any text editor. The format of a
|
434
|
+
certificate file is defined in the zcert man page.
|
435
|
+
|
436
|
+
<A name="toc4-177" title="zchunk - work with memory chunks" />
|
437
|
+
#### zchunk - work with memory chunks
|
438
|
+
|
439
|
+
The zchunk class works with variable sized blobs. Not as efficient as
|
440
|
+
ØMQ's messages but they do less weirdness and so are easier to understand.
|
441
|
+
The chunk class has methods to read and write chunks from disk.
|
442
|
+
|
443
|
+
This is the class interface:
|
444
|
+
|
445
|
+
// Create new chunk
|
446
|
+
CZMQ_EXPORT zchunk_t *
|
447
|
+
zchunk_new (const void *data, size_t size);
|
448
|
+
|
449
|
+
// Destroy a chunk
|
450
|
+
CZMQ_EXPORT void
|
451
|
+
zchunk_destroy (zchunk_t **self_p);
|
452
|
+
|
453
|
+
// Resizes chunk max_size as requested; chunk_cur size is set to zero
|
454
|
+
CZMQ_EXPORT void
|
455
|
+
zchunk_resize (zchunk_t *self, size_t size);
|
456
|
+
|
457
|
+
// Return chunk cur size
|
458
|
+
CZMQ_EXPORT size_t
|
459
|
+
zchunk_size (zchunk_t *self);
|
460
|
+
|
461
|
+
// Return chunk max size
|
462
|
+
CZMQ_EXPORT size_t
|
463
|
+
zchunk_max_size (zchunk_t *self);
|
464
|
+
|
465
|
+
// Return chunk data
|
466
|
+
CZMQ_EXPORT byte *
|
467
|
+
zchunk_data (zchunk_t *self);
|
468
|
+
|
469
|
+
// Set chunk data from user-supplied data; truncate if too large
|
470
|
+
CZMQ_EXPORT size_t
|
471
|
+
zchunk_set (zchunk_t *self, const void *data, size_t size);
|
472
|
+
|
473
|
+
// Fill chunk data from user-supplied octet
|
474
|
+
CZMQ_EXPORT size_t
|
475
|
+
zchunk_fill (zchunk_t *self, byte filler, size_t size);
|
476
|
+
|
477
|
+
// Read chunk from an open file descriptor
|
478
|
+
CZMQ_EXPORT zchunk_t *
|
479
|
+
zchunk_read (FILE *handle, size_t bytes);
|
480
|
+
|
481
|
+
// Write chunk to an open file descriptor
|
482
|
+
CZMQ_EXPORT int
|
483
|
+
zchunk_write (zchunk_t *self, FILE *handle);
|
484
|
+
|
485
|
+
// Self test of this class
|
486
|
+
CZMQ_EXPORT int
|
487
|
+
zchunk_test (bool verbose);
|
488
|
+
|
489
|
+
|
490
|
+
<A name="toc4-188" title="zclock - millisecond clocks and delays" />
|
491
|
+
#### zclock - millisecond clocks and delays
|
492
|
+
|
493
|
+
The zclock class provides essential sleep and system time functions, used
|
494
|
+
to slow down threads for testing, and calculate timers for polling. Wraps
|
495
|
+
the non-portable system calls in a simple portable API.
|
496
|
+
|
497
|
+
This is the class interface:
|
498
|
+
|
499
|
+
// Sleep for a number of milliseconds
|
500
|
+
CZMQ_EXPORT void
|
501
|
+
zclock_sleep (int msecs);
|
502
|
+
|
503
|
+
// Return current system clock as milliseconds
|
504
|
+
CZMQ_EXPORT int64_t
|
505
|
+
zclock_time (void);
|
506
|
+
|
507
|
+
// Print formatted string to stdout, prefixed by date/time and
|
508
|
+
// terminated with a newline.
|
509
|
+
CZMQ_EXPORT void
|
510
|
+
zclock_log (const char *format, ...);
|
511
|
+
|
512
|
+
// Return formatted date/time as fresh string.
|
513
|
+
CZMQ_EXPORT char *
|
514
|
+
zclock_timestr (void);
|
515
|
+
|
516
|
+
// Self test of this class
|
517
|
+
CZMQ_EXPORT int
|
518
|
+
zclock_test (bool verbose);
|
519
|
+
|
520
|
+
The Win32 Sleep() call defaults to 16ms resolution unless the system timer
|
521
|
+
resolution is increased with a call to timeBeginPeriod() permitting 1ms
|
522
|
+
granularity.
|
523
|
+
|
524
|
+
<A name="toc4-199" title="zconfig - work with config files written in rfc.zeromq.org/spec:4/ZPL." />
|
525
|
+
#### zconfig - work with config files written in rfc.zeromq.org/spec:4/ZPL.
|
526
|
+
|
527
|
+
Lets applications load, work with, and save configuration files.
|
528
|
+
This implements rfc.zeromq.org/spec:4/ZPL, which is a simple structured
|
529
|
+
text format for configuration files.
|
530
|
+
|
531
|
+
This is the class interface:
|
532
|
+
|
533
|
+
|
534
|
+
|
535
|
+
<A name="toc4-210" title="zctx - working with ØMQ contexts" />
|
125
536
|
#### zctx - working with ØMQ contexts
|
126
537
|
|
127
538
|
The zctx class wraps ØMQ contexts. It manages open sockets in the context
|
@@ -160,20 +571,39 @@ This is the class interface:
|
|
160
571
|
zctx_destroy (zctx_t **self_p);
|
161
572
|
|
162
573
|
// Raise default I/O threads from 1, for crazy heavy applications
|
574
|
+
// The rule of thumb is one I/O thread per gigabyte of traffic in
|
575
|
+
// or out. Call this method before creating any sockets on the context
|
576
|
+
// or the setting will have no effect.
|
163
577
|
CZMQ_EXPORT void
|
164
578
|
zctx_set_iothreads (zctx_t *self, int iothreads);
|
165
579
|
|
166
|
-
// Set msecs to flush sockets when closing them
|
580
|
+
// Set msecs to flush sockets when closing them, see the ZMQ_LINGER
|
581
|
+
// man page section for more details. By default, set to zero, so
|
582
|
+
// any in-transit messages are discarded when you destroy a socket or
|
583
|
+
// a context.
|
167
584
|
CZMQ_EXPORT void
|
168
585
|
zctx_set_linger (zctx_t *self, int linger);
|
169
586
|
|
170
|
-
// Set
|
587
|
+
// Set initial high-water mark for inter-thread pipe sockets. Note that
|
588
|
+
// this setting is separate from the default for normal sockets. You
|
589
|
+
// should change the default for pipe sockets *with care*. Too low values
|
590
|
+
// will cause blocked threads, and an infinite setting can cause memory
|
591
|
+
// exhaustion. The default, no matter the underlying ZeroMQ version, is
|
592
|
+
// 1,000.
|
171
593
|
CZMQ_EXPORT void
|
172
|
-
|
173
|
-
|
174
|
-
//
|
175
|
-
|
176
|
-
|
594
|
+
zctx_set_pipehwm (zctx_t *self, int pipehwm);
|
595
|
+
|
596
|
+
// Set initial send HWM for all new normal sockets created in context.
|
597
|
+
// You can set this per-socket after the socket is created.
|
598
|
+
// The default, no matter the underlying ZeroMQ version, is 1,000.
|
599
|
+
CZMQ_EXPORT void
|
600
|
+
zctx_set_sndhwm (zctx_t *self, int sndhwm);
|
601
|
+
|
602
|
+
// Set initial receive HWM for all new normal sockets created in context.
|
603
|
+
// You can set this per-socket after the socket is created.
|
604
|
+
// The default, no matter the underlying ZeroMQ version, is 1,000.
|
605
|
+
CZMQ_EXPORT void
|
606
|
+
zctx_set_rcvhwm (zctx_t *self, int rcvhwm);
|
177
607
|
|
178
608
|
// Return low-level ØMQ context object, will be NULL before first socket
|
179
609
|
// is created. Use with care.
|
@@ -181,7 +611,7 @@ This is the class interface:
|
|
181
611
|
zctx_underlying (zctx_t *self);
|
182
612
|
|
183
613
|
// Self test of this class
|
184
|
-
int
|
614
|
+
CZMQ_EXPORT int
|
185
615
|
zctx_test (bool verbose);
|
186
616
|
|
187
617
|
// Global signal indicator, TRUE when user presses Ctrl-C or the process
|
@@ -189,263 +619,174 @@ This is the class interface:
|
|
189
619
|
CZMQ_EXPORT extern volatile int zctx_interrupted;
|
190
620
|
|
191
621
|
|
192
|
-
<A name="toc4-
|
193
|
-
####
|
622
|
+
<A name="toc4-221" title="zdir - work with file-system directories" />
|
623
|
+
#### zdir - work with file-system directories
|
194
624
|
|
195
|
-
The
|
196
|
-
|
197
|
-
|
625
|
+
The zdir class gives access to the file system index. It will load
|
626
|
+
a directory tree (a directory plus all child directories) into a
|
627
|
+
zdir structure and then let you navigate that structure. It exists
|
628
|
+
mainly to wrap non-portable OS functions to do this.
|
198
629
|
|
199
630
|
This is the class interface:
|
200
631
|
|
201
|
-
//
|
202
|
-
//
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
// Create a new socket within our CZMQ context, replaces zmq_socket.
|
207
|
-
// Use this to get automatic management of the socket at shutdown.
|
208
|
-
// Note: SUB sockets do not automatically subscribe to everything; you
|
209
|
-
// must set filters explicitly.
|
210
|
-
CZMQ_EXPORT void *
|
211
|
-
zsocket_new (zctx_t *self, int type);
|
632
|
+
// Create a new directory item that loads in the full tree of the
|
633
|
+
// specified path, optionally located under some parent path.
|
634
|
+
CZMQ_EXPORT zdir_t *
|
635
|
+
zdir_new (const char *path, const char *parent);
|
212
636
|
|
213
|
-
// Destroy a
|
637
|
+
// Destroy a directory tree and all children it contains.
|
214
638
|
CZMQ_EXPORT void
|
215
|
-
|
216
|
-
|
217
|
-
// Bind a socket to a formatted endpoint. If the port is specified as
|
218
|
-
// '*', binds to any free port from ZSOCKET_DYNFROM to ZSOCKET_DYNTO
|
219
|
-
// and returns the actual port number used. Otherwise asserts that the
|
220
|
-
// bind succeeded with the specified port number. Always returns the
|
221
|
-
// port number if successful.
|
222
|
-
CZMQ_EXPORT int
|
223
|
-
zsocket_bind (void *socket, const char *format, ...);
|
224
|
-
|
225
|
-
// Connect a socket to a formatted endpoint
|
226
|
-
// Returns 0 if OK, -1 if the endpoint was invalid.
|
227
|
-
CZMQ_EXPORT int
|
228
|
-
zsocket_connect (void *socket, const char *format, ...);
|
229
|
-
|
230
|
-
// Disonnect a socket from a formatted endpoint
|
231
|
-
// Returns 0 if OK, -1 if the endpoint was invalid or the function
|
232
|
-
// isn't supported.
|
233
|
-
CZMQ_EXPORT int
|
234
|
-
zsocket_disconnect (void *socket, const char *format, ...);
|
639
|
+
zdir_destroy (zdir_t **self_p);
|
235
640
|
|
236
|
-
//
|
237
|
-
// ready on the socket, else FALSE.
|
238
|
-
CZMQ_EXPORT bool
|
239
|
-
zsocket_poll (void *socket, int msecs);
|
240
|
-
|
241
|
-
// Returns socket type as printable constant string
|
641
|
+
// Return directory path
|
242
642
|
CZMQ_EXPORT char *
|
243
|
-
|
643
|
+
zdir_path (zdir_t *self);
|
644
|
+
|
645
|
+
// Return last modification time for directory.
|
646
|
+
CZMQ_EXPORT time_t
|
647
|
+
zdir_modified (zdir_t *self);
|
648
|
+
|
649
|
+
// Return total hierarchy size, in bytes of data contained in all files
|
650
|
+
// in the directory tree.
|
651
|
+
CZMQ_EXPORT off_t
|
652
|
+
zdir_cursize (zdir_t *self);
|
653
|
+
|
654
|
+
// Returns a sorted array of zfile objects; returns a single block of memory,
|
655
|
+
// that you destroy by calling free(). Each entry in the array is a pointer
|
656
|
+
// to a zfile_t item already allocated in the zdir tree. The array ends with
|
657
|
+
// a null pointer. Do not destroy the original zdir tree until you are done
|
658
|
+
// with this array.
|
659
|
+
CZMQ_EXPORT zfile_t **
|
660
|
+
zdir_flatten (zdir_t *self);
|
661
|
+
|
662
|
+
// Print contents of directory to stderr
|
663
|
+
CZMQ_EXPORT void
|
664
|
+
zdir_dump (zdir_t *self, int indent);
|
665
|
+
|
666
|
+
// Remove directory, optionally including all files that it contains, at
|
667
|
+
// all levels. If force is false, will only remove the directory if empty.
|
668
|
+
// If force is true, will remove all files and all subdirectories.
|
669
|
+
CZMQ_EXPORT void
|
670
|
+
zdir_remove (zdir_t *self, bool force);
|
244
671
|
|
245
672
|
// Self test of this class
|
246
|
-
int
|
247
|
-
|
673
|
+
CZMQ_EXPORT int
|
674
|
+
zdir_test (bool verbose);
|
248
675
|
|
249
676
|
|
250
|
-
<A name="toc4-
|
251
|
-
####
|
677
|
+
<A name="toc4-232" title="zfile - work with files" />
|
678
|
+
#### zfile - work with files
|
252
679
|
|
253
|
-
The
|
680
|
+
The zfile class provides methods to work with files. This class is a new
|
681
|
+
API, deprecating the old zfile class (which still exists but is implemented
|
682
|
+
in zsys now).
|
254
683
|
|
255
684
|
This is the class interface:
|
256
685
|
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
CZMQ_EXPORT int zsocket_swap (void *zocket);
|
261
|
-
CZMQ_EXPORT int zsocket_affinity (void *zocket);
|
262
|
-
// Returns freshly allocated string, free when done
|
263
|
-
CZMQ_EXPORT char * zsocket_identity (void *zocket);
|
264
|
-
CZMQ_EXPORT int zsocket_rate (void *zocket);
|
265
|
-
CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket);
|
266
|
-
CZMQ_EXPORT int zsocket_recovery_ivl_msec (void *zocket);
|
267
|
-
CZMQ_EXPORT int zsocket_mcast_loop (void *zocket);
|
268
|
-
# if (ZMQ_VERSION_MINOR == 2)
|
269
|
-
CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket);
|
270
|
-
# endif
|
271
|
-
# if (ZMQ_VERSION_MINOR == 2)
|
272
|
-
CZMQ_EXPORT int zsocket_sndtimeo (void *zocket);
|
273
|
-
# endif
|
274
|
-
CZMQ_EXPORT int zsocket_sndbuf (void *zocket);
|
275
|
-
CZMQ_EXPORT int zsocket_rcvbuf (void *zocket);
|
276
|
-
CZMQ_EXPORT int zsocket_linger (void *zocket);
|
277
|
-
CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket);
|
278
|
-
CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket);
|
279
|
-
CZMQ_EXPORT int zsocket_backlog (void *zocket);
|
280
|
-
CZMQ_EXPORT int zsocket_type (void *zocket);
|
281
|
-
CZMQ_EXPORT int zsocket_rcvmore (void *zocket);
|
282
|
-
CZMQ_EXPORT int zsocket_fd (void *zocket);
|
283
|
-
CZMQ_EXPORT int zsocket_events (void *zocket);
|
686
|
+
// Create new file item
|
687
|
+
CZMQ_EXPORT zfile_t *
|
688
|
+
zfile_new (const char *path, const char *name);
|
284
689
|
|
285
|
-
//
|
286
|
-
CZMQ_EXPORT void
|
287
|
-
|
288
|
-
CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity);
|
289
|
-
CZMQ_EXPORT void zsocket_set_identity (void *zocket, char * identity);
|
290
|
-
CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate);
|
291
|
-
CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl);
|
292
|
-
CZMQ_EXPORT void zsocket_set_recovery_ivl_msec (void *zocket, int recovery_ivl_msec);
|
293
|
-
CZMQ_EXPORT void zsocket_set_mcast_loop (void *zocket, int mcast_loop);
|
294
|
-
# if (ZMQ_VERSION_MINOR == 2)
|
295
|
-
CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo);
|
296
|
-
# endif
|
297
|
-
# if (ZMQ_VERSION_MINOR == 2)
|
298
|
-
CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo);
|
299
|
-
# endif
|
300
|
-
CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf);
|
301
|
-
CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf);
|
302
|
-
CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger);
|
303
|
-
CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl);
|
304
|
-
CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max);
|
305
|
-
CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog);
|
306
|
-
CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, char * subscribe);
|
307
|
-
CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, char * unsubscribe);
|
308
|
-
#endif
|
690
|
+
// Destroy a file item
|
691
|
+
CZMQ_EXPORT void
|
692
|
+
zfile_destroy (zfile_t **self_p);
|
309
693
|
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
CZMQ_EXPORT int zsocket_sndhwm (void *zocket);
|
314
|
-
CZMQ_EXPORT int zsocket_rcvhwm (void *zocket);
|
315
|
-
CZMQ_EXPORT int zsocket_affinity (void *zocket);
|
316
|
-
// Returns freshly allocated string, free when done
|
317
|
-
CZMQ_EXPORT char * zsocket_identity (void *zocket);
|
318
|
-
CZMQ_EXPORT int zsocket_rate (void *zocket);
|
319
|
-
CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket);
|
320
|
-
CZMQ_EXPORT int zsocket_sndbuf (void *zocket);
|
321
|
-
CZMQ_EXPORT int zsocket_rcvbuf (void *zocket);
|
322
|
-
CZMQ_EXPORT int zsocket_linger (void *zocket);
|
323
|
-
CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket);
|
324
|
-
CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket);
|
325
|
-
CZMQ_EXPORT int zsocket_backlog (void *zocket);
|
326
|
-
CZMQ_EXPORT int zsocket_maxmsgsize (void *zocket);
|
327
|
-
CZMQ_EXPORT int zsocket_multicast_hops (void *zocket);
|
328
|
-
CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket);
|
329
|
-
CZMQ_EXPORT int zsocket_sndtimeo (void *zocket);
|
330
|
-
CZMQ_EXPORT int zsocket_ipv4only (void *zocket);
|
331
|
-
CZMQ_EXPORT int zsocket_rcvmore (void *zocket);
|
332
|
-
CZMQ_EXPORT int zsocket_fd (void *zocket);
|
333
|
-
CZMQ_EXPORT int zsocket_events (void *zocket);
|
334
|
-
// Returns freshly allocated string, free when done
|
335
|
-
CZMQ_EXPORT char * zsocket_last_endpoint (void *zocket);
|
694
|
+
// Duplicate a file item, returns a newly constructed item
|
695
|
+
CZMQ_EXPORT zfile_t *
|
696
|
+
zfile_dup (zfile_t *self);
|
336
697
|
|
337
|
-
//
|
338
|
-
CZMQ_EXPORT
|
339
|
-
|
340
|
-
CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity);
|
341
|
-
CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, char * subscribe);
|
342
|
-
CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, char * unsubscribe);
|
343
|
-
CZMQ_EXPORT void zsocket_set_identity (void *zocket, char * identity);
|
344
|
-
CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate);
|
345
|
-
CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl);
|
346
|
-
CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf);
|
347
|
-
CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf);
|
348
|
-
CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger);
|
349
|
-
CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl);
|
350
|
-
CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max);
|
351
|
-
CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog);
|
352
|
-
CZMQ_EXPORT void zsocket_set_maxmsgsize (void *zocket, int maxmsgsize);
|
353
|
-
CZMQ_EXPORT void zsocket_set_multicast_hops (void *zocket, int multicast_hops);
|
354
|
-
CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo);
|
355
|
-
CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo);
|
356
|
-
CZMQ_EXPORT void zsocket_set_ipv4only (void *zocket, int ipv4only);
|
357
|
-
CZMQ_EXPORT void zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect);
|
358
|
-
CZMQ_EXPORT void zsocket_set_router_mandatory (void *zocket, int router_mandatory);
|
359
|
-
CZMQ_EXPORT void zsocket_set_router_raw (void *zocket, int router_raw);
|
360
|
-
CZMQ_EXPORT void zsocket_set_xpub_verbose (void *zocket, int xpub_verbose);
|
698
|
+
// Return file name, remove path if provided
|
699
|
+
CZMQ_EXPORT char *
|
700
|
+
zfile_filename (zfile_t *self, char *path);
|
361
701
|
|
362
|
-
//
|
363
|
-
|
364
|
-
|
702
|
+
// Return when the file was last modified.
|
703
|
+
// Updates the file statistics from disk at every call.
|
704
|
+
CZMQ_EXPORT time_t
|
705
|
+
zfile_modified (zfile_t *self);
|
365
706
|
|
366
|
-
//
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
XML file, which provides the metadata, and the sockopts.gsl template,
|
371
|
-
which does the work.
|
372
|
-
|
373
|
-
<A name="toc4-149" title="zstr - sending and receiving strings" />
|
374
|
-
#### zstr - sending and receiving strings
|
375
|
-
|
376
|
-
The zstr class provides utility functions for sending and receiving C
|
377
|
-
strings across ØMQ sockets. It sends strings without a terminating null,
|
378
|
-
and appends a null byte on received strings. This class is for simple
|
379
|
-
message sending.
|
380
|
-
|
381
|
-
<center>
|
382
|
-
<img src="https://github.com/zeromq/czmq/raw/master/images/README_2.png" alt="2">
|
383
|
-
</center>
|
384
|
-
|
385
|
-
This is the class interface:
|
386
|
-
|
387
|
-
// Receive a string off a socket, caller must free it
|
388
|
-
CZMQ_EXPORT char *
|
389
|
-
zstr_recv (void *socket);
|
707
|
+
// Return the last-known size of the file.
|
708
|
+
// Updates the file statistics from disk at every call.
|
709
|
+
CZMQ_EXPORT off_t
|
710
|
+
zfile_cursize (zfile_t *self);
|
390
711
|
|
391
|
-
//
|
392
|
-
|
393
|
-
|
712
|
+
// Return true if the file is a directory.
|
713
|
+
// Updates the file statistics from disk at every call.
|
714
|
+
CZMQ_EXPORT bool
|
715
|
+
zfile_is_directory (zfile_t *self);
|
394
716
|
|
395
|
-
//
|
717
|
+
// Return true if the file is a regular file.
|
718
|
+
// Updates the file statistics from disk at every call.
|
719
|
+
CZMQ_EXPORT bool
|
720
|
+
zfile_is_regular (zfile_t *self);
|
721
|
+
|
722
|
+
// Return true if the file is readable by this process
|
723
|
+
// Updates the file statistics from disk at every call.
|
724
|
+
CZMQ_EXPORT bool
|
725
|
+
zfile_is_readable (zfile_t *self);
|
726
|
+
|
727
|
+
// Return true if the file is writeable by this process
|
728
|
+
// Updates the file statistics from disk at every call.
|
729
|
+
CZMQ_EXPORT bool
|
730
|
+
zfile_is_writeable (zfile_t *self);
|
731
|
+
|
732
|
+
// Check if file has stopped changing and can be safely processed.
|
733
|
+
// Updates the file statistics from disk at every call.
|
734
|
+
CZMQ_EXPORT bool
|
735
|
+
zfile_is_stable (zfile_t *self);
|
736
|
+
|
737
|
+
// Remove the file from disk
|
738
|
+
CZMQ_EXPORT void
|
739
|
+
zfile_remove (zfile_t *self);
|
740
|
+
|
741
|
+
// Open file for reading, returns 0 if OK, else -1.
|
396
742
|
CZMQ_EXPORT int
|
397
|
-
|
743
|
+
zfile_input (zfile_t *self);
|
398
744
|
|
399
|
-
//
|
745
|
+
// Open file for writing, creating full directory path if needed
|
400
746
|
CZMQ_EXPORT int
|
401
|
-
|
747
|
+
zfile_output (zfile_t *self);
|
748
|
+
|
749
|
+
// Read chunk from file at specified position
|
750
|
+
CZMQ_EXPORT zchunk_t *
|
751
|
+
zfile_read (zfile_t *self, size_t bytes, off_t offset);
|
752
|
+
|
753
|
+
// Write chunk to file at specified position
|
754
|
+
CZMQ_EXPORT int
|
755
|
+
zfile_write (zfile_t *self, zchunk_t *chunk, off_t offset);
|
756
|
+
|
757
|
+
// Close file, if open
|
758
|
+
CZMQ_EXPORT void
|
759
|
+
zfile_close (zfile_t *self);
|
760
|
+
|
761
|
+
// Return file handle, if opened
|
762
|
+
CZMQ_EXPORT FILE *
|
763
|
+
zfile_handle (zfile_t *self);
|
402
764
|
|
403
765
|
// Self test of this class
|
404
|
-
int
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
<A name="toc4-174" title="zfile - work with files" />
|
409
|
-
#### zfile - work with files
|
410
|
-
|
411
|
-
The zfile class provides methods to work with files and directories.
|
412
|
-
|
413
|
-
This is the class interface:
|
414
|
-
|
415
|
-
// Return 1 if file exists, else zero
|
766
|
+
CZMQ_EXPORT int
|
767
|
+
zfile_test (bool verbose);
|
768
|
+
// These methods are deprecated, and now moved to zsys class.
|
416
769
|
CZMQ_EXPORT bool
|
417
770
|
zfile_exists (const char *filename);
|
418
|
-
|
419
|
-
// Return size of file, or -1 if not found
|
420
771
|
CZMQ_EXPORT ssize_t
|
421
|
-
zfile_size
|
422
|
-
|
423
|
-
// Return file mode
|
772
|
+
zfile_size (const char *filename);
|
424
773
|
CZMQ_EXPORT mode_t
|
425
|
-
zfile_mode
|
426
|
-
|
427
|
-
// Delete file. Does not complain if the file is absent
|
774
|
+
zfile_mode (const char *filename);
|
428
775
|
CZMQ_EXPORT int
|
429
776
|
zfile_delete (const char *filename);
|
430
|
-
|
431
|
-
// Check if file is 'stable'
|
432
777
|
CZMQ_EXPORT bool
|
433
778
|
zfile_stable (const char *filename);
|
434
|
-
|
435
|
-
// Create a file path if it doesn't exit
|
436
779
|
CZMQ_EXPORT int
|
437
|
-
zfile_mkdir
|
438
|
-
|
439
|
-
// Remove a file path if empty
|
780
|
+
zfile_mkdir (const char *pathname);
|
440
781
|
CZMQ_EXPORT int
|
441
|
-
zfile_rmdir
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
782
|
+
zfile_rmdir (const char *pathname);
|
783
|
+
CZMQ_EXPORT void
|
784
|
+
zfile_mode_private (void);
|
785
|
+
CZMQ_EXPORT void
|
786
|
+
zfile_mode_default (void);
|
446
787
|
|
447
788
|
|
448
|
-
<A name="toc4-
|
789
|
+
<A name="toc4-243" title="zframe - working with single message frames" />
|
449
790
|
#### zframe - working with single message frames
|
450
791
|
|
451
792
|
The zframe class provides methods to send and receive single message
|
@@ -462,17 +803,13 @@ This is the class interface:
|
|
462
803
|
#define ZFRAME_REUSE 2
|
463
804
|
#define ZFRAME_DONTWAIT 4
|
464
805
|
|
465
|
-
// Callback function for zframe_free_fn method
|
466
|
-
typedef void (zframe_free_fn) (void *data, void *arg);
|
467
|
-
|
468
806
|
// Create a new frame with optional size, and optional data
|
469
807
|
CZMQ_EXPORT zframe_t *
|
470
808
|
zframe_new (const void *data, size_t size);
|
471
809
|
|
472
|
-
// Create
|
810
|
+
// Create an empty (zero-sized) frame
|
473
811
|
CZMQ_EXPORT zframe_t *
|
474
|
-
|
475
|
-
zframe_free_fn *free_fn, void *arg);
|
812
|
+
zframe_new_empty (void);
|
476
813
|
|
477
814
|
// Destroy a frame
|
478
815
|
CZMQ_EXPORT void
|
@@ -489,8 +826,8 @@ This is the class interface:
|
|
489
826
|
CZMQ_EXPORT zframe_t *
|
490
827
|
zframe_recv_nowait (void *socket);
|
491
828
|
|
492
|
-
// Send a frame to a socket, destroy frame after sending.
|
493
|
-
//
|
829
|
+
// Send a frame to a socket, destroy frame after sending.
|
830
|
+
// Return -1 on error, 0 on success.
|
494
831
|
CZMQ_EXPORT int
|
495
832
|
zframe_send (zframe_t **self_p, void *socket, int flags);
|
496
833
|
|
@@ -518,19 +855,25 @@ This is the class interface:
|
|
518
855
|
CZMQ_EXPORT bool
|
519
856
|
zframe_streq (zframe_t *self, const char *string);
|
520
857
|
|
521
|
-
//
|
858
|
+
// Return frame MORE indicator (1 or 0), set when reading frame from socket
|
859
|
+
// or by the zframe_set_more() method
|
522
860
|
CZMQ_EXPORT int
|
523
|
-
|
524
|
-
|
525
|
-
// Return frame 'more' property
|
526
|
-
CZMQ_EXPORT int
|
527
|
-
zframe_more (const zframe_t *self);
|
861
|
+
zframe_more (zframe_t *self);
|
528
862
|
|
863
|
+
// Set frame MORE indicator (1 or 0). Note this is NOT used when sending
|
864
|
+
// frame to socket, you have to specify flag explicitly.
|
865
|
+
CZMQ_EXPORT void
|
866
|
+
zframe_set_more (zframe_t *self, int more);
|
867
|
+
|
529
868
|
// Return TRUE if two frames have identical size and data
|
530
869
|
// If either frame is NULL, equality is always false.
|
531
870
|
CZMQ_EXPORT bool
|
532
871
|
zframe_eq (zframe_t *self, zframe_t *other);
|
533
872
|
|
873
|
+
// Print contents of the frame to FILE stream.
|
874
|
+
CZMQ_EXPORT void
|
875
|
+
zframe_fprint (zframe_t *self, const char *prefix, FILE *file);
|
876
|
+
|
534
877
|
// Print contents of frame to stderr
|
535
878
|
CZMQ_EXPORT void
|
536
879
|
zframe_print (zframe_t *self, const char *prefix);
|
@@ -540,82 +883,354 @@ This is the class interface:
|
|
540
883
|
zframe_reset (zframe_t *self, const void *data, size_t size);
|
541
884
|
|
542
885
|
// Self test of this class
|
543
|
-
int
|
886
|
+
CZMQ_EXPORT int
|
544
887
|
zframe_test (bool verbose);
|
545
888
|
|
546
889
|
|
547
|
-
<A name="toc4-
|
548
|
-
####
|
890
|
+
<A name="toc4-254" title="zhash - generic hash table container" />
|
891
|
+
#### zhash - generic hash table container
|
549
892
|
|
550
|
-
|
551
|
-
across ØMQ sockets. This class provides a list-like container interface,
|
552
|
-
with methods to work with the overall container. zmsg_t messages are
|
553
|
-
composed of zero or more zframe_t frames.
|
893
|
+
Expandable hash table container
|
554
894
|
|
555
895
|
This is the class interface:
|
556
896
|
|
557
|
-
//
|
558
|
-
|
559
|
-
|
897
|
+
// Callback function for zhash_foreach method
|
898
|
+
typedef int (zhash_foreach_fn) (const char *key, void *item, void *argument);
|
899
|
+
// Callback function for zhash_freefn method
|
900
|
+
typedef void (zhash_free_fn) (void *data);
|
560
901
|
|
561
|
-
//
|
562
|
-
CZMQ_EXPORT
|
563
|
-
|
902
|
+
// Create a new, empty hash container
|
903
|
+
CZMQ_EXPORT zhash_t *
|
904
|
+
zhash_new (void);
|
564
905
|
|
565
|
-
//
|
566
|
-
CZMQ_EXPORT
|
567
|
-
|
906
|
+
// Destroy a hash container and all items in it
|
907
|
+
CZMQ_EXPORT void
|
908
|
+
zhash_destroy (zhash_t **self_p);
|
568
909
|
|
569
|
-
//
|
910
|
+
// Insert item into hash table with specified key and item.
|
911
|
+
// If key is already present returns -1 and leaves existing item unchanged
|
912
|
+
// Returns 0 on success.
|
570
913
|
CZMQ_EXPORT int
|
571
|
-
|
914
|
+
zhash_insert (zhash_t *self, const char *key, void *item);
|
572
915
|
|
573
|
-
//
|
574
|
-
|
575
|
-
|
916
|
+
// Update item into hash table with specified key and item.
|
917
|
+
// If key is already present, destroys old item and inserts new one.
|
918
|
+
// Use free_fn method to ensure deallocator is properly called on item.
|
919
|
+
CZMQ_EXPORT void
|
920
|
+
zhash_update (zhash_t *self, const char *key, void *item);
|
576
921
|
|
577
|
-
//
|
578
|
-
|
579
|
-
|
922
|
+
// Remove an item specified by key from the hash table. If there was no such
|
923
|
+
// item, this function does nothing.
|
924
|
+
CZMQ_EXPORT void
|
925
|
+
zhash_delete (zhash_t *self, const char *key);
|
926
|
+
|
927
|
+
// Return the item at the specified key, or null
|
928
|
+
CZMQ_EXPORT void *
|
929
|
+
zhash_lookup (zhash_t *self, const char *key);
|
580
930
|
|
581
|
-
//
|
931
|
+
// Reindexes an item from an old key to a new key. If there was no such
|
932
|
+
// item, does nothing. Returns 0 if successful, else -1.
|
582
933
|
CZMQ_EXPORT int
|
583
|
-
|
934
|
+
zhash_rename (zhash_t *self, const char *old_key, const char *new_key);
|
584
935
|
|
585
|
-
//
|
586
|
-
|
587
|
-
|
936
|
+
// Set a free function for the specified hash table item. When the item is
|
937
|
+
// destroyed, the free function, if any, is called on that item.
|
938
|
+
// Use this when hash items are dynamically allocated, to ensure that
|
939
|
+
// you don't have memory leaks. You can pass 'free' or NULL as a free_fn.
|
940
|
+
// Returns the item, or NULL if there is no such item.
|
941
|
+
CZMQ_EXPORT void *
|
942
|
+
zhash_freefn (zhash_t *self, const char *key, zhash_free_fn *free_fn);
|
588
943
|
|
589
|
-
//
|
590
|
-
CZMQ_EXPORT
|
591
|
-
|
944
|
+
// Return the number of keys/items in the hash table
|
945
|
+
CZMQ_EXPORT size_t
|
946
|
+
zhash_size (zhash_t *self);
|
592
947
|
|
593
|
-
//
|
594
|
-
|
595
|
-
|
596
|
-
zmsg_pushmem (zmsg_t *self, const void *src, size_t size);
|
948
|
+
// Make copy of hash table
|
949
|
+
CZMQ_EXPORT zhash_t *
|
950
|
+
zhash_dup (zhash_t *self);
|
597
951
|
|
598
|
-
//
|
599
|
-
|
952
|
+
// Return keys for items in table
|
953
|
+
CZMQ_EXPORT zlist_t *
|
954
|
+
zhash_keys (zhash_t *self);
|
955
|
+
|
956
|
+
// Apply function to each item in the hash table. Items are iterated in no
|
957
|
+
// defined order. Stops if callback function returns non-zero and returns
|
958
|
+
// final return code from callback function (zero = success).
|
600
959
|
CZMQ_EXPORT int
|
601
|
-
|
960
|
+
zhash_foreach (zhash_t *self, zhash_foreach_fn *callback, void *argument);
|
602
961
|
|
603
|
-
//
|
604
|
-
//
|
962
|
+
// Add comment to hash table before saving to disk. You can add as many
|
963
|
+
// comment lines as you like. These comment lines are discarded when loading
|
964
|
+
// the file. If you use a null format, all comments are deleted.
|
965
|
+
CZMQ_EXPORT void
|
966
|
+
zhash_comment (zhash_t *self, char *format, ...);
|
967
|
+
|
968
|
+
// Save hash table to a text file in name=value format. Hash values must be
|
969
|
+
// printable strings; keys may not contain '=' character. Returns 0 if OK,
|
970
|
+
// else -1 if a file error occurred.
|
605
971
|
CZMQ_EXPORT int
|
606
|
-
|
972
|
+
zhash_save (zhash_t *self, char *filename);
|
607
973
|
|
608
|
-
//
|
609
|
-
//
|
974
|
+
// Load hash table from a text file in name=value format; hash table must
|
975
|
+
// already exist. Hash values must printable strings; keys may not contain
|
976
|
+
// '=' character. Returns 0 if OK, else -1 if a file was not readable.
|
610
977
|
CZMQ_EXPORT int
|
611
|
-
|
978
|
+
zhash_load (zhash_t *self, char *filename);
|
612
979
|
|
613
|
-
//
|
614
|
-
|
615
|
-
|
980
|
+
// When a hash table was loaded from a file by zhash_load, this method will
|
981
|
+
// reload the file if it has been modified since, and is "stable", i.e. not
|
982
|
+
// still changing. Returns 0 if OK, -1 if there was an error reloading the
|
983
|
+
// file.
|
984
|
+
CZMQ_EXPORT int
|
985
|
+
zhash_refresh (zhash_t *self);
|
616
986
|
|
617
|
-
//
|
618
|
-
|
987
|
+
// Set hash for automatic value destruction
|
988
|
+
CZMQ_EXPORT void
|
989
|
+
zhash_autofree (zhash_t *self);
|
990
|
+
|
991
|
+
// Self test of this class
|
992
|
+
CZMQ_EXPORT void
|
993
|
+
zhash_test (int verbose);
|
994
|
+
|
995
|
+
Note that it's relatively slow (~50K insertions/deletes per second), so
|
996
|
+
don't do inserts/updates on the critical path for message I/O. It can
|
997
|
+
do ~2.5M lookups per second for 16-char keys. Timed on a 1.6GHz CPU.
|
998
|
+
|
999
|
+
<A name="toc4-265" title="zlist - generic list container" />
|
1000
|
+
#### zlist - generic list container
|
1001
|
+
|
1002
|
+
Provides a generic container implementing a fast singly-linked list. You
|
1003
|
+
can use this to construct multi-dimensional lists, and other structures
|
1004
|
+
together with other generic containers like zhash.
|
1005
|
+
|
1006
|
+
This is the class interface:
|
1007
|
+
|
1008
|
+
// Comparison function for zlist_sort method
|
1009
|
+
typedef bool (zlist_compare_fn) (void *item1, void *item2);
|
1010
|
+
|
1011
|
+
// Create a new list container
|
1012
|
+
CZMQ_EXPORT zlist_t *
|
1013
|
+
zlist_new (void);
|
1014
|
+
|
1015
|
+
// Destroy a list container
|
1016
|
+
CZMQ_EXPORT void
|
1017
|
+
zlist_destroy (zlist_t **self_p);
|
1018
|
+
|
1019
|
+
// Return first item in the list, or null
|
1020
|
+
CZMQ_EXPORT void *
|
1021
|
+
zlist_first (zlist_t *self);
|
1022
|
+
|
1023
|
+
// Return last item in the list, or null
|
1024
|
+
CZMQ_EXPORT void *
|
1025
|
+
zlist_last (zlist_t *self);
|
1026
|
+
|
1027
|
+
// Return first item in the list, or null, leaves the cursor
|
1028
|
+
CZMQ_EXPORT void *
|
1029
|
+
zlist_head (zlist_t *self);
|
1030
|
+
|
1031
|
+
// Return last item in the list, or null, leaves the cursor
|
1032
|
+
CZMQ_EXPORT void *
|
1033
|
+
zlist_tail (zlist_t *self);
|
1034
|
+
|
1035
|
+
// Return next item in the list, or null
|
1036
|
+
CZMQ_EXPORT void *
|
1037
|
+
zlist_next (zlist_t *self);
|
1038
|
+
|
1039
|
+
// Append an item to the end of the list
|
1040
|
+
CZMQ_EXPORT int
|
1041
|
+
zlist_append (zlist_t *self, void *item);
|
1042
|
+
|
1043
|
+
// Push an item to the start of the list
|
1044
|
+
CZMQ_EXPORT int
|
1045
|
+
zlist_push (zlist_t *self, void *item);
|
1046
|
+
|
1047
|
+
// Pop the item off the start of the list, if any
|
1048
|
+
CZMQ_EXPORT void *
|
1049
|
+
zlist_pop (zlist_t *self);
|
1050
|
+
|
1051
|
+
// Remove the specified item from the list if present
|
1052
|
+
CZMQ_EXPORT void
|
1053
|
+
zlist_remove (zlist_t *self, void *item);
|
1054
|
+
|
1055
|
+
// Copy the entire list, return the copy
|
1056
|
+
CZMQ_EXPORT zlist_t *
|
1057
|
+
zlist_dup (zlist_t *self);
|
1058
|
+
|
1059
|
+
// Return number of items in the list
|
1060
|
+
CZMQ_EXPORT size_t
|
1061
|
+
zlist_size (zlist_t *self);
|
1062
|
+
|
1063
|
+
// Sort list
|
1064
|
+
CZMQ_EXPORT void
|
1065
|
+
zlist_sort (zlist_t *self, zlist_compare_fn *compare);
|
1066
|
+
|
1067
|
+
// Set list for automatic item destruction
|
1068
|
+
CZMQ_EXPORT void
|
1069
|
+
zlist_autofree (zlist_t *self);
|
1070
|
+
|
1071
|
+
// Self test of this class
|
1072
|
+
CZMQ_EXPORT void
|
1073
|
+
zlist_test (int verbose);
|
1074
|
+
|
1075
|
+
To iterate through a list, use zlist_first to get the first item, then
|
1076
|
+
loop while not null, and do zlist_next at the end of each iteration.
|
1077
|
+
|
1078
|
+
<A name="toc4-276" title="zloop - event-driven reactor" />
|
1079
|
+
#### zloop - event-driven reactor
|
1080
|
+
|
1081
|
+
The zloop class provides an event-driven reactor pattern. The reactor
|
1082
|
+
handles zmq_pollitem_t items (pollers or writers, sockets or fds), and
|
1083
|
+
once-off or repeated timers. Its resolution is 1 msec. It uses a tickless
|
1084
|
+
timer to reduce CPU interrupts in inactive processes.
|
1085
|
+
|
1086
|
+
This is the class interface:
|
1087
|
+
|
1088
|
+
// Callback function for reactor events
|
1089
|
+
typedef int (zloop_fn) (zloop_t *loop, zmq_pollitem_t *item, void *arg);
|
1090
|
+
|
1091
|
+
// Create a new zloop reactor
|
1092
|
+
CZMQ_EXPORT zloop_t *
|
1093
|
+
zloop_new (void);
|
1094
|
+
|
1095
|
+
// Destroy a reactor
|
1096
|
+
CZMQ_EXPORT void
|
1097
|
+
zloop_destroy (zloop_t **self_p);
|
1098
|
+
|
1099
|
+
// Register pollitem with the reactor. When the pollitem is ready, will call
|
1100
|
+
// the handler, passing the arg. Returns 0 if OK, -1 if there was an error.
|
1101
|
+
// If you register the pollitem more than once, each instance will invoke its
|
1102
|
+
// corresponding handler.
|
1103
|
+
CZMQ_EXPORT int
|
1104
|
+
zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg);
|
1105
|
+
|
1106
|
+
// Cancel a pollitem from the reactor, specified by socket or FD. If both
|
1107
|
+
// are specified, uses only socket. If multiple poll items exist for same
|
1108
|
+
// socket/FD, cancels ALL of them.
|
1109
|
+
CZMQ_EXPORT void
|
1110
|
+
zloop_poller_end (zloop_t *self, zmq_pollitem_t *item);
|
1111
|
+
|
1112
|
+
// Configure a registered pollitem to ignore errors. If you do not set this,
|
1113
|
+
// then pollitems that have errors are removed from the reactor silently.
|
1114
|
+
CZMQ_EXPORT void
|
1115
|
+
zloop_set_tolerant (zloop_t *self, zmq_pollitem_t *item);
|
1116
|
+
|
1117
|
+
// Register a timer that expires after some delay and repeats some number of
|
1118
|
+
// times. At each expiry, will call the handler, passing the arg. To
|
1119
|
+
// run a timer forever, use 0 times. Returns 0 if OK, -1 if there was an
|
1120
|
+
// error.
|
1121
|
+
CZMQ_EXPORT int
|
1122
|
+
zloop_timer (zloop_t *self, size_t delay, size_t times, zloop_fn handler, void *arg);
|
1123
|
+
|
1124
|
+
// Cancel all timers for a specific argument (as provided in zloop_timer)
|
1125
|
+
CZMQ_EXPORT int
|
1126
|
+
zloop_timer_end (zloop_t *self, void *arg);
|
1127
|
+
|
1128
|
+
// Set verbose tracing of reactor on/off
|
1129
|
+
CZMQ_EXPORT void
|
1130
|
+
zloop_set_verbose (zloop_t *self, bool verbose);
|
1131
|
+
|
1132
|
+
// Start the reactor. Takes control of the thread and returns when the ØMQ
|
1133
|
+
// context is terminated or the process is interrupted, or any event handler
|
1134
|
+
// returns -1. Event handlers may register new sockets and timers, and
|
1135
|
+
// cancel sockets. Returns 0 if interrupted, -1 if cancelled by a handler.
|
1136
|
+
CZMQ_EXPORT int
|
1137
|
+
zloop_start (zloop_t *self);
|
1138
|
+
|
1139
|
+
// Self test of this class
|
1140
|
+
CZMQ_EXPORT void
|
1141
|
+
zloop_test (bool verbose);
|
1142
|
+
|
1143
|
+
|
1144
|
+
<A name="toc4-287" title="zmsg - working with multipart messages" />
|
1145
|
+
#### zmsg - working with multipart messages
|
1146
|
+
|
1147
|
+
The zmsg class provides methods to send and receive multipart messages
|
1148
|
+
across ØMQ sockets. This class provides a list-like container interface,
|
1149
|
+
with methods to work with the overall container. zmsg_t messages are
|
1150
|
+
composed of zero or more zframe_t frames.
|
1151
|
+
|
1152
|
+
This is the class interface:
|
1153
|
+
|
1154
|
+
// Create a new empty message object
|
1155
|
+
CZMQ_EXPORT zmsg_t *
|
1156
|
+
zmsg_new (void);
|
1157
|
+
|
1158
|
+
// Destroy a message object and all frames it contains
|
1159
|
+
CZMQ_EXPORT void
|
1160
|
+
zmsg_destroy (zmsg_t **self_p);
|
1161
|
+
|
1162
|
+
// Receive message from socket, returns zmsg_t object or NULL if the recv
|
1163
|
+
// was interrupted. Does a blocking recv, if you want to not block then use
|
1164
|
+
// the zloop class or zmq_poll to check for socket input before receiving.
|
1165
|
+
CZMQ_EXPORT zmsg_t *
|
1166
|
+
zmsg_recv (void *socket);
|
1167
|
+
|
1168
|
+
// Send message to socket, destroy after sending. If the message has no
|
1169
|
+
// frames, sends nothing but destroys the message anyhow. Safe to call
|
1170
|
+
// if zmsg is null.
|
1171
|
+
CZMQ_EXPORT int
|
1172
|
+
zmsg_send (zmsg_t **self_p, void *socket);
|
1173
|
+
|
1174
|
+
// Return size of message, i.e. number of frames (0 or more).
|
1175
|
+
CZMQ_EXPORT size_t
|
1176
|
+
zmsg_size (zmsg_t *self);
|
1177
|
+
|
1178
|
+
// Return total size of all frames in message.
|
1179
|
+
CZMQ_EXPORT size_t
|
1180
|
+
zmsg_content_size (zmsg_t *self);
|
1181
|
+
|
1182
|
+
// Push frame to the front of the message, i.e. before all other frames.
|
1183
|
+
// Message takes ownership of frame, will destroy it when message is sent.
|
1184
|
+
// Returns 0 on success, -1 on error.
|
1185
|
+
CZMQ_EXPORT int
|
1186
|
+
zmsg_push (zmsg_t *self, zframe_t *frame);
|
1187
|
+
|
1188
|
+
// Remove first frame from message, if any. Returns frame, or NULL. Caller
|
1189
|
+
// now owns frame and must destroy it when finished with it.
|
1190
|
+
CZMQ_EXPORT zframe_t *
|
1191
|
+
zmsg_pop (zmsg_t *self);
|
1192
|
+
|
1193
|
+
// Add frame to the end of the message, i.e. after all other frames.
|
1194
|
+
// Message takes ownership of frame, will destroy it when message is sent.
|
1195
|
+
// Returns 0 on success. Deprecates zmsg_add, which did not nullify the
|
1196
|
+
// caller's frame reference.
|
1197
|
+
CZMQ_EXPORT int
|
1198
|
+
zmsg_append (zmsg_t *self, zframe_t **frame_p);
|
1199
|
+
|
1200
|
+
// Add frame to the end of the message, i.e. after all other frames.
|
1201
|
+
// Message takes ownership of frame, will destroy it when message is sent.
|
1202
|
+
// Returns 0 on success.
|
1203
|
+
// DEPRECATED - will be removed for next stable release
|
1204
|
+
CZMQ_EXPORT int
|
1205
|
+
zmsg_add (zmsg_t *self, zframe_t *frame);
|
1206
|
+
|
1207
|
+
// Push block of memory to front of message, as a new frame.
|
1208
|
+
// Returns 0 on success, -1 on error.
|
1209
|
+
CZMQ_EXPORT int
|
1210
|
+
zmsg_pushmem (zmsg_t *self, const void *src, size_t size);
|
1211
|
+
|
1212
|
+
// Add block of memory to the end of the message, as a new frame.
|
1213
|
+
// Returns 0 on success, -1 on error.
|
1214
|
+
CZMQ_EXPORT int
|
1215
|
+
zmsg_addmem (zmsg_t *self, const void *src, size_t size);
|
1216
|
+
|
1217
|
+
// Push string as new frame to front of message.
|
1218
|
+
// Returns 0 on success, -1 on error.
|
1219
|
+
CZMQ_EXPORT int
|
1220
|
+
zmsg_pushstr (zmsg_t *self, const char *format, ...);
|
1221
|
+
|
1222
|
+
// Push string as new frame to end of message.
|
1223
|
+
// Returns 0 on success, -1 on error.
|
1224
|
+
CZMQ_EXPORT int
|
1225
|
+
zmsg_addstr (zmsg_t *self, const char *format, ...);
|
1226
|
+
|
1227
|
+
// Pop frame off front of message, return as fresh string. If there were
|
1228
|
+
// no more frames in the message, returns NULL.
|
1229
|
+
CZMQ_EXPORT char *
|
1230
|
+
zmsg_popstr (zmsg_t *self);
|
1231
|
+
|
1232
|
+
// Push frame plus empty frame to front of message, before first frame.
|
1233
|
+
// Message takes ownership of frame, will destroy it when message is sent.
|
619
1234
|
CZMQ_EXPORT void
|
620
1235
|
zmsg_wrap (zmsg_t *self, zframe_t *frame);
|
621
1236
|
|
@@ -624,115 +1239,580 @@ This is the class interface:
|
|
624
1239
|
CZMQ_EXPORT zframe_t *
|
625
1240
|
zmsg_unwrap (zmsg_t *self);
|
626
1241
|
|
627
|
-
// Remove frame from
|
1242
|
+
// Remove specified frame from list, if present. Does not destroy frame.
|
628
1243
|
CZMQ_EXPORT void
|
629
1244
|
zmsg_remove (zmsg_t *self, zframe_t *frame);
|
630
1245
|
|
631
|
-
//
|
1246
|
+
// Set cursor to first frame in message. Returns frame, or NULL, if the
|
1247
|
+
// message is empty. Use this to navigate the frames as a list.
|
632
1248
|
CZMQ_EXPORT zframe_t *
|
633
1249
|
zmsg_first (zmsg_t *self);
|
634
1250
|
|
635
|
-
// Return next frame
|
1251
|
+
// Return the next frame. If there are no more frames, returns NULL. To move
|
1252
|
+
// to the first frame call zmsg_first(). Advances the cursor.
|
636
1253
|
CZMQ_EXPORT zframe_t *
|
637
1254
|
zmsg_next (zmsg_t *self);
|
638
1255
|
|
639
|
-
// Return last frame
|
1256
|
+
// Return the last frame. If there are no frames, returns NULL.
|
640
1257
|
CZMQ_EXPORT zframe_t *
|
641
1258
|
zmsg_last (zmsg_t *self);
|
642
1259
|
|
643
|
-
// Save message to an open file, return 0 if OK, else -1.
|
1260
|
+
// Save message to an open file, return 0 if OK, else -1. The message is
|
1261
|
+
// saved as a series of frames, each with length and data. Note that the
|
1262
|
+
// file is NOT guaranteed to be portable between operating systems, not
|
1263
|
+
// versions of CZMQ. The file format is at present undocumented and liable
|
1264
|
+
// to arbitrary change.
|
644
1265
|
CZMQ_EXPORT int
|
645
1266
|
zmsg_save (zmsg_t *self, FILE *file);
|
646
1267
|
|
647
1268
|
// Load/append an open file into message, create new message if
|
648
|
-
// null message provided.
|
1269
|
+
// null message provided. Returns NULL if the message could not
|
1270
|
+
// be loaded.
|
649
1271
|
CZMQ_EXPORT zmsg_t *
|
650
1272
|
zmsg_load (zmsg_t *self, FILE *file);
|
651
1273
|
|
652
|
-
//
|
1274
|
+
// Serialize multipart message to a single buffer. Use this method to send
|
1275
|
+
// structured messages across transports that do not support multipart data.
|
1276
|
+
// Allocates and returns a new buffer containing the serialized message.
|
1277
|
+
// To decode a serialized message buffer, use zmsg_decode ().
|
653
1278
|
CZMQ_EXPORT size_t
|
654
1279
|
zmsg_encode (zmsg_t *self, byte **buffer);
|
655
1280
|
|
656
|
-
//
|
657
|
-
//
|
1281
|
+
// Decodes a serialized message buffer created by zmsg_encode () and returns
|
1282
|
+
// a new zmsg_t object. Returns NULL if the buffer was badly formatted or
|
1283
|
+
// there was insufficient memory to work.
|
658
1284
|
CZMQ_EXPORT zmsg_t *
|
659
1285
|
zmsg_decode (byte *buffer, size_t buffer_size);
|
660
1286
|
|
661
|
-
// Create copy of message, as new message object
|
1287
|
+
// Create copy of message, as new message object. Returns a fresh zmsg_t
|
1288
|
+
// object, or NULL if there was not enough heap memory.
|
662
1289
|
CZMQ_EXPORT zmsg_t *
|
663
1290
|
zmsg_dup (zmsg_t *self);
|
664
1291
|
|
665
|
-
//
|
1292
|
+
// Dump message to stderr, for debugging and tracing.
|
1293
|
+
// See zmsg_dump_to_stream() for details
|
666
1294
|
CZMQ_EXPORT void
|
667
1295
|
zmsg_dump (zmsg_t *self);
|
668
1296
|
|
1297
|
+
// Dump message to FILE stream, for debugging and tracing.
|
1298
|
+
// Truncates to first 10 frames, for readability; this may be unfortunate
|
1299
|
+
// when debugging larger and more complex messages.
|
1300
|
+
CZMQ_EXPORT void
|
1301
|
+
zmsg_dump_to_stream (zmsg_t *self, FILE *file);
|
1302
|
+
|
669
1303
|
// Self test of this class
|
670
|
-
int
|
1304
|
+
CZMQ_EXPORT int
|
671
1305
|
zmsg_test (bool verbose);
|
672
1306
|
|
673
1307
|
|
674
|
-
<A name="toc4-
|
675
|
-
####
|
1308
|
+
<A name="toc4-298" title="zmutex - wrap lightweight mutexes" />
|
1309
|
+
#### zmutex - wrap lightweight mutexes
|
1310
|
+
|
1311
|
+
The zmutex class provides a portable wrapper for mutexes. Please do not
|
1312
|
+
use this class to do multi-threading. It is for the rare case where you
|
1313
|
+
absolutely need thread-safe global state. This should happen in system
|
1314
|
+
code only. DO NOT USE THIS TO SHARE SOCKETS BETWEEN THREADS, OR DARK
|
1315
|
+
THINGS WILL HAPPEN TO YOUR CODE.
|
1316
|
+
|
1317
|
+
This is the class interface:
|
1318
|
+
|
1319
|
+
// Create a new mutex container
|
1320
|
+
CZMQ_EXPORT zmutex_t *
|
1321
|
+
zmutex_new (void);
|
1322
|
+
|
1323
|
+
// Destroy a mutex container
|
1324
|
+
CZMQ_EXPORT void
|
1325
|
+
zmutex_destroy (zmutex_t **self_p);
|
1326
|
+
|
1327
|
+
// Lock mutex
|
1328
|
+
CZMQ_EXPORT void
|
1329
|
+
zmutex_lock (zmutex_t *self);
|
1330
|
+
|
1331
|
+
// Unlock mutex
|
1332
|
+
CZMQ_EXPORT void
|
1333
|
+
zmutex_unlock (zmutex_t *self);
|
1334
|
+
|
1335
|
+
// Self test of this class
|
1336
|
+
CZMQ_EXPORT int
|
1337
|
+
zmutex_test (bool verbose);
|
1338
|
+
|
1339
|
+
|
1340
|
+
<A name="toc4-309" title="zpoller - trivial socket poller class" />
|
1341
|
+
#### zpoller - trivial socket poller class
|
1342
|
+
|
1343
|
+
The zpoller class provides a minimalist interface to ZeroMQ's zmq_poll
|
1344
|
+
API, for the very common case of reading from a number of sockets.
|
1345
|
+
It does not provide polling for output, nor polling on file handles.
|
1346
|
+
If you need either of these, use the zmq_poll API directly.
|
1347
|
+
|
1348
|
+
This is the class interface:
|
1349
|
+
|
1350
|
+
// Create new poller
|
1351
|
+
CZMQ_EXPORT zpoller_t *
|
1352
|
+
zpoller_new (void *reader, ...);
|
1353
|
+
|
1354
|
+
// Destroy a poller
|
1355
|
+
CZMQ_EXPORT void
|
1356
|
+
zpoller_destroy (zpoller_t **self_p);
|
1357
|
+
|
1358
|
+
// Poll the registered readers for I/O, return first socket that has input.
|
1359
|
+
// This means the order that sockets are defined in the poll list affects
|
1360
|
+
// their priority. If you need a balanced poll, use the low level zmq_poll
|
1361
|
+
// method directly.
|
1362
|
+
CZMQ_EXPORT void *
|
1363
|
+
zpoller_wait (zpoller_t *self, int timeout);
|
1364
|
+
|
1365
|
+
// Return true if the last zpoller_wait () call ended because the timeout
|
1366
|
+
// expired, without any error.
|
1367
|
+
CZMQ_EXPORT bool
|
1368
|
+
zpoller_expired (zpoller_t *self);
|
1369
|
+
|
1370
|
+
// Return true if the last zpoller_wait () call ended because the process
|
1371
|
+
// was interrupted, or the parent context was destroyed.
|
1372
|
+
CZMQ_EXPORT bool
|
1373
|
+
zpoller_terminated (zpoller_t *self);
|
1374
|
+
|
1375
|
+
// Self test of this class
|
1376
|
+
CZMQ_EXPORT int
|
1377
|
+
zpoller_test (bool verbose);
|
1378
|
+
|
1379
|
+
|
1380
|
+
<A name="toc4-320" title="zsocket - working with ØMQ sockets" />
|
1381
|
+
#### zsocket - working with ØMQ sockets
|
1382
|
+
|
1383
|
+
The zsocket class provides helper functions for ØMQ sockets. It doesn't
|
1384
|
+
wrap the ØMQ socket type, to avoid breaking all libzmq socket-related
|
1385
|
+
calls.
|
1386
|
+
|
1387
|
+
This is the class interface:
|
1388
|
+
|
1389
|
+
// This port range is defined by IANA for dynamic or private ports
|
1390
|
+
// We use this when choosing a port for dynamic binding.
|
1391
|
+
#define ZSOCKET_DYNFROM 0xc000
|
1392
|
+
#define ZSOCKET_DYNTO 0xffff
|
1393
|
+
|
1394
|
+
// Callback function for zero-copy methods
|
1395
|
+
typedef void (zsocket_free_fn) (void *data, void *arg);
|
1396
|
+
|
1397
|
+
// Create a new socket within our CZMQ context, replaces zmq_socket.
|
1398
|
+
// Use this to get automatic management of the socket at shutdown.
|
1399
|
+
// Note: SUB sockets do not automatically subscribe to everything; you
|
1400
|
+
// must set filters explicitly.
|
1401
|
+
CZMQ_EXPORT void *
|
1402
|
+
zsocket_new (zctx_t *self, int type);
|
1403
|
+
|
1404
|
+
// Destroy a socket within our CZMQ context, replaces zmq_close.
|
1405
|
+
CZMQ_EXPORT void
|
1406
|
+
zsocket_destroy (zctx_t *self, void *socket);
|
1407
|
+
|
1408
|
+
// Bind a socket to a formatted endpoint. If the port is specified as
|
1409
|
+
// '*', binds to any free port from ZSOCKET_DYNFROM to ZSOCKET_DYNTO
|
1410
|
+
// and returns the actual port number used. Otherwise asserts that the
|
1411
|
+
// bind succeeded with the specified port number. Always returns the
|
1412
|
+
// port number if successful.
|
1413
|
+
CZMQ_EXPORT int
|
1414
|
+
zsocket_bind (void *socket, const char *format, ...);
|
1415
|
+
|
1416
|
+
// Unbind a socket from a formatted endpoint.
|
1417
|
+
// Returns 0 if OK, -1 if the endpoint was invalid or the function
|
1418
|
+
// isn't supported.
|
1419
|
+
CZMQ_EXPORT int
|
1420
|
+
zsocket_unbind (void *socket, const char *format, ...);
|
1421
|
+
|
1422
|
+
// Connect a socket to a formatted endpoint
|
1423
|
+
// Returns 0 if OK, -1 if the endpoint was invalid.
|
1424
|
+
CZMQ_EXPORT int
|
1425
|
+
zsocket_connect (void *socket, const char *format, ...);
|
1426
|
+
|
1427
|
+
// Disonnect a socket from a formatted endpoint
|
1428
|
+
// Returns 0 if OK, -1 if the endpoint was invalid or the function
|
1429
|
+
// isn't supported.
|
1430
|
+
CZMQ_EXPORT int
|
1431
|
+
zsocket_disconnect (void *socket, const char *format, ...);
|
1432
|
+
|
1433
|
+
// Poll for input events on the socket. Returns TRUE if there is input
|
1434
|
+
// ready on the socket, else FALSE.
|
1435
|
+
CZMQ_EXPORT bool
|
1436
|
+
zsocket_poll (void *socket, int msecs);
|
1437
|
+
|
1438
|
+
// Returns socket type as printable constant string
|
1439
|
+
CZMQ_EXPORT char *
|
1440
|
+
zsocket_type_str (void *socket);
|
1441
|
+
|
1442
|
+
// Send data over a socket as a single frame
|
1443
|
+
// Returns -1 on error, 0 on success
|
1444
|
+
CZMQ_EXPORT int
|
1445
|
+
zsocket_sendmem (void *socket, const void* data, size_t size, int flags);
|
1446
|
+
|
1447
|
+
// Self test of this class
|
1448
|
+
CZMQ_EXPORT int
|
1449
|
+
zsocket_test (bool verbose);
|
1450
|
+
|
1451
|
+
|
1452
|
+
<A name="toc4-331" title="zsockopt - working with ØMQ socket options" />
|
1453
|
+
#### zsockopt - working with ØMQ socket options
|
1454
|
+
|
1455
|
+
The zsockopt class provides access to the ØMQ getsockopt/setsockopt API.
|
1456
|
+
|
1457
|
+
This is the class interface:
|
1458
|
+
|
1459
|
+
#if (ZMQ_VERSION_MAJOR == 4)
|
1460
|
+
// Get socket options
|
1461
|
+
CZMQ_EXPORT int zsocket_ipv6 (void *zocket);
|
1462
|
+
CZMQ_EXPORT int zsocket_ipv4only (void *zocket);
|
1463
|
+
CZMQ_EXPORT int zsocket_probe_router (void *zocket);
|
1464
|
+
CZMQ_EXPORT int zsocket_plain_server (void *zocket);
|
1465
|
+
CZMQ_EXPORT char * zsocket_plain_username (void *zocket);
|
1466
|
+
CZMQ_EXPORT char * zsocket_plain_password (void *zocket);
|
1467
|
+
CZMQ_EXPORT int zsocket_curve_server (void *zocket);
|
1468
|
+
CZMQ_EXPORT char * zsocket_curve_publickey (void *zocket);
|
1469
|
+
CZMQ_EXPORT char * zsocket_curve_secretkey (void *zocket);
|
1470
|
+
CZMQ_EXPORT char * zsocket_curve_serverkey (void *zocket);
|
1471
|
+
CZMQ_EXPORT char * zsocket_zap_domain (void *zocket);
|
1472
|
+
CZMQ_EXPORT int zsocket_type (void *zocket);
|
1473
|
+
CZMQ_EXPORT int zsocket_sndhwm (void *zocket);
|
1474
|
+
CZMQ_EXPORT int zsocket_rcvhwm (void *zocket);
|
1475
|
+
CZMQ_EXPORT int zsocket_affinity (void *zocket);
|
1476
|
+
CZMQ_EXPORT char * zsocket_identity (void *zocket);
|
1477
|
+
CZMQ_EXPORT int zsocket_rate (void *zocket);
|
1478
|
+
CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket);
|
1479
|
+
CZMQ_EXPORT int zsocket_sndbuf (void *zocket);
|
1480
|
+
CZMQ_EXPORT int zsocket_rcvbuf (void *zocket);
|
1481
|
+
CZMQ_EXPORT int zsocket_linger (void *zocket);
|
1482
|
+
CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket);
|
1483
|
+
CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket);
|
1484
|
+
CZMQ_EXPORT int zsocket_backlog (void *zocket);
|
1485
|
+
CZMQ_EXPORT int zsocket_maxmsgsize (void *zocket);
|
1486
|
+
CZMQ_EXPORT int zsocket_multicast_hops (void *zocket);
|
1487
|
+
CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket);
|
1488
|
+
CZMQ_EXPORT int zsocket_sndtimeo (void *zocket);
|
1489
|
+
CZMQ_EXPORT int zsocket_tcp_keepalive (void *zocket);
|
1490
|
+
CZMQ_EXPORT int zsocket_tcp_keepalive_idle (void *zocket);
|
1491
|
+
CZMQ_EXPORT int zsocket_tcp_keepalive_cnt (void *zocket);
|
1492
|
+
CZMQ_EXPORT int zsocket_tcp_keepalive_intvl (void *zocket);
|
1493
|
+
CZMQ_EXPORT char * zsocket_tcp_accept_filter (void *zocket);
|
1494
|
+
CZMQ_EXPORT int zsocket_rcvmore (void *zocket);
|
1495
|
+
CZMQ_EXPORT int zsocket_fd (void *zocket);
|
1496
|
+
CZMQ_EXPORT int zsocket_events (void *zocket);
|
1497
|
+
CZMQ_EXPORT char * zsocket_last_endpoint (void *zocket);
|
1498
|
+
|
1499
|
+
// Set socket options
|
1500
|
+
CZMQ_EXPORT void zsocket_set_ipv6 (void *zocket, int ipv6);
|
1501
|
+
CZMQ_EXPORT void zsocket_set_immediate (void *zocket, int immediate);
|
1502
|
+
CZMQ_EXPORT void zsocket_set_router_raw (void *zocket, int router_raw);
|
1503
|
+
CZMQ_EXPORT void zsocket_set_ipv4only (void *zocket, int ipv4only);
|
1504
|
+
CZMQ_EXPORT void zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect);
|
1505
|
+
CZMQ_EXPORT void zsocket_set_router_mandatory (void *zocket, int router_mandatory);
|
1506
|
+
CZMQ_EXPORT void zsocket_set_req_relaxed (void *zocket, int req_relaxed);
|
1507
|
+
CZMQ_EXPORT void zsocket_set_req_correlate (void *zocket, int req_correlate);
|
1508
|
+
CZMQ_EXPORT void zsocket_set_conflate (void *zocket, int conflate);
|
1509
|
+
CZMQ_EXPORT void zsocket_set_plain_server (void *zocket, int plain_server);
|
1510
|
+
CZMQ_EXPORT void zsocket_set_plain_username (void *zocket, const char * plain_username);
|
1511
|
+
CZMQ_EXPORT void zsocket_set_plain_password (void *zocket, const char * plain_password);
|
1512
|
+
CZMQ_EXPORT void zsocket_set_curve_server (void *zocket, int curve_server);
|
1513
|
+
CZMQ_EXPORT void zsocket_set_curve_publickey (void *zocket, const char * curve_publickey);
|
1514
|
+
CZMQ_EXPORT void zsocket_set_curve_publickey_bin (void *zocket, const byte *curve_publickey);
|
1515
|
+
CZMQ_EXPORT void zsocket_set_curve_secretkey (void *zocket, const char * curve_secretkey);
|
1516
|
+
CZMQ_EXPORT void zsocket_set_curve_secretkey_bin (void *zocket, const byte *curve_secretkey);
|
1517
|
+
CZMQ_EXPORT void zsocket_set_curve_serverkey (void *zocket, const char * curve_serverkey);
|
1518
|
+
CZMQ_EXPORT void zsocket_set_curve_serverkey_bin (void *zocket, const byte *curve_serverkey);
|
1519
|
+
CZMQ_EXPORT void zsocket_set_zap_domain (void *zocket, const char * zap_domain);
|
1520
|
+
CZMQ_EXPORT void zsocket_set_sndhwm (void *zocket, int sndhwm);
|
1521
|
+
CZMQ_EXPORT void zsocket_set_rcvhwm (void *zocket, int rcvhwm);
|
1522
|
+
CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity);
|
1523
|
+
CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe);
|
1524
|
+
CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe);
|
1525
|
+
CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity);
|
1526
|
+
CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate);
|
1527
|
+
CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl);
|
1528
|
+
CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf);
|
1529
|
+
CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf);
|
1530
|
+
CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger);
|
1531
|
+
CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl);
|
1532
|
+
CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max);
|
1533
|
+
CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog);
|
1534
|
+
CZMQ_EXPORT void zsocket_set_maxmsgsize (void *zocket, int maxmsgsize);
|
1535
|
+
CZMQ_EXPORT void zsocket_set_multicast_hops (void *zocket, int multicast_hops);
|
1536
|
+
CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo);
|
1537
|
+
CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo);
|
1538
|
+
CZMQ_EXPORT void zsocket_set_xpub_verbose (void *zocket, int xpub_verbose);
|
1539
|
+
CZMQ_EXPORT void zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive);
|
1540
|
+
CZMQ_EXPORT void zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle);
|
1541
|
+
CZMQ_EXPORT void zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt);
|
1542
|
+
CZMQ_EXPORT void zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl);
|
1543
|
+
CZMQ_EXPORT void zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter);
|
1544
|
+
|
1545
|
+
// Emulation of widely-used 2.x socket options
|
1546
|
+
CZMQ_EXPORT void zsocket_set_hwm (void *zocket, int hwm);
|
1547
|
+
|
1548
|
+
// Patch in case we're on older libzmq
|
1549
|
+
#ifndef ZMQ_STREAM
|
1550
|
+
#define ZMQ_STREAM 11
|
1551
|
+
#endif
|
1552
|
+
#endif
|
1553
|
+
|
1554
|
+
#if (ZMQ_VERSION_MAJOR == 3)
|
1555
|
+
// Get socket options
|
1556
|
+
CZMQ_EXPORT int zsocket_ipv4only (void *zocket);
|
1557
|
+
CZMQ_EXPORT int zsocket_type (void *zocket);
|
1558
|
+
CZMQ_EXPORT int zsocket_sndhwm (void *zocket);
|
1559
|
+
CZMQ_EXPORT int zsocket_rcvhwm (void *zocket);
|
1560
|
+
CZMQ_EXPORT int zsocket_affinity (void *zocket);
|
1561
|
+
CZMQ_EXPORT char * zsocket_identity (void *zocket);
|
1562
|
+
CZMQ_EXPORT int zsocket_rate (void *zocket);
|
1563
|
+
CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket);
|
1564
|
+
CZMQ_EXPORT int zsocket_sndbuf (void *zocket);
|
1565
|
+
CZMQ_EXPORT int zsocket_rcvbuf (void *zocket);
|
1566
|
+
CZMQ_EXPORT int zsocket_linger (void *zocket);
|
1567
|
+
CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket);
|
1568
|
+
CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket);
|
1569
|
+
CZMQ_EXPORT int zsocket_backlog (void *zocket);
|
1570
|
+
CZMQ_EXPORT int zsocket_maxmsgsize (void *zocket);
|
1571
|
+
CZMQ_EXPORT int zsocket_multicast_hops (void *zocket);
|
1572
|
+
CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket);
|
1573
|
+
CZMQ_EXPORT int zsocket_sndtimeo (void *zocket);
|
1574
|
+
CZMQ_EXPORT int zsocket_tcp_keepalive (void *zocket);
|
1575
|
+
CZMQ_EXPORT int zsocket_tcp_keepalive_idle (void *zocket);
|
1576
|
+
CZMQ_EXPORT int zsocket_tcp_keepalive_cnt (void *zocket);
|
1577
|
+
CZMQ_EXPORT int zsocket_tcp_keepalive_intvl (void *zocket);
|
1578
|
+
CZMQ_EXPORT char * zsocket_tcp_accept_filter (void *zocket);
|
1579
|
+
CZMQ_EXPORT int zsocket_rcvmore (void *zocket);
|
1580
|
+
CZMQ_EXPORT int zsocket_fd (void *zocket);
|
1581
|
+
CZMQ_EXPORT int zsocket_events (void *zocket);
|
1582
|
+
CZMQ_EXPORT char * zsocket_last_endpoint (void *zocket);
|
1583
|
+
|
1584
|
+
// Set socket options
|
1585
|
+
CZMQ_EXPORT void zsocket_set_router_raw (void *zocket, int router_raw);
|
1586
|
+
CZMQ_EXPORT void zsocket_set_ipv4only (void *zocket, int ipv4only);
|
1587
|
+
CZMQ_EXPORT void zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect);
|
1588
|
+
CZMQ_EXPORT void zsocket_set_sndhwm (void *zocket, int sndhwm);
|
1589
|
+
CZMQ_EXPORT void zsocket_set_rcvhwm (void *zocket, int rcvhwm);
|
1590
|
+
CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity);
|
1591
|
+
CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe);
|
1592
|
+
CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe);
|
1593
|
+
CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity);
|
1594
|
+
CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate);
|
1595
|
+
CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl);
|
1596
|
+
CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf);
|
1597
|
+
CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf);
|
1598
|
+
CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger);
|
1599
|
+
CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl);
|
1600
|
+
CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max);
|
1601
|
+
CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog);
|
1602
|
+
CZMQ_EXPORT void zsocket_set_maxmsgsize (void *zocket, int maxmsgsize);
|
1603
|
+
CZMQ_EXPORT void zsocket_set_multicast_hops (void *zocket, int multicast_hops);
|
1604
|
+
CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo);
|
1605
|
+
CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo);
|
1606
|
+
CZMQ_EXPORT void zsocket_set_xpub_verbose (void *zocket, int xpub_verbose);
|
1607
|
+
CZMQ_EXPORT void zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive);
|
1608
|
+
CZMQ_EXPORT void zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle);
|
1609
|
+
CZMQ_EXPORT void zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt);
|
1610
|
+
CZMQ_EXPORT void zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl);
|
1611
|
+
CZMQ_EXPORT void zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter);
|
1612
|
+
|
1613
|
+
// Emulation of widely-used 2.x socket options
|
1614
|
+
CZMQ_EXPORT void zsocket_set_hwm (void *zocket, int hwm);
|
1615
|
+
|
1616
|
+
// Patch in case we're on older libzmq
|
1617
|
+
#ifndef ZMQ_STREAM
|
1618
|
+
#define ZMQ_STREAM 11
|
1619
|
+
#endif
|
1620
|
+
#endif
|
1621
|
+
|
1622
|
+
#if (ZMQ_VERSION_MAJOR == 2)
|
1623
|
+
// Get socket options
|
1624
|
+
CZMQ_EXPORT int zsocket_hwm (void *zocket);
|
1625
|
+
CZMQ_EXPORT int zsocket_swap (void *zocket);
|
1626
|
+
CZMQ_EXPORT int zsocket_affinity (void *zocket);
|
1627
|
+
CZMQ_EXPORT char * zsocket_identity (void *zocket);
|
1628
|
+
CZMQ_EXPORT int zsocket_rate (void *zocket);
|
1629
|
+
CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket);
|
1630
|
+
CZMQ_EXPORT int zsocket_recovery_ivl_msec (void *zocket);
|
1631
|
+
CZMQ_EXPORT int zsocket_mcast_loop (void *zocket);
|
1632
|
+
# if (ZMQ_VERSION_MINOR == 2)
|
1633
|
+
CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket);
|
1634
|
+
# endif
|
1635
|
+
# if (ZMQ_VERSION_MINOR == 2)
|
1636
|
+
CZMQ_EXPORT int zsocket_sndtimeo (void *zocket);
|
1637
|
+
# endif
|
1638
|
+
CZMQ_EXPORT int zsocket_sndbuf (void *zocket);
|
1639
|
+
CZMQ_EXPORT int zsocket_rcvbuf (void *zocket);
|
1640
|
+
CZMQ_EXPORT int zsocket_linger (void *zocket);
|
1641
|
+
CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket);
|
1642
|
+
CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket);
|
1643
|
+
CZMQ_EXPORT int zsocket_backlog (void *zocket);
|
1644
|
+
CZMQ_EXPORT int zsocket_type (void *zocket);
|
1645
|
+
CZMQ_EXPORT int zsocket_rcvmore (void *zocket);
|
1646
|
+
CZMQ_EXPORT int zsocket_fd (void *zocket);
|
1647
|
+
CZMQ_EXPORT int zsocket_events (void *zocket);
|
1648
|
+
|
1649
|
+
// Set socket options
|
1650
|
+
CZMQ_EXPORT void zsocket_set_hwm (void *zocket, int hwm);
|
1651
|
+
CZMQ_EXPORT void zsocket_set_swap (void *zocket, int swap);
|
1652
|
+
CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity);
|
1653
|
+
CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity);
|
1654
|
+
CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate);
|
1655
|
+
CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl);
|
1656
|
+
CZMQ_EXPORT void zsocket_set_recovery_ivl_msec (void *zocket, int recovery_ivl_msec);
|
1657
|
+
CZMQ_EXPORT void zsocket_set_mcast_loop (void *zocket, int mcast_loop);
|
1658
|
+
# if (ZMQ_VERSION_MINOR == 2)
|
1659
|
+
CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo);
|
1660
|
+
# endif
|
1661
|
+
# if (ZMQ_VERSION_MINOR == 2)
|
1662
|
+
CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo);
|
1663
|
+
# endif
|
1664
|
+
CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf);
|
1665
|
+
CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf);
|
1666
|
+
CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger);
|
1667
|
+
CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl);
|
1668
|
+
CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max);
|
1669
|
+
CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog);
|
1670
|
+
CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe);
|
1671
|
+
CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe);
|
1672
|
+
#endif
|
1673
|
+
|
1674
|
+
// Self test of this class
|
1675
|
+
int zsockopt_test (bool verbose);
|
1676
|
+
|
1677
|
+
This class is generated, using the GSL code generator. See the sockopts
|
1678
|
+
XML file, which provides the metadata, and the sockopts.gsl template,
|
1679
|
+
which does the work.
|
1680
|
+
|
1681
|
+
<A name="toc4-342" title="zstr - sending and receiving strings" />
|
1682
|
+
#### zstr - sending and receiving strings
|
1683
|
+
|
1684
|
+
The zstr class provides utility functions for sending and receiving C
|
1685
|
+
strings across ØMQ sockets. It sends strings without a terminating null,
|
1686
|
+
and appends a null byte on received strings. This class is for simple
|
1687
|
+
message sending.
|
1688
|
+
|
1689
|
+
<center>
|
1690
|
+
<img src="https://github.com/zeromq/czmq/raw/master/images/README_2.png" alt="2">
|
1691
|
+
</center>
|
1692
|
+
|
1693
|
+
This is the class interface:
|
1694
|
+
|
1695
|
+
// Receive a string off a socket, caller must free it
|
1696
|
+
CZMQ_EXPORT char *
|
1697
|
+
zstr_recv (void *socket);
|
1698
|
+
|
1699
|
+
// Receive a string off a socket if socket had input waiting
|
1700
|
+
CZMQ_EXPORT char *
|
1701
|
+
zstr_recv_nowait (void *socket);
|
1702
|
+
|
1703
|
+
// Send a formatted string to a socket
|
1704
|
+
CZMQ_EXPORT int
|
1705
|
+
zstr_send (void *socket, const char *format, ...);
|
1706
|
+
|
1707
|
+
// Send a formatted string to a socket, with MORE flag
|
1708
|
+
CZMQ_EXPORT int
|
1709
|
+
zstr_sendm (void *socket, const char *format, ...);
|
1710
|
+
|
1711
|
+
// Send a series of strings (until NULL) as multipart data
|
1712
|
+
// Returns 0 if the strings could be sent OK, or -1 on error.
|
1713
|
+
CZMQ_EXPORT int
|
1714
|
+
zstr_sendx (void *socket, const char *string, ...);
|
1715
|
+
|
1716
|
+
// Receive a series of strings (until NULL) from multipart data
|
1717
|
+
// Each string is allocated and filled with string data; if there
|
1718
|
+
// are not enough frames, unallocated strings are set to NULL.
|
1719
|
+
// Returns -1 if the message could not be read, else returns the
|
1720
|
+
// number of strings filled, zero or more.
|
1721
|
+
CZMQ_EXPORT int
|
1722
|
+
zstr_recvx (void *socket, char **string_p, ...);
|
1723
|
+
|
1724
|
+
// Self test of this class
|
1725
|
+
CZMQ_EXPORT int
|
1726
|
+
zstr_test (bool verbose);
|
1727
|
+
|
1728
|
+
|
1729
|
+
<A name="toc4-367" title="zsys - system-level methods" />
|
1730
|
+
#### zsys - system-level methods
|
676
1731
|
|
677
|
-
The
|
678
|
-
|
679
|
-
|
680
|
-
|
1732
|
+
The zsys class provides a portable wrapper for miscellaneous functions
|
1733
|
+
that we want to wrap but which don't fit into any of the existing
|
1734
|
+
classes. Eventually all non-portable functionality might be moved here
|
1735
|
+
but for now it covers only file systems.
|
681
1736
|
|
682
1737
|
This is the class interface:
|
683
1738
|
|
684
|
-
// Callback
|
685
|
-
typedef
|
1739
|
+
// Callback for interrupt signal handler
|
1740
|
+
typedef void (zsys_handler_fn) (int signal_value);
|
686
1741
|
|
687
|
-
//
|
688
|
-
CZMQ_EXPORT
|
689
|
-
|
1742
|
+
// Set interrupt handler (NULL means external handler)
|
1743
|
+
CZMQ_EXPORT void
|
1744
|
+
zsys_handler_set (zsys_handler_fn *handler_fn);
|
690
1745
|
|
691
|
-
//
|
1746
|
+
// Reset interrupt handler, call this at exit if needed
|
692
1747
|
CZMQ_EXPORT void
|
693
|
-
|
1748
|
+
zsys_handler_reset (void);
|
694
1749
|
|
695
|
-
//
|
696
|
-
//
|
697
|
-
//
|
698
|
-
|
1750
|
+
// Set network interface name to use for broadcasts
|
1751
|
+
// Use this to force the interface for beacons
|
1752
|
+
// This is experimental; may be merged into zbeacon class.
|
1753
|
+
CZMQ_EXPORT void
|
1754
|
+
zsys_set_interface (char *iinterface);
|
1755
|
+
|
1756
|
+
// Return network interface name to use for broadcasts.
|
1757
|
+
// Returns "" if no interface was set.
|
1758
|
+
// This is experimental; may be merged into zbeacon class.
|
1759
|
+
CZMQ_EXPORT char *
|
1760
|
+
zsys_interface (void);
|
1761
|
+
|
1762
|
+
// Return 1 if file exists, else zero
|
1763
|
+
CZMQ_EXPORT bool
|
1764
|
+
zsys_file_exists (const char *filename);
|
1765
|
+
|
1766
|
+
// Return size of file, or -1 if not found
|
1767
|
+
CZMQ_EXPORT ssize_t
|
1768
|
+
zsys_file_size (const char *filename);
|
1769
|
+
|
1770
|
+
// Return file modification time. Returns 0 if the file does not exist.
|
1771
|
+
CZMQ_EXPORT time_t
|
1772
|
+
zsys_file_modified (const char *filename);
|
1773
|
+
|
1774
|
+
// Return file mode
|
1775
|
+
CZMQ_EXPORT mode_t
|
1776
|
+
zsys_file_mode (const char *filename);
|
1777
|
+
|
1778
|
+
// Delete file. Does not complain if the file is absent
|
699
1779
|
CZMQ_EXPORT int
|
700
|
-
|
1780
|
+
zsys_file_delete (const char *filename);
|
701
1781
|
|
702
|
-
//
|
703
|
-
|
704
|
-
|
705
|
-
CZMQ_EXPORT void
|
706
|
-
zloop_poller_end (zloop_t *self, zmq_pollitem_t *item);
|
1782
|
+
// Check if file is 'stable'
|
1783
|
+
CZMQ_EXPORT bool
|
1784
|
+
zsys_file_stable (const char *filename);
|
707
1785
|
|
708
|
-
//
|
709
|
-
//
|
710
|
-
// run a timer forever, use 0 times. Returns 0 if OK, -1 if there was an
|
711
|
-
// error.
|
1786
|
+
// Create a file path if it doesn't exist. The file path is treated as a
|
1787
|
+
// printf format.
|
712
1788
|
CZMQ_EXPORT int
|
713
|
-
|
1789
|
+
zsys_dir_create (const char *pathname, ...);
|
714
1790
|
|
715
|
-
//
|
1791
|
+
// Remove a file path if empty; the pathname is treated as printf format.
|
716
1792
|
CZMQ_EXPORT int
|
717
|
-
|
1793
|
+
zsys_dir_delete (const char *pathname, ...);
|
718
1794
|
|
719
|
-
// Set
|
1795
|
+
// Set private file creation mode; all files created from here will be
|
1796
|
+
// readable/writable by the owner only.
|
720
1797
|
CZMQ_EXPORT void
|
721
|
-
|
1798
|
+
zsys_file_mode_private (void);
|
722
1799
|
|
723
|
-
//
|
724
|
-
//
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
1800
|
+
// Reset default file creation mode; all files created from here will use
|
1801
|
+
// process file mode defaults.
|
1802
|
+
CZMQ_EXPORT void
|
1803
|
+
zsys_file_mode_default (void);
|
1804
|
+
|
1805
|
+
// Format a string with variable arguments, returning a freshly allocated
|
1806
|
+
// buffer. If there was insufficient memory, returns NULL.
|
1807
|
+
CZMQ_EXPORT char *
|
1808
|
+
zsys_vprintf (const char *format, va_list argptr);
|
729
1809
|
|
730
1810
|
// Self test of this class
|
731
|
-
|
732
|
-
|
1811
|
+
CZMQ_EXPORT int
|
1812
|
+
zsys_test (bool verbose);
|
733
1813
|
|
734
1814
|
|
735
|
-
<A name="toc4-
|
1815
|
+
<A name="toc4-378" title="zthread - working with system threads" />
|
736
1816
|
#### zthread - working with system threads
|
737
1817
|
|
738
1818
|
The zthread class wraps OS thread creation. It creates detached threads
|
@@ -762,7 +1842,7 @@ This is the class interface:
|
|
762
1842
|
zthread_fork (zctx_t *ctx, zthread_attached_fn *thread_fn, void *args);
|
763
1843
|
|
764
1844
|
// Self test of this class
|
765
|
-
int
|
1845
|
+
CZMQ_EXPORT int
|
766
1846
|
zthread_test (bool verbose);
|
767
1847
|
|
768
1848
|
We have several use cases for multiple threads. One is to simulate many
|
@@ -798,249 +1878,106 @@ If you want to communicate over ipc:// or tcp:// you may be sharing
|
|
798
1878
|
the same context, or use separate contexts. Thus, every detached thread
|
799
1879
|
usually starts by creating its own zctx_t instance.
|
800
1880
|
|
801
|
-
<A name="toc4-
|
802
|
-
####
|
1881
|
+
<A name="toc4-389" title="ztree - generic red-black tree container" />
|
1882
|
+
#### ztree - generic red-black tree container
|
803
1883
|
|
804
|
-
|
1884
|
+
Red black tree container
|
1885
|
+
Derived from Emin Martianan's Red Black which is licensed for free use.
|
1886
|
+
http://web.mit.edu/~emin/www.old/source_code/red_black_tree/index.html
|
805
1887
|
|
806
1888
|
This is the class interface:
|
807
1889
|
|
808
|
-
// Callback function for
|
809
|
-
typedef int (
|
810
|
-
// Callback function for zhash_freefn method
|
811
|
-
typedef void (zhash_free_fn) (void *data);
|
1890
|
+
// Callback function for ztee_walk method
|
1891
|
+
typedef int (ztree_walk_fn) (const char *key, void *value, void *argument);
|
812
1892
|
|
813
|
-
//
|
814
|
-
|
815
|
-
zhash_new (void);
|
1893
|
+
// Callback function for ztree_freefn method
|
1894
|
+
typedef void (ztree_free_fn) (void *data);
|
816
1895
|
|
817
|
-
//
|
1896
|
+
// Comparison function for ztree ordering
|
1897
|
+
// returns -1 for key1 < key2, 0 if key1 == key 2, 1 for key1 > key2
|
1898
|
+
// if key's are strings okay to use strcmp as function
|
1899
|
+
typedef int (ztree_compare_fn) (const char *key1, const char *key2);
|
1900
|
+
|
1901
|
+
// Create a new tree container
|
1902
|
+
CZMQ_EXPORT ztree_t *
|
1903
|
+
ztree_new (ztree_compare_fn *compare_func);
|
1904
|
+
|
1905
|
+
// Destroy a tree container
|
818
1906
|
CZMQ_EXPORT void
|
819
|
-
|
1907
|
+
ztree_destroy (ztree_t **self_p);
|
820
1908
|
|
821
|
-
// Insert
|
822
|
-
// If key is already present returns -1 and leaves existing
|
1909
|
+
// Insert node into tree with specified key and value
|
1910
|
+
// If key is already present returns -1 and leaves existing node unchanged
|
823
1911
|
// Returns 0 on success.
|
824
1912
|
CZMQ_EXPORT int
|
825
|
-
|
1913
|
+
ztree_insert (ztree_t *self, const char *key, void *value);
|
826
1914
|
|
827
|
-
// Update
|
828
|
-
// If key is already present, destroys old
|
829
|
-
// Use free_fn method to ensure deallocator is properly called on
|
1915
|
+
// Update node in tree with specified key and value.
|
1916
|
+
// If key is already present, destroys old value and inserts new one.
|
1917
|
+
// Use free_fn method to ensure deallocator is properly called on value.
|
830
1918
|
CZMQ_EXPORT void
|
831
|
-
|
1919
|
+
ztree_update (ztree_t *self, const char *key, void *value);
|
832
1920
|
|
833
|
-
// Remove
|
834
|
-
//
|
1921
|
+
// Remove a node specified by key from the tree. If there was no such
|
1922
|
+
// node, this function does nothing.
|
835
1923
|
CZMQ_EXPORT void
|
836
|
-
|
1924
|
+
ztree_delete (ztree_t *self, const char *key);
|
837
1925
|
|
838
|
-
// Return the
|
1926
|
+
// Return the value at the specified key, or null
|
839
1927
|
CZMQ_EXPORT void *
|
840
|
-
|
841
|
-
|
842
|
-
// Reindexes an item from an old key to a new key. If there was no such
|
843
|
-
// item, does nothing. Returns 0 if successful, else -1.
|
844
|
-
CZMQ_EXPORT int
|
845
|
-
zhash_rename (zhash_t *self, const char *old_key, const char *new_key);
|
1928
|
+
ztree_lookup (ztree_t *self, const char *key);
|
846
1929
|
|
847
|
-
// Set a free function for the specified
|
848
|
-
// destroyed, the free function, if any, is called on that
|
849
|
-
// Use this when
|
1930
|
+
// Set a free function for the specified tree node. When the value is
|
1931
|
+
// destroyed, the free function, if any, is called on that node.
|
1932
|
+
// Use this when tree values are dynamically allocated, to ensure that
|
850
1933
|
// you don't have memory leaks. You can pass 'free' or NULL as a free_fn.
|
851
1934
|
// Returns the item, or NULL if there is no such item.
|
852
1935
|
CZMQ_EXPORT void *
|
853
|
-
|
1936
|
+
ztree_freefn (ztree_t *self, const char *key, ztree_free_fn *free_fn);
|
854
1937
|
|
855
|
-
// Return the number of keys/
|
1938
|
+
// Return the number of keys/values in the tree
|
856
1939
|
CZMQ_EXPORT size_t
|
857
|
-
|
858
|
-
|
859
|
-
// Make copy of hash table
|
860
|
-
CZMQ_EXPORT zhash_t *
|
861
|
-
zhash_dup (zhash_t *self);
|
1940
|
+
ztree_size (ztree_t *self);
|
862
1941
|
|
863
|
-
// Return keys for
|
1942
|
+
// Return keys for nodes in tree
|
864
1943
|
CZMQ_EXPORT zlist_t *
|
865
|
-
|
866
|
-
|
867
|
-
//
|
868
|
-
|
869
|
-
|
1944
|
+
ztree_keys (ztree_t *self);
|
1945
|
+
|
1946
|
+
// Copy the entire tree, return the copy
|
1947
|
+
CZMQ_EXPORT ztree_t *
|
1948
|
+
ztree_dup (ztree_t *self);
|
1949
|
+
|
1950
|
+
// Walk the tree depth-first, left-to-right order.
|
1951
|
+
// Stops if callback function returns non-zero and returns
|
1952
|
+
// final return code from callback function (zero = success).
|
870
1953
|
CZMQ_EXPORT int
|
871
|
-
|
1954
|
+
ztree_walk (ztree_t *self, ztree_walk_fn *callback, void *argument);
|
872
1955
|
|
873
|
-
// Save
|
1956
|
+
// Save tree to a text file in name=value format. Values must be
|
874
1957
|
// printable strings; keys may not contain '=' character. Returns 0 if OK,
|
875
1958
|
// else -1 if a file error occurred.
|
876
1959
|
CZMQ_EXPORT int
|
877
|
-
|
1960
|
+
ztree_save (ztree_t *self, const char *filename);
|
878
1961
|
|
879
|
-
// Load
|
880
|
-
// already exist.
|
1962
|
+
// Load tree from a text file in name=value format; tree must
|
1963
|
+
// already exist. Tree values must printable strings; keys may not contain
|
881
1964
|
// '=' character. Returns 0 if OK, else -1 if a file was not readable.
|
882
1965
|
CZMQ_EXPORT int
|
883
|
-
|
884
|
-
|
885
|
-
// Set hash for automatic value destruction
|
886
|
-
CZMQ_EXPORT void
|
887
|
-
zhash_autofree (zhash_t *self);
|
888
|
-
|
889
|
-
// Self test of this class
|
890
|
-
void
|
891
|
-
zhash_test (int verbose);
|
892
|
-
|
893
|
-
Note that it's relatively slow (~50k insertions/deletes per second), so
|
894
|
-
don't do inserts/updates on the critical path for message I/O. It can
|
895
|
-
do ~2.5M lookups per second for 16-char keys. Timed on a 1.6GHz CPU.
|
896
|
-
|
897
|
-
<A name="toc4-240" title="zlist - singly-linked list container" />
|
898
|
-
#### zlist - singly-linked list container
|
899
|
-
|
900
|
-
Provides a generic container implementing a fast singly-linked list. You
|
901
|
-
can use this to construct multi-dimensional lists, and other structures
|
902
|
-
together with other generic containers like zhash.
|
903
|
-
|
904
|
-
This is the class interface:
|
905
|
-
|
906
|
-
// Comparison function for zlist_sort method
|
907
|
-
typedef bool (zlist_compare_fn) (void *item1, void *item2);
|
908
|
-
|
909
|
-
// Create a new list container
|
910
|
-
CZMQ_EXPORT zlist_t *
|
911
|
-
zlist_new (void);
|
912
|
-
|
913
|
-
// Destroy a list container
|
914
|
-
CZMQ_EXPORT void
|
915
|
-
zlist_destroy (zlist_t **self_p);
|
916
|
-
|
917
|
-
// Return first item in the list, or null
|
918
|
-
CZMQ_EXPORT void *
|
919
|
-
zlist_first (zlist_t *self);
|
920
|
-
|
921
|
-
// Return last item in the list, or null
|
922
|
-
CZMQ_EXPORT void *
|
923
|
-
zlist_last (zlist_t *self);
|
924
|
-
|
925
|
-
// Return first item in the list, or null, leaves the cursor
|
926
|
-
CZMQ_EXPORT void *
|
927
|
-
zlist_head (zlist_t *self);
|
928
|
-
|
929
|
-
// Return last item in the list, or null, leaves the cursor
|
930
|
-
CZMQ_EXPORT void *
|
931
|
-
zlist_tail (zlist_t *self);
|
932
|
-
|
933
|
-
// Return next item in the list, or null
|
934
|
-
CZMQ_EXPORT void *
|
935
|
-
zlist_next (zlist_t *self);
|
936
|
-
|
937
|
-
// Append an item to the end of the list
|
938
|
-
CZMQ_EXPORT int
|
939
|
-
zlist_append (zlist_t *self, void *item);
|
940
|
-
|
941
|
-
// Push an item to the start of the list
|
942
|
-
CZMQ_EXPORT int
|
943
|
-
zlist_push (zlist_t *self, void *item);
|
944
|
-
|
945
|
-
// Pop the item off the start of the list, if any
|
946
|
-
CZMQ_EXPORT void *
|
947
|
-
zlist_pop (zlist_t *self);
|
948
|
-
|
949
|
-
// Remove the specified item from the list if present
|
950
|
-
CZMQ_EXPORT void
|
951
|
-
zlist_remove (zlist_t *self, void *item);
|
952
|
-
|
953
|
-
// Copy the entire list, return the copy
|
954
|
-
CZMQ_EXPORT zlist_t *
|
955
|
-
zlist_dup (zlist_t *self);
|
956
|
-
|
957
|
-
// Copy the entire list, return the copy (deprecated)
|
958
|
-
CZMQ_EXPORT zlist_t *
|
959
|
-
zlist_copy (zlist_t *self);
|
960
|
-
|
961
|
-
// Return number of items in the list
|
962
|
-
CZMQ_EXPORT size_t
|
963
|
-
zlist_size (zlist_t *self);
|
964
|
-
|
965
|
-
// Sort list
|
966
|
-
CZMQ_EXPORT void
|
967
|
-
zlist_sort (zlist_t *self, zlist_compare_fn *compare);
|
968
|
-
|
969
|
-
// Set list for automatic item destruction
|
970
|
-
CZMQ_EXPORT void
|
971
|
-
zlist_autofree (zlist_t *self);
|
972
|
-
|
973
|
-
// Self test of this class
|
974
|
-
void
|
975
|
-
zlist_test (int verbose);
|
976
|
-
|
977
|
-
|
978
|
-
<A name="toc4-251" title="zclock - millisecond clocks and delays" />
|
979
|
-
#### zclock - millisecond clocks and delays
|
980
|
-
|
981
|
-
The zclock class provides essential sleep and system time functions, used
|
982
|
-
to slow down threads for testing, and calculate timers for polling. Wraps
|
983
|
-
the non-portable system calls in a simple portable API.
|
984
|
-
|
985
|
-
This is the class interface:
|
986
|
-
|
987
|
-
// Sleep for a number of milliseconds
|
988
|
-
CZMQ_EXPORT void
|
989
|
-
zclock_sleep (int msecs);
|
990
|
-
|
991
|
-
// Return current system clock as milliseconds
|
992
|
-
CZMQ_EXPORT int64_t
|
993
|
-
zclock_time (void);
|
1966
|
+
ztree_load (ztree_t *self, const char *filename);
|
994
1967
|
|
995
|
-
//
|
996
|
-
// terminated with a newline.
|
1968
|
+
// Set tree for automatic value destruction
|
997
1969
|
CZMQ_EXPORT void
|
998
|
-
|
1970
|
+
ztree_autofree (ztree_t *self);
|
999
1971
|
|
1000
1972
|
// Self test of this class
|
1001
|
-
int
|
1002
|
-
zclock_test (bool verbose);
|
1003
|
-
|
1004
|
-
The Win32 Sleep() call defaults to 16ms resolution unless the system timer
|
1005
|
-
resolution is increased with a call to timeBeginPeriod() permitting 1ms
|
1006
|
-
granularity.
|
1007
|
-
|
1008
|
-
<A name="toc4-262" title="zmutex - wrap lightweight mutexes" />
|
1009
|
-
#### zmutex - wrap lightweight mutexes
|
1010
|
-
|
1011
|
-
The zmutex class provides a portable wrapper for mutexes. Please do not
|
1012
|
-
use this class to do multi-threading. It is for the rare case where you
|
1013
|
-
absolutely need thread-safe global state. This should happen in system
|
1014
|
-
code only. DO NOT USE THIS TO SHARE SOCKETS BETWEEN THREADS, OR DARK
|
1015
|
-
THINGS WILL HAPPEN TO YOUR CODE.
|
1016
|
-
|
1017
|
-
This is the class interface:
|
1018
|
-
|
1019
|
-
// Create a new mutex container
|
1020
|
-
CZMQ_EXPORT zmutex_t *
|
1021
|
-
zmutex_new (void);
|
1022
|
-
|
1023
|
-
// Destroy a mutex container
|
1024
|
-
CZMQ_EXPORT void
|
1025
|
-
zmutex_destroy (zmutex_t **self_p);
|
1026
|
-
|
1027
|
-
// Lock mutex
|
1028
|
-
CZMQ_EXPORT void
|
1029
|
-
zmutex_lock (zmutex_t *self);
|
1030
|
-
|
1031
|
-
// Unlock mutex
|
1032
1973
|
CZMQ_EXPORT void
|
1033
|
-
|
1034
|
-
|
1035
|
-
// Self test of this class
|
1036
|
-
int
|
1037
|
-
zmutex_test (bool verbose);
|
1974
|
+
ztree_test (int verbose);
|
1038
1975
|
|
1039
1976
|
|
1040
|
-
<A name="toc2-
|
1977
|
+
<A name="toc2-400" title="Under the Hood" />
|
1041
1978
|
## Under the Hood
|
1042
1979
|
|
1043
|
-
<A name="toc3-
|
1980
|
+
<A name="toc3-403" title="Adding a New Class" />
|
1044
1981
|
### Adding a New Class
|
1045
1982
|
|
1046
1983
|
If you define a new CZMQ class `myclass` you need to:
|
@@ -1050,8 +1987,9 @@ If you define a new CZMQ class `myclass` you need to:
|
|
1050
1987
|
* Add the myclass header and test call to `src/czmq_selftest.c`.
|
1051
1988
|
* Add a reference documentation to 'doc/zmyclass.txt'.
|
1052
1989
|
* Add myclass to 'src/Makefile.am` and `doc/Makefile.am`.
|
1990
|
+
* Add a section to README.txt.
|
1053
1991
|
|
1054
|
-
<A name="toc3-
|
1992
|
+
<A name="toc3-415" title="Documentation" />
|
1055
1993
|
### Documentation
|
1056
1994
|
|
1057
1995
|
Man pages are generated from the class header and source files via the doc/mkman tool, and similar functionality in the gitdown tool (http://github.com/imatix/gitdown). The header file for a class must wrap its interface as follows (example is from include/zclock.h):
|
@@ -1090,7 +2028,7 @@ The source file for a class then provides the self test example as follows:
|
|
1090
2028
|
|
1091
2029
|
The template for man pages is in doc/mkman.
|
1092
2030
|
|
1093
|
-
<A name="toc3-
|
2031
|
+
<A name="toc3-454" title="Development" />
|
1094
2032
|
### Development
|
1095
2033
|
|
1096
2034
|
CZMQ is developed through a test-driven process that guarantees no memory violations or leaks in the code:
|
@@ -1100,7 +2038,7 @@ CZMQ is developed through a test-driven process that guarantees no memory violat
|
|
1100
2038
|
* Run the 'selftest' script, which uses the Valgrind memcheck tool.
|
1101
2039
|
* Repeat until perfect.
|
1102
2040
|
|
1103
|
-
<A name="toc3-
|
2041
|
+
<A name="toc3-464" title="Porting CZMQ" />
|
1104
2042
|
### Porting CZMQ
|
1105
2043
|
|
1106
2044
|
When you try CZMQ on an OS that it's not been used on (ever, or for a while), you will hit code that does not compile. In some cases the patches are trivial, in other cases (usually when porting to Windows), the work needed to build equivalent functionality may be non-trivial. In any case, the benefit is that once ported, the functionality is available to all applications.
|
@@ -1111,12 +2049,12 @@ Before attempting to patch code for portability, please read the `czmq_prelude.h
|
|
1111
2049
|
* Defining macros that rename exotic library functions to more conventional names: do this in czmq_prelude.h.
|
1112
2050
|
* Reimplementing specific methods to use a non-standard API: this is typically needed on Windows. Do this in the relevant class, using #ifdefs to properly differentiate code for different platforms.
|
1113
2051
|
|
1114
|
-
<A name="toc3-
|
2052
|
+
<A name="toc3-475" title="Code Generation" />
|
1115
2053
|
### Code Generation
|
1116
2054
|
|
1117
|
-
We generate the zsockopt class using [https://github.com/imatix/gsl GSL].
|
2055
|
+
We generate the zsockopt class using [https://github.com/imatix/gsl GSL], using a code generator script in scripts/sockopts.gsl.
|
1118
2056
|
|
1119
|
-
<A name="toc3-
|
2057
|
+
<A name="toc3-480" title="This Document" />
|
1120
2058
|
### This Document
|
1121
2059
|
|
1122
2060
|
This document is originally at README.txt and is built using [gitdown](http://github.com/imatix/gitdown).
|