Codebase list czmq / b8f2802
Merge tag 'upstream/4.0.2' Upstream version 4.0.2 Luca Boccassi 7 years ago
99 changed file(s) with 15415 addition(s) and 2613 deletion(s). Raw diff Collapse all Expand all
6060 Patrik Wenger
6161 Luca Boccassi
6262 Kouhei Sutou
63 Michal Vyskocil
64 Jim Klimov
65 Michal Hrusecky
66 Alena Chernikava
67 Stephen Procter
241241 set_target_properties(czmq
242242 PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${SOURCE_DIR}/src"
243243 )
244 set_target_properties (czmq
245 PROPERTIES SOVERSION "4.0.2"
246 )
244247 target_link_libraries(czmq
245248 ${ZEROMQ_LIBRARIES} ${MORE_LIBRARIES}
246249 )
256259 ########################################################################
257260 # pkgconfig
258261 ########################################################################
259 set (VERSION "4.0.1")
262 set (VERSION "4.0.2")
260263 set (prefix "${CMAKE_INSTALL_PREFIX}")
261264 set (exec_prefix "\${prefix}")
262265 set (libdir "\${prefix}/lib${LIB_SUFFIX}")
2424 check_PROGRAMS =
2525 noinst_LTLIBRARIES =
2626 TESTS =
27 EXTRA_DIST =
2728
28 EXTRA_DIST = \
29 CMakeLists.txt \
29 if ENABLE_DIST_CMAKEFILES
30 EXTRA_DIST += \
3031 Findlibzmq.cmake \
3132 Finduuid.cmake \
3233 Findsystemd.cmake \
34 src/CMakeLists-local.txt \
35 CMakeLists.txt
36 endif
37
38 EXTRA_DIST += \
3339 src/zsock_option.inc \
3440 src/zgossip_engine.inc \
3541 src/zhash_primes.inc \
4747 noinst_PROGRAMS = $(am__EXEEXT_2)
4848 check_PROGRAMS = $(am__EXEEXT_2)
4949 TESTS =
50 @ENABLE_DIST_CMAKEFILES_TRUE@am__append_1 = \
51 @ENABLE_DIST_CMAKEFILES_TRUE@ Findlibzmq.cmake \
52 @ENABLE_DIST_CMAKEFILES_TRUE@ Finduuid.cmake \
53 @ENABLE_DIST_CMAKEFILES_TRUE@ Findsystemd.cmake \
54 @ENABLE_DIST_CMAKEFILES_TRUE@ src/CMakeLists-local.txt \
55 @ENABLE_DIST_CMAKEFILES_TRUE@ CMakeLists.txt
56
5057 DIST_COMMON = $(am__configure_deps) $(am__include_HEADERS_DIST) \
5158 $(dist_api_DATA) $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
5259 $(srcdir)/src/Makemodule-local.am $(srcdir)/src/Makemodule.am \
5663 config/install-sh config/ltmain.sh config/missing
5764
5865 # Programs need to link the c++ runtime if everything was compiled statically.
59 @ENABLE_SHARED_FALSE@am__append_1 = -lstdc++ -lm
60 @ENABLE_DRAFTS_TRUE@am__append_2 = \
66 @ENABLE_SHARED_FALSE@am__append_2 = -lstdc++ -lm
67 @ENABLE_DRAFTS_TRUE@am__append_3 = \
6168 @ENABLE_DRAFTS_TRUE@ include/zproc.h \
6269 @ENABLE_DRAFTS_TRUE@ include/ztimerset.h \
6370 @ENABLE_DRAFTS_TRUE@ include/ztrie.h
6471
65 @ENABLE_DRAFTS_TRUE@am__append_3 = \
72 @ENABLE_DRAFTS_TRUE@am__append_4 = \
6673 @ENABLE_DRAFTS_TRUE@ src/zproc.c \
6774 @ENABLE_DRAFTS_TRUE@ src/ztimerset.c \
6875 @ENABLE_DRAFTS_TRUE@ src/ztrie.c
6976
70 @ON_MINGW_TRUE@am__append_4 = \
77 @ON_MINGW_TRUE@am__append_5 = \
7178 @ON_MINGW_TRUE@ -no-undefined \
7279 @ON_MINGW_TRUE@ -avoid-version
7380
74 @ON_CYGWIN_TRUE@am__append_5 = \
81 @ON_CYGWIN_TRUE@am__append_6 = \
7582 @ON_CYGWIN_TRUE@ -no-undefined \
7683 @ON_CYGWIN_TRUE@ -avoid-version
7784
78 @ENABLE_ZMAKECERT_TRUE@am__append_6 = src/zmakecert
79 @ENABLE_CZMQ_SELFTEST_TRUE@am__append_7 = src/czmq_selftest
85 @ENABLE_ZMAKECERT_TRUE@am__append_7 = src/zmakecert
8086 @ENABLE_CZMQ_SELFTEST_TRUE@am__append_8 = src/czmq_selftest
87 @ENABLE_CZMQ_SELFTEST_TRUE@am__append_9 = src/czmq_selftest
8188
8289 # Android-qt requires this special link dependency
83 @ON_ANDROID_TRUE@am__append_9 = -llog
90 @ON_ANDROID_TRUE@am__append_10 = -llog
8491 subdir = .
8592 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
8693 am__aclocal_m4_deps = $(top_srcdir)/config/libtool.m4 \
139146 src/zfile.c src/zframe.c src/zhash.c src/zhashx.c \
140147 src/ziflist.c src/zlist.c src/zlistx.c src/zloop.c src/zmsg.c \
141148 src/zpoller.c src/zsock.c src/zstr.c src/zuuid.c src/zauth.c \
142 src/zbeacon.c src/zgossip.c src/zmonitor.c src/zproxy.c \
143 src/zrex.c src/zsys.c src/zgossip_msg.c src/zsock_option.inc \
144 src/zgossip_engine.inc src/zhash_primes.inc \
149 src/zbeacon.c src/zgossip.c src/zgossip_engine.inc \
150 src/zmonitor.c src/zproxy.c src/zrex.c src/zsys.c \
151 src/zgossip_msg.c src/zsock_option.inc src/zhash_primes.inc \
145152 src/foreign/sha1/sha1.inc_c src/foreign/sha1/sha1.h \
146153 src/foreign/slre/slre.inc_c src/foreign/slre/slre.h \
147154 src/foreign/slre/readme.txt src/platform.h src/zproc.c \
443450 DIST_SUBDIRS = doc
444451 lib_LTLIBRARIES = src/libczmq.la
445452 noinst_LTLIBRARIES =
446 EXTRA_DIST = \
447 CMakeLists.txt \
448 Findlibzmq.cmake \
449 Finduuid.cmake \
450 Findsystemd.cmake \
451 src/zsock_option.inc \
452 src/zgossip_engine.inc \
453 src/zhash_primes.inc \
454 src/foreign/sha1/sha1.inc_c \
455 src/foreign/sha1/sha1.h \
456 src/foreign/slre/slre.inc_c \
457 src/foreign/slre/slre.h \
458 src/foreign/slre/readme.txt \
459 src/zgossip_msg.h \
460 LICENSE \
461 README.txt \
462 README.md \
463 CONTRIBUTING.md \
464 src/czmq_classes.h
465
453 EXTRA_DIST = $(am__append_1) src/zsock_option.inc \
454 src/zgossip_engine.inc src/zhash_primes.inc \
455 src/foreign/sha1/sha1.inc_c src/foreign/sha1/sha1.h \
456 src/foreign/slre/slre.inc_c src/foreign/slre/slre.h \
457 src/foreign/slre/readme.txt src/zgossip_msg.h LICENSE \
458 README.txt README.md CONTRIBUTING.md src/czmq_classes.h
466459
467460 ################################################################################
468461 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
469462 # Read the zproject/README.md for information about making permanent changes. #
470463 ################################################################################
471 program_libs = src/libczmq.la ${project_libs} $(am__append_1)
464 program_libs = src/libczmq.la ${project_libs} $(am__append_2)
472465 pkgconfig_DATA = src/libczmq.pc
473466 include_HEADERS = include/czmq_prelude.h include/czmq.h \
474467 include/zactor.h include/zarmour.h include/zcert.h \
481474 include/zstr.h include/zuuid.h include/zauth.h \
482475 include/zbeacon.h include/zgossip.h include/zmonitor.h \
483476 include/zproxy.h include/zrex.h include/zsys.h \
484 include/czmq_library.h $(am__append_2)
477 include/czmq_library.h $(am__append_3)
485478 src_libczmq_la_SOURCES = src/zactor.c src/zarmour.c src/zcert.c \
486479 src/zcertstore.c src/zchunk.c src/zclock.c src/zconfig.c \
487480 src/zdigest.c src/zdir.c src/zdir_patch.c src/zfile.c \
488481 src/zframe.c src/zhash.c src/zhashx.c src/ziflist.c \
489482 src/zlist.c src/zlistx.c src/zloop.c src/zmsg.c src/zpoller.c \
490483 src/zsock.c src/zstr.c src/zuuid.c src/zauth.c src/zbeacon.c \
491 src/zgossip.c src/zmonitor.c src/zproxy.c src/zrex.c \
492 src/zsys.c src/zgossip_msg.c src/zsock_option.inc \
493 src/zgossip_engine.inc src/zhash_primes.inc \
494 src/foreign/sha1/sha1.inc_c src/foreign/sha1/sha1.h \
495 src/foreign/slre/slre.inc_c src/foreign/slre/slre.h \
496 src/foreign/slre/readme.txt src/platform.h $(am__append_3)
484 src/zgossip.c src/zgossip_engine.inc src/zmonitor.c \
485 src/zproxy.c src/zrex.c src/zsys.c src/zgossip_msg.c \
486 src/zsock_option.inc src/zgossip_engine.inc \
487 src/zhash_primes.inc src/foreign/sha1/sha1.inc_c \
488 src/foreign/sha1/sha1.h src/foreign/slre/slre.inc_c \
489 src/foreign/slre/slre.h src/foreign/slre/readme.txt \
490 src/platform.h $(am__append_4)
497491 src_libczmq_la_CPPFLAGS = ${AM_CPPFLAGS}
498492 src_libczmq_la_LDFLAGS = -version-info @LTVER@ \
499 $(LIBTOOL_EXTRA_LDFLAGS) $(am__append_4) $(am__append_5)
500 src_libczmq_la_LIBADD = ${project_libs} $(am__append_9)
493 $(LIBTOOL_EXTRA_LDFLAGS) $(am__append_5) $(am__append_6)
494 src_libczmq_la_LIBADD = ${project_libs} $(am__append_10)
501495 @ENABLE_ZMAKECERT_TRUE@src_zmakecert_CPPFLAGS = ${AM_CPPFLAGS}
502496 @ENABLE_ZMAKECERT_TRUE@src_zmakecert_LDADD = ${program_libs}
503497 @ENABLE_ZMAKECERT_TRUE@src_zmakecert_SOURCES = src/zmakecert.c
0 CZMQ version 4.0.2 stable, released on 2016/12/31
1 =================================================
2
3 * Fixed #1559 - DRAFT zsock_new_*_checked symbols leak
4
5 * Fixed #1560 - zsock options could be available at build time but
6 not at runtime. Added runtime check, an error will
7 be printed if the option is not available.
8
9 * Fixed #1565 - improved compatibility with Solaris/Illumos
10
11 * Fixed #1573 - memory leak when message send fails in internal usage
12
13
014 CZMQ version 4.0.1 stable, released on 2016/11/10
115 =================================================
216
5252 * <a href="#toc4-3682">zlist - simple generic list container</a>
5353 * <a href="#toc4-3948">zlistx - extended generic list container</a>
5454 * <a href="#toc4-4245">zloop - event-driven reactor</a>
55 * <a href="#toc4-4460">zmonitor - socket event monitor</a>
56 * <a href="#toc4-4568">zmsg - working with multipart messages</a>
57 * <a href="#toc4-5062">zpoller - trivial socket poller class</a>
58 * <a href="#toc4-5233">zproc - process configuration and status</a>
59 * <a href="#toc4-5385">zproxy - run a steerable proxy in the background</a>
60 * <a href="#toc4-5736">zrex - work with regular expressions</a>
61 * <a href="#toc4-5875">zsock - high-level socket API that hides libzmq contexts and sockets</a>
62 * <a href="#toc4-7161">zstr - sending and receiving strings</a>
63 * <a href="#toc4-7336">zsys - system-level methods</a>
64 * <a href="#toc4-7823">ztimerset - timer set</a>
65 * <a href="#toc4-7949">ztrie - simple trie for tokenizable strings</a>
66 * <a href="#toc4-8192">zuuid - UUID support class</a>
67
68 **<a href="#toc2-8313">Error Handling</a>**
69
70 **<a href="#toc2-8330">CZMQ Actors</a>**
71
72 **<a href="#toc2-8476">Under the Hood</a>**
73
74 **<a href="#toc3-8479">Adding a New Class</a>**
75
76 **<a href="#toc3-8491">Documentation</a>**
77
78 **<a href="#toc3-8530">Development</a>**
79
80 **<a href="#toc3-8540">Porting CZMQ</a>**
81
82 **<a href="#toc3-8551">Hints to Contributors</a>**
83
84 **<a href="#toc3-8562">Code Generation</a>**
85
86 **<a href="#toc3-8567">This Document</a>**
55 * <a href="#toc4-4455">zmonitor - socket event monitor</a>
56 * <a href="#toc4-4563">zmsg - working with multipart messages</a>
57 * <a href="#toc4-5057">zpoller - trivial socket poller class</a>
58 * <a href="#toc4-5223">zproc - process configuration and status</a>
59 * <a href="#toc4-5375">zproxy - run a steerable proxy in the background</a>
60 * <a href="#toc4-5726">zrex - work with regular expressions</a>
61 * <a href="#toc4-5865">zsock - high-level socket API that hides libzmq contexts and sockets</a>
62 * <a href="#toc4-7281">zstr - sending and receiving strings</a>
63 * <a href="#toc4-7456">zsys - system-level methods</a>
64 * <a href="#toc4-7943">ztimerset - timer set</a>
65 * <a href="#toc4-8069">ztrie - simple trie for tokenizable strings</a>
66 * <a href="#toc4-8312">zuuid - UUID support class</a>
67
68 **<a href="#toc2-8433">Error Handling</a>**
69
70 **<a href="#toc2-8450">CZMQ Actors</a>**
71
72 **<a href="#toc2-8596">Under the Hood</a>**
73
74 **<a href="#toc3-8599">Adding a New Class</a>**
75
76 **<a href="#toc3-8611">Documentation</a>**
77
78 **<a href="#toc3-8650">Development</a>**
79
80 **<a href="#toc3-8660">Porting CZMQ</a>**
81
82 **<a href="#toc3-8671">Hints to Contributors</a>**
83
84 **<a href="#toc3-8682">Code Generation</a>**
85
86 **<a href="#toc3-8687">This Document</a>**
8787
8888 <A name="toc2-21" title="Overview" />
8989 ## Overview
151151 # only execute this next line if interested in updating the man pages as well (adds to build time):
152152 sudo apt-get install -y asciidoc
153153
154 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 libzmq (ZeroMQ core) library:
154 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 libzmq (ZeroMQ core) library (NOTE: skip ldconfig on OSX):
155155
156156 git clone git://github.com/zeromq/libzmq.git
157157 cd libzmq
43004300 ```h
43014301 // This is a stable class, and may not change except for emergencies. It
43024302 // is provided in stable builds.
4303 // This class has draft methods, which may change over time. They are not
4304 // in stable releases, by default. Use --enable-drafts to enable.
43054303 // Callback function for reactor socket activity
43064304 typedef int (zloop_reader_fn) (
43074305 zloop_t *loop, zsock_t *reader, void *arg);
44114409 CZMQ_EXPORT void
44124410 zloop_set_verbose (zloop_t *self, bool verbose);
44134411
4412 // By default the reactor stops if the process receives a SIGINT or SIGTERM
4413 // signal. This makes it impossible to shut-down message based architectures
4414 // like zactors. This method lets you switch off break handling. The default
4415 // nonstop setting is off (false).
4416 CZMQ_EXPORT void
4417 zloop_set_nonstop (zloop_t *self, bool nonstop);
4418
44144419 // Start the reactor. Takes control of the thread and returns when the ØMQ
44154420 // context is terminated or the process is interrupted, or any event handler
44164421 // returns -1. Event handlers may register new sockets and timers, and
44224427 CZMQ_EXPORT void
44234428 zloop_test (bool verbose);
44244429
4425 #ifdef CZMQ_BUILD_DRAFT_API
4426 // *** Draft method, for development use, may change without warning ***
4427 // By default the reactor stops if the process receives a SIGINT or SIGTERM
4428 // signal. This makes it impossible to shut-down message based architectures
4429 // like zactors. This method lets you switch off break handling. The default
4430 // nonstop setting is off (false).
4431 CZMQ_EXPORT void
4432 zloop_set_nonstop (zloop_t *self, bool nonstop);
4433
4434 #endif // CZMQ_BUILD_DRAFT_API
44354430 ```
44364431
44374432 This is the class self test code:
45004495 zsock_destroy (&output);
45014496 ```
45024497
4503 <A name="toc4-4460" title="zmonitor - socket event monitor" />
4498 <A name="toc4-4455" title="zmonitor - socket event monitor" />
45044499 #### zmonitor - socket event monitor
45054500
45064501 The zmonitor actor provides an API for obtaining socket events such as
46084603 #endif
46094604 ```
46104605
4611 <A name="toc4-4568" title="zmsg - working with multipart messages" />
4606 <A name="toc4-4563" title="zmsg - working with multipart messages" />
46124607 #### zmsg - working with multipart messages
46134608
46144609 The zmsg class provides methods to send and receive multipart messages
51025097 #endif
51035098 ```
51045099
5105 <A name="toc4-5062" title="zpoller - trivial socket poller class" />
5100 <A name="toc4-5057" title="zpoller - trivial socket poller class" />
51065101 #### zpoller - trivial socket poller class
51075102
51085103 The zpoller class provides a minimalist interface to ZeroMQ's zmq_poll
51185113 ```h
51195114 // This is a stable class, and may not change except for emergencies. It
51205115 // is provided in stable builds.
5121 // This class has draft methods, which may change over time. They are not
5122 // in stable releases, by default. Use --enable-drafts to enable.
51235116 // Create new poller, specifying zero or more readers. The list of
51245117 // readers ends in a NULL. Each reader can be a zsock_t instance, a
51255118 // zactor_t instance, a libzmq socket (void *), or a file handle.
51395132 // must have been passed during construction, or in an zpoller_add () call.
51405133 CZMQ_EXPORT int
51415134 zpoller_remove (zpoller_t *self, void *reader);
5135
5136 // By default the poller stops if the process receives a SIGINT or SIGTERM
5137 // signal. This makes it impossible to shut-down message based architectures
5138 // like zactors. This method lets you switch off break handling. The default
5139 // nonstop setting is off (false).
5140 CZMQ_EXPORT void
5141 zpoller_set_nonstop (zpoller_t *self, bool nonstop);
51425142
51435143 // Poll the registered readers for I/O, return first reader that has input.
51445144 // The reader will be a libzmq void * socket, or a zsock_t or zactor_t
51665166 CZMQ_EXPORT void
51675167 zpoller_test (bool verbose);
51685168
5169 #ifdef CZMQ_BUILD_DRAFT_API
5170 // *** Draft method, for development use, may change without warning ***
5171 // By default the poller stops if the process receives a SIGINT or SIGTERM
5172 // signal. This makes it impossible to shut-down message based architectures
5173 // like zactors. This method lets you switch off break handling. The default
5174 // nonstop setting is off (false).
5175 CZMQ_EXPORT void
5176 zpoller_set_nonstop (zpoller_t *self, bool nonstop);
5177
5178 #endif // CZMQ_BUILD_DRAFT_API
51795169 ```
51805170
51815171 This is the class self test code:
52735263 #endif
52745264 ```
52755265
5276 <A name="toc4-5233" title="zproc - process configuration and status" />
5266 <A name="toc4-5223" title="zproc - process configuration and status" />
52775267 #### zproc - process configuration and status
52785268
52795269 zproc - process configuration and status
54255415
54265416 Please add @selftest section in ../src/zproc.c.
54275417
5428 <A name="toc4-5385" title="zproxy - run a steerable proxy in the background" />
5418 <A name="toc4-5375" title="zproxy - run a steerable proxy in the background" />
54295419 #### zproxy - run a steerable proxy in the background
54305420
54315421 A zproxy actor switches messages between a frontend and a backend socket.
57765766 #endif
57775767 ```
57785768
5779 <A name="toc4-5736" title="zrex - work with regular expressions" />
5769 <A name="toc4-5726" title="zrex - work with regular expressions" />
57805770 #### zrex - work with regular expressions
57815771
57825772 Wraps a very simple regular expression library (SLRE) as a CZMQ class.
59155905
59165906 ```
59175907
5918 <A name="toc4-5875" title="zsock - high-level socket API that hides libzmq contexts and sockets" />
5908 <A name="toc4-5865" title="zsock - high-level socket API that hides libzmq contexts and sockets" />
59195909 #### zsock - high-level socket API that hides libzmq contexts and sockets
59205910
59215911 The zsock class wraps the libzmq socket handle (a void *) with a proper
62006190 zsock_resolve (void *self);
62016191
62026192 // Get socket option `heartbeat_ivl`.
6193 // Available from libzmq 4.2.0.
62036194 // Caller owns return value and must destroy it when done.
62046195 CZMQ_EXPORT int
62056196 zsock_heartbeat_ivl (void *self);
62066197
62076198 // Set socket option `heartbeat_ivl`.
6199 // Available from libzmq 4.2.0.
62086200 CZMQ_EXPORT void
62096201 zsock_set_heartbeat_ivl (void *self, int heartbeat_ivl);
62106202
62116203 // Get socket option `heartbeat_ttl`.
6204 // Available from libzmq 4.2.0.
62126205 // Caller owns return value and must destroy it when done.
62136206 CZMQ_EXPORT int
62146207 zsock_heartbeat_ttl (void *self);
62156208
62166209 // Set socket option `heartbeat_ttl`.
6210 // Available from libzmq 4.2.0.
62176211 CZMQ_EXPORT void
62186212 zsock_set_heartbeat_ttl (void *self, int heartbeat_ttl);
62196213
62206214 // Get socket option `heartbeat_timeout`.
6215 // Available from libzmq 4.2.0.
62216216 // Caller owns return value and must destroy it when done.
62226217 CZMQ_EXPORT int
62236218 zsock_heartbeat_timeout (void *self);
62246219
62256220 // Set socket option `heartbeat_timeout`.
6221 // Available from libzmq 4.2.0.
62266222 CZMQ_EXPORT void
62276223 zsock_set_heartbeat_timeout (void *self, int heartbeat_timeout);
62286224
6229 // Get socket option `use_fd`.
6225 // Get socket option `use_fd`.
6226 // Available from libzmq 4.2.0.
62306227 // Caller owns return value and must destroy it when done.
62316228 CZMQ_EXPORT int
62326229 zsock_use_fd (void *self);
62336230
6234 // Set socket option `use_fd`.
6231 // Set socket option `use_fd`.
6232 // Available from libzmq 4.2.0.
62356233 CZMQ_EXPORT void
62366234 zsock_set_use_fd (void *self, int use_fd);
62376235
62386236 // Set socket option `xpub_manual`.
6237 // Available from libzmq 4.2.0.
62396238 CZMQ_EXPORT void
62406239 zsock_set_xpub_manual (void *self, int xpub_manual);
62416240
62426241 // Set socket option `xpub_welcome_msg`.
6242 // Available from libzmq 4.2.0.
62436243 CZMQ_EXPORT void
62446244 zsock_set_xpub_welcome_msg (void *self, const char *xpub_welcome_msg);
62456245
62466246 // Set socket option `stream_notify`.
6247 // Available from libzmq 4.2.0.
62476248 CZMQ_EXPORT void
62486249 zsock_set_stream_notify (void *self, int stream_notify);
62496250
62506251 // Get socket option `invert_matching`.
6252 // Available from libzmq 4.2.0.
62516253 // Caller owns return value and must destroy it when done.
62526254 CZMQ_EXPORT int
62536255 zsock_invert_matching (void *self);
62546256
62556257 // Set socket option `invert_matching`.
6258 // Available from libzmq 4.2.0.
62566259 CZMQ_EXPORT void
62576260 zsock_set_invert_matching (void *self, int invert_matching);
62586261
62596262 // Set socket option `xpub_verboser`.
6263 // Available from libzmq 4.2.0.
62606264 CZMQ_EXPORT void
62616265 zsock_set_xpub_verboser (void *self, int xpub_verboser);
62626266
62636267 // Get socket option `connect_timeout`.
6268 // Available from libzmq 4.2.0.
62646269 // Caller owns return value and must destroy it when done.
62656270 CZMQ_EXPORT int
62666271 zsock_connect_timeout (void *self);
62676272
62686273 // Set socket option `connect_timeout`.
6274 // Available from libzmq 4.2.0.
62696275 CZMQ_EXPORT void
62706276 zsock_set_connect_timeout (void *self, int connect_timeout);
62716277
62726278 // Get socket option `tcp_maxrt`.
6279 // Available from libzmq 4.2.0.
62736280 // Caller owns return value and must destroy it when done.
62746281 CZMQ_EXPORT int
62756282 zsock_tcp_maxrt (void *self);
62766283
62776284 // Set socket option `tcp_maxrt`.
6285 // Available from libzmq 4.2.0.
62786286 CZMQ_EXPORT void
62796287 zsock_set_tcp_maxrt (void *self, int tcp_maxrt);
62806288
62816289 // Get socket option `thread_safe`.
6290 // Available from libzmq 4.2.0.
62826291 // Caller owns return value and must destroy it when done.
62836292 CZMQ_EXPORT int
62846293 zsock_thread_safe (void *self);
62856294
62866295 // Get socket option `multicast_maxtpdu`.
6296 // Available from libzmq 4.2.0.
62876297 // Caller owns return value and must destroy it when done.
62886298 CZMQ_EXPORT int
62896299 zsock_multicast_maxtpdu (void *self);
62906300
62916301 // Set socket option `multicast_maxtpdu`.
6302 // Available from libzmq 4.2.0.
62926303 CZMQ_EXPORT void
62936304 zsock_set_multicast_maxtpdu (void *self, int multicast_maxtpdu);
62946305
62956306 // Get socket option `vmci_buffer_size`.
6307 // Available from libzmq 4.2.0.
62966308 // Caller owns return value and must destroy it when done.
62976309 CZMQ_EXPORT int
62986310 zsock_vmci_buffer_size (void *self);
62996311
63006312 // Set socket option `vmci_buffer_size`.
6313 // Available from libzmq 4.2.0.
63016314 CZMQ_EXPORT void
63026315 zsock_set_vmci_buffer_size (void *self, int vmci_buffer_size);
63036316
63046317 // Get socket option `vmci_buffer_min_size`.
6318 // Available from libzmq 4.2.0.
63056319 // Caller owns return value and must destroy it when done.
63066320 CZMQ_EXPORT int
63076321 zsock_vmci_buffer_min_size (void *self);
63086322
63096323 // Set socket option `vmci_buffer_min_size`.
6324 // Available from libzmq 4.2.0.
63106325 CZMQ_EXPORT void
63116326 zsock_set_vmci_buffer_min_size (void *self, int vmci_buffer_min_size);
63126327
63136328 // Get socket option `vmci_buffer_max_size`.
6329 // Available from libzmq 4.2.0.
63146330 // Caller owns return value and must destroy it when done.
63156331 CZMQ_EXPORT int
63166332 zsock_vmci_buffer_max_size (void *self);
63176333
63186334 // Set socket option `vmci_buffer_max_size`.
6335 // Available from libzmq 4.2.0.
63196336 CZMQ_EXPORT void
63206337 zsock_set_vmci_buffer_max_size (void *self, int vmci_buffer_max_size);
63216338
63226339 // Get socket option `vmci_connect_timeout`.
6340 // Available from libzmq 4.2.0.
63236341 // Caller owns return value and must destroy it when done.
63246342 CZMQ_EXPORT int
63256343 zsock_vmci_connect_timeout (void *self);
63266344
63276345 // Set socket option `vmci_connect_timeout`.
6346 // Available from libzmq 4.2.0.
63286347 CZMQ_EXPORT void
63296348 zsock_set_vmci_connect_timeout (void *self, int vmci_connect_timeout);
63306349
6331 // Get socket option `tos`.
6350 // Get socket option `tos`.
6351 // Available from libzmq 4.1.0.
63326352 // Caller owns return value and must destroy it when done.
63336353 CZMQ_EXPORT int
63346354 zsock_tos (void *self);
63356355
6336 // Set socket option `tos`.
6356 // Set socket option `tos`.
6357 // Available from libzmq 4.1.0.
63376358 CZMQ_EXPORT void
63386359 zsock_set_tos (void *self, int tos);
63396360
63406361 // Set socket option `router_handover`.
6362 // Available from libzmq 4.1.0.
63416363 CZMQ_EXPORT void
63426364 zsock_set_router_handover (void *self, int router_handover);
63436365
63446366 // Set socket option `connect_rid`.
6367 // Available from libzmq 4.1.0.
63456368 CZMQ_EXPORT void
63466369 zsock_set_connect_rid (void *self, const char *connect_rid);
63476370
63486371 // Set socket option `connect_rid` from 32-octet binary
6372 // Available from libzmq 4.1.0.
63496373 CZMQ_EXPORT void
63506374 zsock_set_connect_rid_bin (void *self, const byte *connect_rid);
63516375
63526376 // Get socket option `handshake_ivl`.
6377 // Available from libzmq 4.1.0.
63536378 // Caller owns return value and must destroy it when done.
63546379 CZMQ_EXPORT int
63556380 zsock_handshake_ivl (void *self);
63566381
63576382 // Set socket option `handshake_ivl`.
6383 // Available from libzmq 4.1.0.
63586384 CZMQ_EXPORT void
63596385 zsock_set_handshake_ivl (void *self, int handshake_ivl);
63606386
63616387 // Get socket option `socks_proxy`.
6388 // Available from libzmq 4.1.0.
63626389 // Caller owns return value and must destroy it when done.
63636390 CZMQ_EXPORT char *
63646391 zsock_socks_proxy (void *self);
63656392
63666393 // Set socket option `socks_proxy`.
6394 // Available from libzmq 4.1.0.
63676395 CZMQ_EXPORT void
63686396 zsock_set_socks_proxy (void *self, const char *socks_proxy);
63696397
63706398 // Set socket option `xpub_nodrop`.
6399 // Available from libzmq 4.1.0.
63716400 CZMQ_EXPORT void
63726401 zsock_set_xpub_nodrop (void *self, int xpub_nodrop);
63736402
63746403 // Set socket option `router_mandatory`.
6404 // Available from libzmq 4.0.0.
63756405 CZMQ_EXPORT void
63766406 zsock_set_router_mandatory (void *self, int router_mandatory);
63776407
63786408 // Set socket option `probe_router`.
6409 // Available from libzmq 4.0.0.
63796410 CZMQ_EXPORT void
63806411 zsock_set_probe_router (void *self, int probe_router);
63816412
63826413 // Set socket option `req_relaxed`.
6414 // Available from libzmq 4.0.0.
63836415 CZMQ_EXPORT void
63846416 zsock_set_req_relaxed (void *self, int req_relaxed);
63856417
63866418 // Set socket option `req_correlate`.
6419 // Available from libzmq 4.0.0.
63876420 CZMQ_EXPORT void
63886421 zsock_set_req_correlate (void *self, int req_correlate);
63896422
63906423 // Set socket option `conflate`.
6424 // Available from libzmq 4.0.0.
63916425 CZMQ_EXPORT void
63926426 zsock_set_conflate (void *self, int conflate);
63936427
63946428 // Get socket option `zap_domain`.
6429 // Available from libzmq 4.0.0.
63956430 // Caller owns return value and must destroy it when done.
63966431 CZMQ_EXPORT char *
63976432 zsock_zap_domain (void *self);
63986433
63996434 // Set socket option `zap_domain`.
6435 // Available from libzmq 4.0.0.
64006436 CZMQ_EXPORT void
64016437 zsock_set_zap_domain (void *self, const char *zap_domain);
64026438
64036439 // Get socket option `mechanism`.
6440 // Available from libzmq 4.0.0.
64046441 // Caller owns return value and must destroy it when done.
64056442 CZMQ_EXPORT int
64066443 zsock_mechanism (void *self);
64076444
64086445 // Get socket option `plain_server`.
6446 // Available from libzmq 4.0.0.
64096447 // Caller owns return value and must destroy it when done.
64106448 CZMQ_EXPORT int
64116449 zsock_plain_server (void *self);
64126450
64136451 // Set socket option `plain_server`.
6452 // Available from libzmq 4.0.0.
64146453 CZMQ_EXPORT void
64156454 zsock_set_plain_server (void *self, int plain_server);
64166455
64176456 // Get socket option `plain_username`.
6457 // Available from libzmq 4.0.0.
64186458 // Caller owns return value and must destroy it when done.
64196459 CZMQ_EXPORT char *
64206460 zsock_plain_username (void *self);
64216461
64226462 // Set socket option `plain_username`.
6463 // Available from libzmq 4.0.0.
64236464 CZMQ_EXPORT void
64246465 zsock_set_plain_username (void *self, const char *plain_username);
64256466
64266467 // Get socket option `plain_password`.
6468 // Available from libzmq 4.0.0.
64276469 // Caller owns return value and must destroy it when done.
64286470 CZMQ_EXPORT char *
64296471 zsock_plain_password (void *self);
64306472
64316473 // Set socket option `plain_password`.
6474 // Available from libzmq 4.0.0.
64326475 CZMQ_EXPORT void
64336476 zsock_set_plain_password (void *self, const char *plain_password);
64346477
64356478 // Get socket option `curve_server`.
6479 // Available from libzmq 4.0.0.
64366480 // Caller owns return value and must destroy it when done.
64376481 CZMQ_EXPORT int
64386482 zsock_curve_server (void *self);
64396483
64406484 // Set socket option `curve_server`.
6485 // Available from libzmq 4.0.0.
64416486 CZMQ_EXPORT void
64426487 zsock_set_curve_server (void *self, int curve_server);
64436488
64446489 // Get socket option `curve_publickey`.
6490 // Available from libzmq 4.0.0.
64456491 // Caller owns return value and must destroy it when done.
64466492 CZMQ_EXPORT char *
64476493 zsock_curve_publickey (void *self);
64486494
64496495 // Set socket option `curve_publickey`.
6496 // Available from libzmq 4.0.0.
64506497 CZMQ_EXPORT void
64516498 zsock_set_curve_publickey (void *self, const char *curve_publickey);
64526499
64536500 // Set socket option `curve_publickey` from 32-octet binary
6501 // Available from libzmq 4.0.0.
64546502 CZMQ_EXPORT void
64556503 zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey);
64566504
64576505 // Get socket option `curve_secretkey`.
6506 // Available from libzmq 4.0.0.
64586507 // Caller owns return value and must destroy it when done.
64596508 CZMQ_EXPORT char *
64606509 zsock_curve_secretkey (void *self);
64616510
64626511 // Set socket option `curve_secretkey`.
6512 // Available from libzmq 4.0.0.
64636513 CZMQ_EXPORT void
64646514 zsock_set_curve_secretkey (void *self, const char *curve_secretkey);
64656515
64666516 // Set socket option `curve_secretkey` from 32-octet binary
6517 // Available from libzmq 4.0.0.
64676518 CZMQ_EXPORT void
64686519 zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey);
64696520
64706521 // Get socket option `curve_serverkey`.
6522 // Available from libzmq 4.0.0.
64716523 // Caller owns return value and must destroy it when done.
64726524 CZMQ_EXPORT char *
64736525 zsock_curve_serverkey (void *self);
64746526
64756527 // Set socket option `curve_serverkey`.
6528 // Available from libzmq 4.0.0.
64766529 CZMQ_EXPORT void
64776530 zsock_set_curve_serverkey (void *self, const char *curve_serverkey);
64786531
64796532 // Set socket option `curve_serverkey` from 32-octet binary
6533 // Available from libzmq 4.0.0.
64806534 CZMQ_EXPORT void
64816535 zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey);
64826536
64836537 // Get socket option `gssapi_server`.
6538 // Available from libzmq 4.0.0.
64846539 // Caller owns return value and must destroy it when done.
64856540 CZMQ_EXPORT int
64866541 zsock_gssapi_server (void *self);
64876542
64886543 // Set socket option `gssapi_server`.
6544 // Available from libzmq 4.0.0.
64896545 CZMQ_EXPORT void
64906546 zsock_set_gssapi_server (void *self, int gssapi_server);
64916547
64926548 // Get socket option `gssapi_plaintext`.
6549 // Available from libzmq 4.0.0.
64936550 // Caller owns return value and must destroy it when done.
64946551 CZMQ_EXPORT int
64956552 zsock_gssapi_plaintext (void *self);
64966553
64976554 // Set socket option `gssapi_plaintext`.
6555 // Available from libzmq 4.0.0.
64986556 CZMQ_EXPORT void
64996557 zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext);
65006558
65016559 // Get socket option `gssapi_principal`.
6560 // Available from libzmq 4.0.0.
65026561 // Caller owns return value and must destroy it when done.
65036562 CZMQ_EXPORT char *
65046563 zsock_gssapi_principal (void *self);
65056564
65066565 // Set socket option `gssapi_principal`.
6566 // Available from libzmq 4.0.0.
65076567 CZMQ_EXPORT void
65086568 zsock_set_gssapi_principal (void *self, const char *gssapi_principal);
65096569
65106570 // Get socket option `gssapi_service_principal`.
6571 // Available from libzmq 4.0.0.
65116572 // Caller owns return value and must destroy it when done.
65126573 CZMQ_EXPORT char *
65136574 zsock_gssapi_service_principal (void *self);
65146575
65156576 // Set socket option `gssapi_service_principal`.
6577 // Available from libzmq 4.0.0.
65166578 CZMQ_EXPORT void
65176579 zsock_set_gssapi_service_principal (void *self, const char *gssapi_service_principal);
65186580
6519 // Get socket option `ipv6`.
6581 // Get socket option `ipv6`.
6582 // Available from libzmq 4.0.0.
65206583 // Caller owns return value and must destroy it when done.
65216584 CZMQ_EXPORT int
65226585 zsock_ipv6 (void *self);
65236586
6524 // Set socket option `ipv6`.
6587 // Set socket option `ipv6`.
6588 // Available from libzmq 4.0.0.
65256589 CZMQ_EXPORT void
65266590 zsock_set_ipv6 (void *self, int ipv6);
65276591
65286592 // Get socket option `immediate`.
6593 // Available from libzmq 4.0.0.
65296594 // Caller owns return value and must destroy it when done.
65306595 CZMQ_EXPORT int
65316596 zsock_immediate (void *self);
65326597
65336598 // Set socket option `immediate`.
6599 // Available from libzmq 4.0.0.
65346600 CZMQ_EXPORT void
65356601 zsock_set_immediate (void *self, int immediate);
65366602
6537 // Set socket option `router_raw`.
6538 CZMQ_EXPORT void
6539 zsock_set_router_raw (void *self, int router_raw);
6540
6541 // Get socket option `ipv4only`.
6542 // Caller owns return value and must destroy it when done.
6543 CZMQ_EXPORT int
6544 zsock_ipv4only (void *self);
6545
6546 // Set socket option `ipv4only`.
6547 CZMQ_EXPORT void
6548 zsock_set_ipv4only (void *self, int ipv4only);
6549
6550 // Set socket option `delay_attach_on_connect`.
6551 CZMQ_EXPORT void
6552 zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect);
6553
6554 // Get socket option `type`.
6603 // Get socket option `type`.
6604 // Available from libzmq 3.0.0.
65556605 // Caller owns return value and must destroy it when done.
65566606 CZMQ_EXPORT int
65576607 zsock_type (void *self);
65586608
6559 // Get socket option `sndhwm`.
6609 // Get socket option `sndhwm`.
6610 // Available from libzmq 3.0.0.
65606611 // Caller owns return value and must destroy it when done.
65616612 CZMQ_EXPORT int
65626613 zsock_sndhwm (void *self);
65636614
6564 // Set socket option `sndhwm`.
6615 // Set socket option `sndhwm`.
6616 // Available from libzmq 3.0.0.
65656617 CZMQ_EXPORT void
65666618 zsock_set_sndhwm (void *self, int sndhwm);
65676619
6568 // Get socket option `rcvhwm`.
6620 // Get socket option `rcvhwm`.
6621 // Available from libzmq 3.0.0.
65696622 // Caller owns return value and must destroy it when done.
65706623 CZMQ_EXPORT int
65716624 zsock_rcvhwm (void *self);
65726625
6573 // Set socket option `rcvhwm`.
6626 // Set socket option `rcvhwm`.
6627 // Available from libzmq 3.0.0.
65746628 CZMQ_EXPORT void
65756629 zsock_set_rcvhwm (void *self, int rcvhwm);
65766630
65776631 // Get socket option `affinity`.
6632 // Available from libzmq 3.0.0.
65786633 // Caller owns return value and must destroy it when done.
65796634 CZMQ_EXPORT int
65806635 zsock_affinity (void *self);
65816636
65826637 // Set socket option `affinity`.
6638 // Available from libzmq 3.0.0.
65836639 CZMQ_EXPORT void
65846640 zsock_set_affinity (void *self, int affinity);
65856641
65866642 // Set socket option `subscribe`.
6643 // Available from libzmq 3.0.0.
65876644 CZMQ_EXPORT void
65886645 zsock_set_subscribe (void *self, const char *subscribe);
65896646
65906647 // Set socket option `unsubscribe`.
6648 // Available from libzmq 3.0.0.
65916649 CZMQ_EXPORT void
65926650 zsock_set_unsubscribe (void *self, const char *unsubscribe);
65936651
65946652 // Get socket option `identity`.
6653 // Available from libzmq 3.0.0.
65956654 // Caller owns return value and must destroy it when done.
65966655 CZMQ_EXPORT char *
65976656 zsock_identity (void *self);
65986657
65996658 // Set socket option `identity`.
6659 // Available from libzmq 3.0.0.
66006660 CZMQ_EXPORT void
66016661 zsock_set_identity (void *self, const char *identity);
66026662
6603 // Get socket option `rate`.
6663 // Get socket option `rate`.
6664 // Available from libzmq 3.0.0.
66046665 // Caller owns return value and must destroy it when done.
66056666 CZMQ_EXPORT int
66066667 zsock_rate (void *self);
66076668
6608 // Set socket option `rate`.
6669 // Set socket option `rate`.
6670 // Available from libzmq 3.0.0.
66096671 CZMQ_EXPORT void
66106672 zsock_set_rate (void *self, int rate);
66116673
66126674 // Get socket option `recovery_ivl`.
6675 // Available from libzmq 3.0.0.
66136676 // Caller owns return value and must destroy it when done.
66146677 CZMQ_EXPORT int
66156678 zsock_recovery_ivl (void *self);
66166679
66176680 // Set socket option `recovery_ivl`.
6681 // Available from libzmq 3.0.0.
66186682 CZMQ_EXPORT void
66196683 zsock_set_recovery_ivl (void *self, int recovery_ivl);
66206684
6621 // Get socket option `sndbuf`.
6685 // Get socket option `sndbuf`.
6686 // Available from libzmq 3.0.0.
66226687 // Caller owns return value and must destroy it when done.
66236688 CZMQ_EXPORT int
66246689 zsock_sndbuf (void *self);
66256690
6626 // Set socket option `sndbuf`.
6691 // Set socket option `sndbuf`.
6692 // Available from libzmq 3.0.0.
66276693 CZMQ_EXPORT void
66286694 zsock_set_sndbuf (void *self, int sndbuf);
66296695
6630 // Get socket option `rcvbuf`.
6696 // Get socket option `rcvbuf`.
6697 // Available from libzmq 3.0.0.
66316698 // Caller owns return value and must destroy it when done.
66326699 CZMQ_EXPORT int
66336700 zsock_rcvbuf (void *self);
66346701
6635 // Set socket option `rcvbuf`.
6702 // Set socket option `rcvbuf`.
6703 // Available from libzmq 3.0.0.
66366704 CZMQ_EXPORT void
66376705 zsock_set_rcvbuf (void *self, int rcvbuf);
66386706
6639 // Get socket option `linger`.
6707 // Get socket option `linger`.
6708 // Available from libzmq 3.0.0.
66406709 // Caller owns return value and must destroy it when done.
66416710 CZMQ_EXPORT int
66426711 zsock_linger (void *self);
66436712
6644 // Set socket option `linger`.
6713 // Set socket option `linger`.
6714 // Available from libzmq 3.0.0.
66456715 CZMQ_EXPORT void
66466716 zsock_set_linger (void *self, int linger);
66476717
66486718 // Get socket option `reconnect_ivl`.
6719 // Available from libzmq 3.0.0.
66496720 // Caller owns return value and must destroy it when done.
66506721 CZMQ_EXPORT int
66516722 zsock_reconnect_ivl (void *self);
66526723
66536724 // Set socket option `reconnect_ivl`.
6725 // Available from libzmq 3.0.0.
66546726 CZMQ_EXPORT void
66556727 zsock_set_reconnect_ivl (void *self, int reconnect_ivl);
66566728
66576729 // Get socket option `reconnect_ivl_max`.
6730 // Available from libzmq 3.0.0.
66586731 // Caller owns return value and must destroy it when done.
66596732 CZMQ_EXPORT int
66606733 zsock_reconnect_ivl_max (void *self);
66616734
66626735 // Set socket option `reconnect_ivl_max`.
6736 // Available from libzmq 3.0.0.
66636737 CZMQ_EXPORT void
66646738 zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max);
66656739
66666740 // Get socket option `backlog`.
6741 // Available from libzmq 3.0.0.
66676742 // Caller owns return value and must destroy it when done.
66686743 CZMQ_EXPORT int
66696744 zsock_backlog (void *self);
66706745
66716746 // Set socket option `backlog`.
6747 // Available from libzmq 3.0.0.
66726748 CZMQ_EXPORT void
66736749 zsock_set_backlog (void *self, int backlog);
66746750
66756751 // Get socket option `maxmsgsize`.
6752 // Available from libzmq 3.0.0.
66766753 // Caller owns return value and must destroy it when done.
66776754 CZMQ_EXPORT int
66786755 zsock_maxmsgsize (void *self);
66796756
66806757 // Set socket option `maxmsgsize`.
6758 // Available from libzmq 3.0.0.
66816759 CZMQ_EXPORT void
66826760 zsock_set_maxmsgsize (void *self, int maxmsgsize);
66836761
66846762 // Get socket option `multicast_hops`.
6763 // Available from libzmq 3.0.0.
66856764 // Caller owns return value and must destroy it when done.
66866765 CZMQ_EXPORT int
66876766 zsock_multicast_hops (void *self);
66886767
66896768 // Set socket option `multicast_hops`.
6769 // Available from libzmq 3.0.0.
66906770 CZMQ_EXPORT void
66916771 zsock_set_multicast_hops (void *self, int multicast_hops);
66926772
66936773 // Get socket option `rcvtimeo`.
6774 // Available from libzmq 3.0.0.
66946775 // Caller owns return value and must destroy it when done.
66956776 CZMQ_EXPORT int
66966777 zsock_rcvtimeo (void *self);
66976778
66986779 // Set socket option `rcvtimeo`.
6780 // Available from libzmq 3.0.0.
66996781 CZMQ_EXPORT void
67006782 zsock_set_rcvtimeo (void *self, int rcvtimeo);
67016783
67026784 // Get socket option `sndtimeo`.
6785 // Available from libzmq 3.0.0.
67036786 // Caller owns return value and must destroy it when done.
67046787 CZMQ_EXPORT int
67056788 zsock_sndtimeo (void *self);
67066789
67076790 // Set socket option `sndtimeo`.
6791 // Available from libzmq 3.0.0.
67086792 CZMQ_EXPORT void
67096793 zsock_set_sndtimeo (void *self, int sndtimeo);
67106794
67116795 // Set socket option `xpub_verbose`.
6796 // Available from libzmq 3.0.0.
67126797 CZMQ_EXPORT void
67136798 zsock_set_xpub_verbose (void *self, int xpub_verbose);
67146799
67156800 // Get socket option `tcp_keepalive`.
6801 // Available from libzmq 3.0.0.
67166802 // Caller owns return value and must destroy it when done.
67176803 CZMQ_EXPORT int
67186804 zsock_tcp_keepalive (void *self);
67196805
67206806 // Set socket option `tcp_keepalive`.
6807 // Available from libzmq 3.0.0.
67216808 CZMQ_EXPORT void
67226809 zsock_set_tcp_keepalive (void *self, int tcp_keepalive);
67236810
67246811 // Get socket option `tcp_keepalive_idle`.
6812 // Available from libzmq 3.0.0.
67256813 // Caller owns return value and must destroy it when done.
67266814 CZMQ_EXPORT int
67276815 zsock_tcp_keepalive_idle (void *self);
67286816
67296817 // Set socket option `tcp_keepalive_idle`.
6818 // Available from libzmq 3.0.0.
67306819 CZMQ_EXPORT void
67316820 zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle);
67326821
67336822 // Get socket option `tcp_keepalive_cnt`.
6823 // Available from libzmq 3.0.0.
67346824 // Caller owns return value and must destroy it when done.
67356825 CZMQ_EXPORT int
67366826 zsock_tcp_keepalive_cnt (void *self);
67376827
67386828 // Set socket option `tcp_keepalive_cnt`.
6829 // Available from libzmq 3.0.0.
67396830 CZMQ_EXPORT void
67406831 zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt);
67416832
67426833 // Get socket option `tcp_keepalive_intvl`.
6834 // Available from libzmq 3.0.0.
67436835 // Caller owns return value and must destroy it when done.
67446836 CZMQ_EXPORT int
67456837 zsock_tcp_keepalive_intvl (void *self);
67466838
67476839 // Set socket option `tcp_keepalive_intvl`.
6840 // Available from libzmq 3.0.0.
67486841 CZMQ_EXPORT void
67496842 zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl);
67506843
67516844 // Get socket option `tcp_accept_filter`.
6845 // Available from libzmq 3.0.0.
67526846 // Caller owns return value and must destroy it when done.
67536847 CZMQ_EXPORT char *
67546848 zsock_tcp_accept_filter (void *self);
67556849
67566850 // Set socket option `tcp_accept_filter`.
6851 // Available from libzmq 3.0.0.
67576852 CZMQ_EXPORT void
67586853 zsock_set_tcp_accept_filter (void *self, const char *tcp_accept_filter);
67596854
67606855 // Get socket option `rcvmore`.
6856 // Available from libzmq 3.0.0.
67616857 // Caller owns return value and must destroy it when done.
67626858 CZMQ_EXPORT int
67636859 zsock_rcvmore (void *self);
67646860
6765 // Get socket option `fd`.
6861 // Get socket option `fd`.
6862 // Available from libzmq 3.0.0.
67666863 // Caller owns return value and must destroy it when done.
67676864 CZMQ_EXPORT SOCKET
67686865 zsock_fd (void *self);
67696866
6770 // Get socket option `events`.
6867 // Get socket option `events`.
6868 // Available from libzmq 3.0.0.
67716869 // Caller owns return value and must destroy it when done.
67726870 CZMQ_EXPORT int
67736871 zsock_events (void *self);
67746872
67756873 // Get socket option `last_endpoint`.
6874 // Available from libzmq 3.0.0.
67766875 // Caller owns return value and must destroy it when done.
67776876 CZMQ_EXPORT char *
67786877 zsock_last_endpoint (void *self);
6878
6879 // Set socket option `router_raw`.
6880 // Available from libzmq 3.0.0.
6881 CZMQ_EXPORT void
6882 zsock_set_router_raw (void *self, int router_raw);
6883
6884 // Get socket option `ipv4only`.
6885 // Available from libzmq 3.0.0.
6886 // Caller owns return value and must destroy it when done.
6887 CZMQ_EXPORT int
6888 zsock_ipv4only (void *self);
6889
6890 // Set socket option `ipv4only`.
6891 // Available from libzmq 3.0.0.
6892 CZMQ_EXPORT void
6893 zsock_set_ipv4only (void *self, int ipv4only);
6894
6895 // Set socket option `delay_attach_on_connect`.
6896 // Available from libzmq 3.0.0.
6897 CZMQ_EXPORT void
6898 zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect);
67796899
67806900 // Self test of this class.
67816901 CZMQ_EXPORT void
72017321
72027322 ```
72037323
7204 <A name="toc4-7161" title="zstr - sending and receiving strings" />
7324 <A name="toc4-7281" title="zstr - sending and receiving strings" />
72057325 #### zstr - sending and receiving strings
72067326
72077327 The zstr class provides utility functions for sending and receiving C
73767496 #endif
73777497 ```
73787498
7379 <A name="toc4-7336" title="zsys - system-level methods" />
7499 <A name="toc4-7456" title="zsys - system-level methods" />
73807500 #### zsys - system-level methods
73817501
73827502 The zsys class provides a portable wrapper for system calls. We collect
78637983 zsys_close (logger, NULL, 0);
78647984 ```
78657985
7866 <A name="toc4-7823" title="ztimerset - timer set" />
7986 <A name="toc4-7943" title="ztimerset - timer set" />
78677987 #### ztimerset - timer set
78687988
78697989 ztimerset - timer set
79898109 ztimerset_destroy (&self);
79908110 ```
79918111
7992 <A name="toc4-7949" title="ztrie - simple trie for tokenizable strings" />
8112 <A name="toc4-8069" title="ztrie - simple trie for tokenizable strings" />
79938113 #### ztrie - simple trie for tokenizable strings
79948114
79958115 This is a variant of a trie or prefix tree where all the descendants of a
82328352 ztrie_destroy (&self);
82338353 ```
82348354
8235 <A name="toc4-8192" title="zuuid - UUID support class" />
8355 <A name="toc4-8312" title="zuuid - UUID support class" />
82368356 #### zuuid - UUID support class
82378357
82388358 The zuuid class generates UUIDs and provides methods for working with
83538473 ```
83548474
83558475
8356 <A name="toc2-8313" title="Error Handling" />
8476 <A name="toc2-8433" title="Error Handling" />
83578477 ## Error Handling
83588478
83598479 The CZMQ policy is to reduce the error flow to 0/-1 where possible. libzmq still does a lot of errno setting. CZMQ does not do that, as it creates a fuzzy API. Things either work as expected, or they fail, and the application's best strategy is usually to assert on non-zero return codes.
83708490
83718491 The overall goal with this strategy is robustness, and absolute minimal and predictable expression in the code. You can see that it works: the CZMQ code is generally very simple and clear, with a few exceptions of places where people have used their old C style (we fix these over time).
83728492
8373 <A name="toc2-8330" title="CZMQ Actors" />
8493 <A name="toc2-8450" title="CZMQ Actors" />
83748494 ## CZMQ Actors
83758495
83768496 The v2 API had a zthread class that let you create "attached threads" connected to their parent by an inproc:// PIPE socket. In v3 this has been simplified and better wrapped as the zactor class. CZMQ actors are in effect threads with a socket interface. A zactor_t instance works like a socket, and the CZMQ classes that deal with sockets (like zmsg and zpoller) all accept zactor_t references as well as zsock_t and libzmq void * socket handles.
85168636
85178637 The selftest code shows how to create, talk to, and destroy an actor.
85188638
8519 <A name="toc2-8476" title="Under the Hood" />
8639 <A name="toc2-8596" title="Under the Hood" />
85208640 ## Under the Hood
85218641
8522 <A name="toc3-8479" title="Adding a New Class" />
8642 <A name="toc3-8599" title="Adding a New Class" />
85238643 ### Adding a New Class
85248644
85258645 If you define a new CZMQ class `myclass` you need to:
85318651 * Add myclass to 'model/projects.xml` and read model/README.txt.
85328652 * Add a section to README.txt.
85338653
8534 <A name="toc3-8491" title="Documentation" />
8654 <A name="toc3-8611" title="Documentation" />
85358655 ### Documentation
85368656
85378657 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):
85708690
85718691 The template for man pages is in doc/mkman.
85728692
8573 <A name="toc3-8530" title="Development" />
8693 <A name="toc3-8650" title="Development" />
85748694 ### Development
85758695
85768696 CZMQ is developed through a test-driven process that guarantees no memory violations or leaks in the code:
85808700 * Run the 'selftest' script, which uses the Valgrind memcheck tool.
85818701 * Repeat until perfect.
85828702
8583 <A name="toc3-8540" title="Porting CZMQ" />
8703 <A name="toc3-8660" title="Porting CZMQ" />
85848704 ### Porting CZMQ
85858705
85868706 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.
85918711 * Defining macros that rename exotic library functions to more conventional names: do this in czmq_prelude.h.
85928712 * 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.
85938713
8594 <A name="toc3-8551" title="Hints to Contributors" />
8714 <A name="toc3-8671" title="Hints to Contributors" />
85958715 ### Hints to Contributors
85968716
85978717 CZMQ is a nice, neat library, and you may not immediately appreciate why. Read the CLASS style guide please, and write your code to make it indistinguishable from the rest of the code in the library. That is the only real criteria for good style: it's invisible.
86028722
86038723 Before opening a pull request read our [contribution guidelines](https://github.com/zeromq/czmq/blob/master/CONTRIBUTING.md). Thanks!
86048724
8605 <A name="toc3-8562" title="Code Generation" />
8725 <A name="toc3-8682" title="Code Generation" />
86068726 ### Code Generation
86078727
86088728 We generate the zsockopt class using [GSL](https://github.com/imatix/gsl), using a code generator script in scripts/sockopts.gsl. We also generate the project files.
86098729
8610 <A name="toc3-8567" title="This Document" />
8730 <A name="toc3-8687" title="This Document" />
86118731 ### This Document
86128732
86138733 This document is originally at README.txt and is built using [gitdown](http://github.com/imatix/gitdown).
101101 # only execute this next line if interested in updating the man pages as well (adds to build time):
102102 sudo apt-get install -y asciidoc
103103
104 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 libzmq (ZeroMQ core) library:
104 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 libzmq (ZeroMQ core) library (NOTE: skip ldconfig on OSX):
105105
106106 git clone git://github.com/zeromq/libzmq.git
107107 cd libzmq
77 ******************************************************************
88 -->
99
10 <!-- The following socket options are available in libzmq from version 4.2.0 -->
11
1012 <method name = "heartbeat ivl" polymorphic = "1">
1113 Get socket option `heartbeat_ivl`.
14 Available from libzmq 4.2.0.
1215 <return type = "integer" fresh = "1" />
1316 </method>
1417
1518 <method name = "set heartbeat ivl" polymorphic = "1">
1619 Set socket option `heartbeat_ivl`.
20 Available from libzmq 4.2.0.
1721 <argument name = "heartbeat ivl" type = "integer" />
1822 </method>
1923
2024 <method name = "heartbeat ttl" polymorphic = "1">
2125 Get socket option `heartbeat_ttl`.
26 Available from libzmq 4.2.0.
2227 <return type = "integer" fresh = "1" />
2328 </method>
2429
2530 <method name = "set heartbeat ttl" polymorphic = "1">
2631 Set socket option `heartbeat_ttl`.
32 Available from libzmq 4.2.0.
2733 <argument name = "heartbeat ttl" type = "integer" />
2834 </method>
2935
3036 <method name = "heartbeat timeout" polymorphic = "1">
3137 Get socket option `heartbeat_timeout`.
38 Available from libzmq 4.2.0.
3239 <return type = "integer" fresh = "1" />
3340 </method>
3441
3542 <method name = "set heartbeat timeout" polymorphic = "1">
3643 Set socket option `heartbeat_timeout`.
44 Available from libzmq 4.2.0.
3745 <argument name = "heartbeat timeout" type = "integer" />
3846 </method>
3947
4048 <method name = "use fd" polymorphic = "1">
4149 Get socket option `use_fd`.
50 Available from libzmq 4.2.0.
4251 <return type = "integer" fresh = "1" />
4352 </method>
4453
4554 <method name = "set use fd" polymorphic = "1">
4655 Set socket option `use_fd`.
56 Available from libzmq 4.2.0.
4757 <argument name = "use fd" type = "integer" />
4858 </method>
4959
5060 <method name = "set xpub manual" polymorphic = "1">
5161 Set socket option `xpub_manual`.
62 Available from libzmq 4.2.0.
5263 <argument name = "xpub manual" type = "integer" />
5364 </method>
5465
5566 <method name = "set xpub welcome msg" polymorphic = "1">
5667 Set socket option `xpub_welcome_msg`.
68 Available from libzmq 4.2.0.
5769 <argument name = "xpub welcome msg" type = "string" />
5870 </method>
5971
6072 <method name = "set stream notify" polymorphic = "1">
6173 Set socket option `stream_notify`.
74 Available from libzmq 4.2.0.
6275 <argument name = "stream notify" type = "integer" />
6376 </method>
6477
6578 <method name = "invert matching" polymorphic = "1">
6679 Get socket option `invert_matching`.
80 Available from libzmq 4.2.0.
6781 <return type = "integer" fresh = "1" />
6882 </method>
6983
7084 <method name = "set invert matching" polymorphic = "1">
7185 Set socket option `invert_matching`.
86 Available from libzmq 4.2.0.
7287 <argument name = "invert matching" type = "integer" />
7388 </method>
7489
7590 <method name = "set xpub verboser" polymorphic = "1">
7691 Set socket option `xpub_verboser`.
92 Available from libzmq 4.2.0.
7793 <argument name = "xpub verboser" type = "integer" />
7894 </method>
7995
8096 <method name = "connect timeout" polymorphic = "1">
8197 Get socket option `connect_timeout`.
98 Available from libzmq 4.2.0.
8299 <return type = "integer" fresh = "1" />
83100 </method>
84101
85102 <method name = "set connect timeout" polymorphic = "1">
86103 Set socket option `connect_timeout`.
104 Available from libzmq 4.2.0.
87105 <argument name = "connect timeout" type = "integer" />
88106 </method>
89107
90108 <method name = "tcp maxrt" polymorphic = "1">
91109 Get socket option `tcp_maxrt`.
110 Available from libzmq 4.2.0.
92111 <return type = "integer" fresh = "1" />
93112 </method>
94113
95114 <method name = "set tcp maxrt" polymorphic = "1">
96115 Set socket option `tcp_maxrt`.
116 Available from libzmq 4.2.0.
97117 <argument name = "tcp maxrt" type = "integer" />
98118 </method>
99119
100120 <method name = "thread safe" polymorphic = "1">
101121 Get socket option `thread_safe`.
122 Available from libzmq 4.2.0.
102123 <return type = "integer" fresh = "1" />
103124 </method>
104125
105126 <method name = "multicast maxtpdu" polymorphic = "1">
106127 Get socket option `multicast_maxtpdu`.
128 Available from libzmq 4.2.0.
107129 <return type = "integer" fresh = "1" />
108130 </method>
109131
110132 <method name = "set multicast maxtpdu" polymorphic = "1">
111133 Set socket option `multicast_maxtpdu`.
134 Available from libzmq 4.2.0.
112135 <argument name = "multicast maxtpdu" type = "integer" />
113136 </method>
114137
115138 <method name = "vmci buffer size" polymorphic = "1">
116139 Get socket option `vmci_buffer_size`.
140 Available from libzmq 4.2.0.
117141 <return type = "integer" fresh = "1" />
118142 </method>
119143
120144 <method name = "set vmci buffer size" polymorphic = "1">
121145 Set socket option `vmci_buffer_size`.
146 Available from libzmq 4.2.0.
122147 <argument name = "vmci buffer size" type = "integer" />
123148 </method>
124149
125150 <method name = "vmci buffer min size" polymorphic = "1">
126151 Get socket option `vmci_buffer_min_size`.
152 Available from libzmq 4.2.0.
127153 <return type = "integer" fresh = "1" />
128154 </method>
129155
130156 <method name = "set vmci buffer min size" polymorphic = "1">
131157 Set socket option `vmci_buffer_min_size`.
158 Available from libzmq 4.2.0.
132159 <argument name = "vmci buffer min size" type = "integer" />
133160 </method>
134161
135162 <method name = "vmci buffer max size" polymorphic = "1">
136163 Get socket option `vmci_buffer_max_size`.
164 Available from libzmq 4.2.0.
137165 <return type = "integer" fresh = "1" />
138166 </method>
139167
140168 <method name = "set vmci buffer max size" polymorphic = "1">
141169 Set socket option `vmci_buffer_max_size`.
170 Available from libzmq 4.2.0.
142171 <argument name = "vmci buffer max size" type = "integer" />
143172 </method>
144173
145174 <method name = "vmci connect timeout" polymorphic = "1">
146175 Get socket option `vmci_connect_timeout`.
176 Available from libzmq 4.2.0.
147177 <return type = "integer" fresh = "1" />
148178 </method>
149179
150180 <method name = "set vmci connect timeout" polymorphic = "1">
151181 Set socket option `vmci_connect_timeout`.
182 Available from libzmq 4.2.0.
152183 <argument name = "vmci connect timeout" type = "integer" />
153184 </method>
185
186 <!-- The following socket options are available in libzmq from version 4.1.0 -->
154187
155188 <method name = "tos" polymorphic = "1">
156189 Get socket option `tos`.
190 Available from libzmq 4.1.0.
157191 <return type = "integer" fresh = "1" />
158192 </method>
159193
160194 <method name = "set tos" polymorphic = "1">
161195 Set socket option `tos`.
196 Available from libzmq 4.1.0.
162197 <argument name = "tos" type = "integer" />
163198 </method>
164199
165200 <method name = "set router handover" polymorphic = "1">
166201 Set socket option `router_handover`.
202 Available from libzmq 4.1.0.
167203 <argument name = "router handover" type = "integer" />
168204 </method>
169205
170206 <method name = "set connect rid" polymorphic = "1">
171207 Set socket option `connect_rid`.
208 Available from libzmq 4.1.0.
172209 <argument name = "connect rid" type = "string" />
173210 </method>
174211
175212 <method name = "set connect rid bin" polymorphic = "1">
176213 Set socket option `connect_rid` from 32-octet binary
214 Available from libzmq 4.1.0.
177215 <argument name = "connect rid" type = "buffer" />
178216 </method>
179217
180218 <method name = "handshake ivl" polymorphic = "1">
181219 Get socket option `handshake_ivl`.
220 Available from libzmq 4.1.0.
182221 <return type = "integer" fresh = "1" />
183222 </method>
184223
185224 <method name = "set handshake ivl" polymorphic = "1">
186225 Set socket option `handshake_ivl`.
226 Available from libzmq 4.1.0.
187227 <argument name = "handshake ivl" type = "integer" />
188228 </method>
189229
190230 <method name = "socks proxy" polymorphic = "1">
191231 Get socket option `socks_proxy`.
232 Available from libzmq 4.1.0.
192233 <return type = "string" fresh = "1" />
193234 </method>
194235
195236 <method name = "set socks proxy" polymorphic = "1">
196237 Set socket option `socks_proxy`.
238 Available from libzmq 4.1.0.
197239 <argument name = "socks proxy" type = "string" />
198240 </method>
199241
200242 <method name = "set xpub nodrop" polymorphic = "1">
201243 Set socket option `xpub_nodrop`.
244 Available from libzmq 4.1.0.
202245 <argument name = "xpub nodrop" type = "integer" />
203246 </method>
247
248 <!-- The following socket options are available in libzmq from version 4.0.0 -->
204249
205250 <method name = "set router mandatory" polymorphic = "1">
206251 Set socket option `router_mandatory`.
252 Available from libzmq 4.0.0.
207253 <argument name = "router mandatory" type = "integer" />
208254 </method>
209255
210256 <method name = "set probe router" polymorphic = "1">
211257 Set socket option `probe_router`.
258 Available from libzmq 4.0.0.
212259 <argument name = "probe router" type = "integer" />
213260 </method>
214261
215262 <method name = "set req relaxed" polymorphic = "1">
216263 Set socket option `req_relaxed`.
264 Available from libzmq 4.0.0.
217265 <argument name = "req relaxed" type = "integer" />
218266 </method>
219267
220268 <method name = "set req correlate" polymorphic = "1">
221269 Set socket option `req_correlate`.
270 Available from libzmq 4.0.0.
222271 <argument name = "req correlate" type = "integer" />
223272 </method>
224273
225274 <method name = "set conflate" polymorphic = "1">
226275 Set socket option `conflate`.
276 Available from libzmq 4.0.0.
227277 <argument name = "conflate" type = "integer" />
228278 </method>
229279
230280 <method name = "zap domain" polymorphic = "1">
231281 Get socket option `zap_domain`.
282 Available from libzmq 4.0.0.
232283 <return type = "string" fresh = "1" />
233284 </method>
234285
235286 <method name = "set zap domain" polymorphic = "1">
236287 Set socket option `zap_domain`.
288 Available from libzmq 4.0.0.
237289 <argument name = "zap domain" type = "string" />
238290 </method>
239291
240292 <method name = "mechanism" polymorphic = "1">
241293 Get socket option `mechanism`.
294 Available from libzmq 4.0.0.
242295 <return type = "integer" fresh = "1" />
243296 </method>
244297
245298 <method name = "plain server" polymorphic = "1">
246299 Get socket option `plain_server`.
300 Available from libzmq 4.0.0.
247301 <return type = "integer" fresh = "1" />
248302 </method>
249303
250304 <method name = "set plain server" polymorphic = "1">
251305 Set socket option `plain_server`.
306 Available from libzmq 4.0.0.
252307 <argument name = "plain server" type = "integer" />
253308 </method>
254309
255310 <method name = "plain username" polymorphic = "1">
256311 Get socket option `plain_username`.
312 Available from libzmq 4.0.0.
257313 <return type = "string" fresh = "1" />
258314 </method>
259315
260316 <method name = "set plain username" polymorphic = "1">
261317 Set socket option `plain_username`.
318 Available from libzmq 4.0.0.
262319 <argument name = "plain username" type = "string" />
263320 </method>
264321
265322 <method name = "plain password" polymorphic = "1">
266323 Get socket option `plain_password`.
324 Available from libzmq 4.0.0.
267325 <return type = "string" fresh = "1" />
268326 </method>
269327
270328 <method name = "set plain password" polymorphic = "1">
271329 Set socket option `plain_password`.
330 Available from libzmq 4.0.0.
272331 <argument name = "plain password" type = "string" />
273332 </method>
274333
275334 <method name = "curve server" polymorphic = "1">
276335 Get socket option `curve_server`.
336 Available from libzmq 4.0.0.
277337 <return type = "integer" fresh = "1" />
278338 </method>
279339
280340 <method name = "set curve server" polymorphic = "1">
281341 Set socket option `curve_server`.
342 Available from libzmq 4.0.0.
282343 <argument name = "curve server" type = "integer" />
283344 </method>
284345
285346 <method name = "curve publickey" polymorphic = "1">
286347 Get socket option `curve_publickey`.
348 Available from libzmq 4.0.0.
287349 <return type = "string" fresh = "1" />
288350 </method>
289351
290352 <method name = "set curve publickey" polymorphic = "1">
291353 Set socket option `curve_publickey`.
354 Available from libzmq 4.0.0.
292355 <argument name = "curve publickey" type = "string" />
293356 </method>
294357
295358 <method name = "set curve publickey bin" polymorphic = "1">
296359 Set socket option `curve_publickey` from 32-octet binary
360 Available from libzmq 4.0.0.
297361 <argument name = "curve publickey" type = "buffer" />
298362 </method>
299363
300364 <method name = "curve secretkey" polymorphic = "1">
301365 Get socket option `curve_secretkey`.
366 Available from libzmq 4.0.0.
302367 <return type = "string" fresh = "1" />
303368 </method>
304369
305370 <method name = "set curve secretkey" polymorphic = "1">
306371 Set socket option `curve_secretkey`.
372 Available from libzmq 4.0.0.
307373 <argument name = "curve secretkey" type = "string" />
308374 </method>
309375
310376 <method name = "set curve secretkey bin" polymorphic = "1">
311377 Set socket option `curve_secretkey` from 32-octet binary
378 Available from libzmq 4.0.0.
312379 <argument name = "curve secretkey" type = "buffer" />
313380 </method>
314381
315382 <method name = "curve serverkey" polymorphic = "1">
316383 Get socket option `curve_serverkey`.
384 Available from libzmq 4.0.0.
317385 <return type = "string" fresh = "1" />
318386 </method>
319387
320388 <method name = "set curve serverkey" polymorphic = "1">
321389 Set socket option `curve_serverkey`.
390 Available from libzmq 4.0.0.
322391 <argument name = "curve serverkey" type = "string" />
323392 </method>
324393
325394 <method name = "set curve serverkey bin" polymorphic = "1">
326395 Set socket option `curve_serverkey` from 32-octet binary
396 Available from libzmq 4.0.0.
327397 <argument name = "curve serverkey" type = "buffer" />
328398 </method>
329399
330400 <method name = "gssapi server" polymorphic = "1">
331401 Get socket option `gssapi_server`.
402 Available from libzmq 4.0.0.
332403 <return type = "integer" fresh = "1" />
333404 </method>
334405
335406 <method name = "set gssapi server" polymorphic = "1">
336407 Set socket option `gssapi_server`.
408 Available from libzmq 4.0.0.
337409 <argument name = "gssapi server" type = "integer" />
338410 </method>
339411
340412 <method name = "gssapi plaintext" polymorphic = "1">
341413 Get socket option `gssapi_plaintext`.
414 Available from libzmq 4.0.0.
342415 <return type = "integer" fresh = "1" />
343416 </method>
344417
345418 <method name = "set gssapi plaintext" polymorphic = "1">
346419 Set socket option `gssapi_plaintext`.
420 Available from libzmq 4.0.0.
347421 <argument name = "gssapi plaintext" type = "integer" />
348422 </method>
349423
350424 <method name = "gssapi principal" polymorphic = "1">
351425 Get socket option `gssapi_principal`.
426 Available from libzmq 4.0.0.
352427 <return type = "string" fresh = "1" />
353428 </method>
354429
355430 <method name = "set gssapi principal" polymorphic = "1">
356431 Set socket option `gssapi_principal`.
432 Available from libzmq 4.0.0.
357433 <argument name = "gssapi principal" type = "string" />
358434 </method>
359435
360436 <method name = "gssapi service principal" polymorphic = "1">
361437 Get socket option `gssapi_service_principal`.
438 Available from libzmq 4.0.0.
362439 <return type = "string" fresh = "1" />
363440 </method>
364441
365442 <method name = "set gssapi service principal" polymorphic = "1">
366443 Set socket option `gssapi_service_principal`.
444 Available from libzmq 4.0.0.
367445 <argument name = "gssapi service principal" type = "string" />
368446 </method>
369447
370448 <method name = "ipv6" polymorphic = "1">
371449 Get socket option `ipv6`.
450 Available from libzmq 4.0.0.
372451 <return type = "integer" fresh = "1" />
373452 </method>
374453
375454 <method name = "set ipv6" polymorphic = "1">
376455 Set socket option `ipv6`.
456 Available from libzmq 4.0.0.
377457 <argument name = "ipv6" type = "integer" />
378458 </method>
379459
380460 <method name = "immediate" polymorphic = "1">
381461 Get socket option `immediate`.
462 Available from libzmq 4.0.0.
382463 <return type = "integer" fresh = "1" />
383464 </method>
384465
385466 <method name = "set immediate" polymorphic = "1">
386467 Set socket option `immediate`.
468 Available from libzmq 4.0.0.
387469 <argument name = "immediate" type = "integer" />
470 </method>
471
472 <!-- The following socket options are available in libzmq from version 3.0.0 -->
473
474 <method name = "type" polymorphic = "1">
475 Get socket option `type`.
476 Available from libzmq 3.0.0.
477 <return type = "integer" fresh = "1" />
478 </method>
479
480 <method name = "sndhwm" polymorphic = "1">
481 Get socket option `sndhwm`.
482 Available from libzmq 3.0.0.
483 <return type = "integer" fresh = "1" />
484 </method>
485
486 <method name = "set sndhwm" polymorphic = "1">
487 Set socket option `sndhwm`.
488 Available from libzmq 3.0.0.
489 <argument name = "sndhwm" type = "integer" />
490 </method>
491
492 <method name = "rcvhwm" polymorphic = "1">
493 Get socket option `rcvhwm`.
494 Available from libzmq 3.0.0.
495 <return type = "integer" fresh = "1" />
496 </method>
497
498 <method name = "set rcvhwm" polymorphic = "1">
499 Set socket option `rcvhwm`.
500 Available from libzmq 3.0.0.
501 <argument name = "rcvhwm" type = "integer" />
502 </method>
503
504 <method name = "affinity" polymorphic = "1">
505 Get socket option `affinity`.
506 Available from libzmq 3.0.0.
507 <return type = "integer" fresh = "1" />
508 </method>
509
510 <method name = "set affinity" polymorphic = "1">
511 Set socket option `affinity`.
512 Available from libzmq 3.0.0.
513 <argument name = "affinity" type = "integer" />
514 </method>
515
516 <method name = "set subscribe" polymorphic = "1">
517 Set socket option `subscribe`.
518 Available from libzmq 3.0.0.
519 <argument name = "subscribe" type = "string" />
520 </method>
521
522 <method name = "set unsubscribe" polymorphic = "1">
523 Set socket option `unsubscribe`.
524 Available from libzmq 3.0.0.
525 <argument name = "unsubscribe" type = "string" />
526 </method>
527
528 <method name = "identity" polymorphic = "1">
529 Get socket option `identity`.
530 Available from libzmq 3.0.0.
531 <return type = "string" fresh = "1" />
532 </method>
533
534 <method name = "set identity" polymorphic = "1">
535 Set socket option `identity`.
536 Available from libzmq 3.0.0.
537 <argument name = "identity" type = "string" />
538 </method>
539
540 <method name = "rate" polymorphic = "1">
541 Get socket option `rate`.
542 Available from libzmq 3.0.0.
543 <return type = "integer" fresh = "1" />
544 </method>
545
546 <method name = "set rate" polymorphic = "1">
547 Set socket option `rate`.
548 Available from libzmq 3.0.0.
549 <argument name = "rate" type = "integer" />
550 </method>
551
552 <method name = "recovery ivl" polymorphic = "1">
553 Get socket option `recovery_ivl`.
554 Available from libzmq 3.0.0.
555 <return type = "integer" fresh = "1" />
556 </method>
557
558 <method name = "set recovery ivl" polymorphic = "1">
559 Set socket option `recovery_ivl`.
560 Available from libzmq 3.0.0.
561 <argument name = "recovery ivl" type = "integer" />
562 </method>
563
564 <method name = "sndbuf" polymorphic = "1">
565 Get socket option `sndbuf`.
566 Available from libzmq 3.0.0.
567 <return type = "integer" fresh = "1" />
568 </method>
569
570 <method name = "set sndbuf" polymorphic = "1">
571 Set socket option `sndbuf`.
572 Available from libzmq 3.0.0.
573 <argument name = "sndbuf" type = "integer" />
574 </method>
575
576 <method name = "rcvbuf" polymorphic = "1">
577 Get socket option `rcvbuf`.
578 Available from libzmq 3.0.0.
579 <return type = "integer" fresh = "1" />
580 </method>
581
582 <method name = "set rcvbuf" polymorphic = "1">
583 Set socket option `rcvbuf`.
584 Available from libzmq 3.0.0.
585 <argument name = "rcvbuf" type = "integer" />
586 </method>
587
588 <method name = "linger" polymorphic = "1">
589 Get socket option `linger`.
590 Available from libzmq 3.0.0.
591 <return type = "integer" fresh = "1" />
592 </method>
593
594 <method name = "set linger" polymorphic = "1">
595 Set socket option `linger`.
596 Available from libzmq 3.0.0.
597 <argument name = "linger" type = "integer" />
598 </method>
599
600 <method name = "reconnect ivl" polymorphic = "1">
601 Get socket option `reconnect_ivl`.
602 Available from libzmq 3.0.0.
603 <return type = "integer" fresh = "1" />
604 </method>
605
606 <method name = "set reconnect ivl" polymorphic = "1">
607 Set socket option `reconnect_ivl`.
608 Available from libzmq 3.0.0.
609 <argument name = "reconnect ivl" type = "integer" />
610 </method>
611
612 <method name = "reconnect ivl max" polymorphic = "1">
613 Get socket option `reconnect_ivl_max`.
614 Available from libzmq 3.0.0.
615 <return type = "integer" fresh = "1" />
616 </method>
617
618 <method name = "set reconnect ivl max" polymorphic = "1">
619 Set socket option `reconnect_ivl_max`.
620 Available from libzmq 3.0.0.
621 <argument name = "reconnect ivl max" type = "integer" />
622 </method>
623
624 <method name = "backlog" polymorphic = "1">
625 Get socket option `backlog`.
626 Available from libzmq 3.0.0.
627 <return type = "integer" fresh = "1" />
628 </method>
629
630 <method name = "set backlog" polymorphic = "1">
631 Set socket option `backlog`.
632 Available from libzmq 3.0.0.
633 <argument name = "backlog" type = "integer" />
634 </method>
635
636 <method name = "maxmsgsize" polymorphic = "1">
637 Get socket option `maxmsgsize`.
638 Available from libzmq 3.0.0.
639 <return type = "integer" fresh = "1" />
640 </method>
641
642 <method name = "set maxmsgsize" polymorphic = "1">
643 Set socket option `maxmsgsize`.
644 Available from libzmq 3.0.0.
645 <argument name = "maxmsgsize" type = "integer" />
646 </method>
647
648 <method name = "multicast hops" polymorphic = "1">
649 Get socket option `multicast_hops`.
650 Available from libzmq 3.0.0.
651 <return type = "integer" fresh = "1" />
652 </method>
653
654 <method name = "set multicast hops" polymorphic = "1">
655 Set socket option `multicast_hops`.
656 Available from libzmq 3.0.0.
657 <argument name = "multicast hops" type = "integer" />
658 </method>
659
660 <method name = "rcvtimeo" polymorphic = "1">
661 Get socket option `rcvtimeo`.
662 Available from libzmq 3.0.0.
663 <return type = "integer" fresh = "1" />
664 </method>
665
666 <method name = "set rcvtimeo" polymorphic = "1">
667 Set socket option `rcvtimeo`.
668 Available from libzmq 3.0.0.
669 <argument name = "rcvtimeo" type = "integer" />
670 </method>
671
672 <method name = "sndtimeo" polymorphic = "1">
673 Get socket option `sndtimeo`.
674 Available from libzmq 3.0.0.
675 <return type = "integer" fresh = "1" />
676 </method>
677
678 <method name = "set sndtimeo" polymorphic = "1">
679 Set socket option `sndtimeo`.
680 Available from libzmq 3.0.0.
681 <argument name = "sndtimeo" type = "integer" />
682 </method>
683
684 <method name = "set xpub verbose" polymorphic = "1">
685 Set socket option `xpub_verbose`.
686 Available from libzmq 3.0.0.
687 <argument name = "xpub verbose" type = "integer" />
688 </method>
689
690 <method name = "tcp keepalive" polymorphic = "1">
691 Get socket option `tcp_keepalive`.
692 Available from libzmq 3.0.0.
693 <return type = "integer" fresh = "1" />
694 </method>
695
696 <method name = "set tcp keepalive" polymorphic = "1">
697 Set socket option `tcp_keepalive`.
698 Available from libzmq 3.0.0.
699 <argument name = "tcp keepalive" type = "integer" />
700 </method>
701
702 <method name = "tcp keepalive idle" polymorphic = "1">
703 Get socket option `tcp_keepalive_idle`.
704 Available from libzmq 3.0.0.
705 <return type = "integer" fresh = "1" />
706 </method>
707
708 <method name = "set tcp keepalive idle" polymorphic = "1">
709 Set socket option `tcp_keepalive_idle`.
710 Available from libzmq 3.0.0.
711 <argument name = "tcp keepalive idle" type = "integer" />
712 </method>
713
714 <method name = "tcp keepalive cnt" polymorphic = "1">
715 Get socket option `tcp_keepalive_cnt`.
716 Available from libzmq 3.0.0.
717 <return type = "integer" fresh = "1" />
718 </method>
719
720 <method name = "set tcp keepalive cnt" polymorphic = "1">
721 Set socket option `tcp_keepalive_cnt`.
722 Available from libzmq 3.0.0.
723 <argument name = "tcp keepalive cnt" type = "integer" />
724 </method>
725
726 <method name = "tcp keepalive intvl" polymorphic = "1">
727 Get socket option `tcp_keepalive_intvl`.
728 Available from libzmq 3.0.0.
729 <return type = "integer" fresh = "1" />
730 </method>
731
732 <method name = "set tcp keepalive intvl" polymorphic = "1">
733 Set socket option `tcp_keepalive_intvl`.
734 Available from libzmq 3.0.0.
735 <argument name = "tcp keepalive intvl" type = "integer" />
736 </method>
737
738 <method name = "tcp accept filter" polymorphic = "1">
739 Get socket option `tcp_accept_filter`.
740 Available from libzmq 3.0.0.
741 <return type = "string" fresh = "1" />
742 </method>
743
744 <method name = "set tcp accept filter" polymorphic = "1">
745 Set socket option `tcp_accept_filter`.
746 Available from libzmq 3.0.0.
747 <argument name = "tcp accept filter" type = "string" />
748 </method>
749
750 <method name = "rcvmore" polymorphic = "1">
751 Get socket option `rcvmore`.
752 Available from libzmq 3.0.0.
753 <return type = "integer" fresh = "1" />
754 </method>
755
756 <method name = "fd" polymorphic = "1">
757 Get socket option `fd`.
758 Available from libzmq 3.0.0.
759 <return type = "socket" fresh = "1" />
760 </method>
761
762 <method name = "events" polymorphic = "1">
763 Get socket option `events`.
764 Available from libzmq 3.0.0.
765 <return type = "integer" fresh = "1" />
766 </method>
767
768 <method name = "last endpoint" polymorphic = "1">
769 Get socket option `last_endpoint`.
770 Available from libzmq 3.0.0.
771 <return type = "string" fresh = "1" />
388772 </method>
389773
390774 <method name = "set router raw" polymorphic = "1">
391775 Set socket option `router_raw`.
776 Available from libzmq 3.0.0.
392777 <argument name = "router raw" type = "integer" />
393778 </method>
394779
395780 <method name = "ipv4only" polymorphic = "1">
396781 Get socket option `ipv4only`.
782 Available from libzmq 3.0.0.
397783 <return type = "integer" fresh = "1" />
398784 </method>
399785
400786 <method name = "set ipv4only" polymorphic = "1">
401787 Set socket option `ipv4only`.
788 Available from libzmq 3.0.0.
402789 <argument name = "ipv4only" type = "integer" />
403790 </method>
404791
405792 <method name = "set delay attach on connect" polymorphic = "1">
406793 Set socket option `delay_attach_on_connect`.
794 Available from libzmq 3.0.0.
407795 <argument name = "delay attach on connect" type = "integer" />
408796 </method>
409
410 <method name = "type" polymorphic = "1">
411 Get socket option `type`.
412 <return type = "integer" fresh = "1" />
413 </method>
414
415 <method name = "sndhwm" polymorphic = "1">
416 Get socket option `sndhwm`.
417 <return type = "integer" fresh = "1" />
418 </method>
419
420 <method name = "set sndhwm" polymorphic = "1">
421 Set socket option `sndhwm`.
422 <argument name = "sndhwm" type = "integer" />
423 </method>
424
425 <method name = "rcvhwm" polymorphic = "1">
426 Get socket option `rcvhwm`.
427 <return type = "integer" fresh = "1" />
428 </method>
429
430 <method name = "set rcvhwm" polymorphic = "1">
431 Set socket option `rcvhwm`.
432 <argument name = "rcvhwm" type = "integer" />
433 </method>
434
435 <method name = "affinity" polymorphic = "1">
436 Get socket option `affinity`.
437 <return type = "integer" fresh = "1" />
438 </method>
439
440 <method name = "set affinity" polymorphic = "1">
441 Set socket option `affinity`.
442 <argument name = "affinity" type = "integer" />
443 </method>
444
445 <method name = "set subscribe" polymorphic = "1">
446 Set socket option `subscribe`.
447 <argument name = "subscribe" type = "string" />
448 </method>
449
450 <method name = "set unsubscribe" polymorphic = "1">
451 Set socket option `unsubscribe`.
452 <argument name = "unsubscribe" type = "string" />
453 </method>
454
455 <method name = "identity" polymorphic = "1">
456 Get socket option `identity`.
457 <return type = "string" fresh = "1" />
458 </method>
459
460 <method name = "set identity" polymorphic = "1">
461 Set socket option `identity`.
462 <argument name = "identity" type = "string" />
463 </method>
464
465 <method name = "rate" polymorphic = "1">
466 Get socket option `rate`.
467 <return type = "integer" fresh = "1" />
468 </method>
469
470 <method name = "set rate" polymorphic = "1">
471 Set socket option `rate`.
472 <argument name = "rate" type = "integer" />
473 </method>
474
475 <method name = "recovery ivl" polymorphic = "1">
476 Get socket option `recovery_ivl`.
477 <return type = "integer" fresh = "1" />
478 </method>
479
480 <method name = "set recovery ivl" polymorphic = "1">
481 Set socket option `recovery_ivl`.
482 <argument name = "recovery ivl" type = "integer" />
483 </method>
484
485 <method name = "sndbuf" polymorphic = "1">
486 Get socket option `sndbuf`.
487 <return type = "integer" fresh = "1" />
488 </method>
489
490 <method name = "set sndbuf" polymorphic = "1">
491 Set socket option `sndbuf`.
492 <argument name = "sndbuf" type = "integer" />
493 </method>
494
495 <method name = "rcvbuf" polymorphic = "1">
496 Get socket option `rcvbuf`.
497 <return type = "integer" fresh = "1" />
498 </method>
499
500 <method name = "set rcvbuf" polymorphic = "1">
501 Set socket option `rcvbuf`.
502 <argument name = "rcvbuf" type = "integer" />
503 </method>
504
505 <method name = "linger" polymorphic = "1">
506 Get socket option `linger`.
507 <return type = "integer" fresh = "1" />
508 </method>
509
510 <method name = "set linger" polymorphic = "1">
511 Set socket option `linger`.
512 <argument name = "linger" type = "integer" />
513 </method>
514
515 <method name = "reconnect ivl" polymorphic = "1">
516 Get socket option `reconnect_ivl`.
517 <return type = "integer" fresh = "1" />
518 </method>
519
520 <method name = "set reconnect ivl" polymorphic = "1">
521 Set socket option `reconnect_ivl`.
522 <argument name = "reconnect ivl" type = "integer" />
523 </method>
524
525 <method name = "reconnect ivl max" polymorphic = "1">
526 Get socket option `reconnect_ivl_max`.
527 <return type = "integer" fresh = "1" />
528 </method>
529
530 <method name = "set reconnect ivl max" polymorphic = "1">
531 Set socket option `reconnect_ivl_max`.
532 <argument name = "reconnect ivl max" type = "integer" />
533 </method>
534
535 <method name = "backlog" polymorphic = "1">
536 Get socket option `backlog`.
537 <return type = "integer" fresh = "1" />
538 </method>
539
540 <method name = "set backlog" polymorphic = "1">
541 Set socket option `backlog`.
542 <argument name = "backlog" type = "integer" />
543 </method>
544
545 <method name = "maxmsgsize" polymorphic = "1">
546 Get socket option `maxmsgsize`.
547 <return type = "integer" fresh = "1" />
548 </method>
549
550 <method name = "set maxmsgsize" polymorphic = "1">
551 Set socket option `maxmsgsize`.
552 <argument name = "maxmsgsize" type = "integer" />
553 </method>
554
555 <method name = "multicast hops" polymorphic = "1">
556 Get socket option `multicast_hops`.
557 <return type = "integer" fresh = "1" />
558 </method>
559
560 <method name = "set multicast hops" polymorphic = "1">
561 Set socket option `multicast_hops`.
562 <argument name = "multicast hops" type = "integer" />
563 </method>
564
565 <method name = "rcvtimeo" polymorphic = "1">
566 Get socket option `rcvtimeo`.
567 <return type = "integer" fresh = "1" />
568 </method>
569
570 <method name = "set rcvtimeo" polymorphic = "1">
571 Set socket option `rcvtimeo`.
572 <argument name = "rcvtimeo" type = "integer" />
573 </method>
574
575 <method name = "sndtimeo" polymorphic = "1">
576 Get socket option `sndtimeo`.
577 <return type = "integer" fresh = "1" />
578 </method>
579
580 <method name = "set sndtimeo" polymorphic = "1">
581 Set socket option `sndtimeo`.
582 <argument name = "sndtimeo" type = "integer" />
583 </method>
584
585 <method name = "set xpub verbose" polymorphic = "1">
586 Set socket option `xpub_verbose`.
587 <argument name = "xpub verbose" type = "integer" />
588 </method>
589
590 <method name = "tcp keepalive" polymorphic = "1">
591 Get socket option `tcp_keepalive`.
592 <return type = "integer" fresh = "1" />
593 </method>
594
595 <method name = "set tcp keepalive" polymorphic = "1">
596 Set socket option `tcp_keepalive`.
597 <argument name = "tcp keepalive" type = "integer" />
598 </method>
599
600 <method name = "tcp keepalive idle" polymorphic = "1">
601 Get socket option `tcp_keepalive_idle`.
602 <return type = "integer" fresh = "1" />
603 </method>
604
605 <method name = "set tcp keepalive idle" polymorphic = "1">
606 Set socket option `tcp_keepalive_idle`.
607 <argument name = "tcp keepalive idle" type = "integer" />
608 </method>
609
610 <method name = "tcp keepalive cnt" polymorphic = "1">
611 Get socket option `tcp_keepalive_cnt`.
612 <return type = "integer" fresh = "1" />
613 </method>
614
615 <method name = "set tcp keepalive cnt" polymorphic = "1">
616 Set socket option `tcp_keepalive_cnt`.
617 <argument name = "tcp keepalive cnt" type = "integer" />
618 </method>
619
620 <method name = "tcp keepalive intvl" polymorphic = "1">
621 Get socket option `tcp_keepalive_intvl`.
622 <return type = "integer" fresh = "1" />
623 </method>
624
625 <method name = "set tcp keepalive intvl" polymorphic = "1">
626 Set socket option `tcp_keepalive_intvl`.
627 <argument name = "tcp keepalive intvl" type = "integer" />
628 </method>
629
630 <method name = "tcp accept filter" polymorphic = "1">
631 Get socket option `tcp_accept_filter`.
632 <return type = "string" fresh = "1" />
633 </method>
634
635 <method name = "set tcp accept filter" polymorphic = "1">
636 Set socket option `tcp_accept_filter`.
637 <argument name = "tcp accept filter" type = "string" />
638 </method>
639
640 <method name = "rcvmore" polymorphic = "1">
641 Get socket option `rcvmore`.
642 <return type = "integer" fresh = "1" />
643 </method>
644
645 <method name = "fd" polymorphic = "1">
646 Get socket option `fd`.
647 <return type = "socket" fresh = "1" />
648 </method>
649
650 <method name = "events" polymorphic = "1">
651 Get socket option `events`.
652 <return type = "integer" fresh = "1" />
653 </method>
654
655 <method name = "last endpoint" polymorphic = "1">
656 Get socket option `last_endpoint`.
657 <return type = "string" fresh = "1" />
658 </method>
00 #! /bin/sh
11 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.68 for czmq 4.0.1.
2 # Generated by GNU Autoconf 2.68 for czmq 4.0.2.
33 #
44 # Report bugs to <zeromq-dev@lists.zeromq.org>.
55 #
569569 # Identity of this package.
570570 PACKAGE_NAME='czmq'
571571 PACKAGE_TARNAME='czmq'
572 PACKAGE_VERSION='4.0.1'
573 PACKAGE_STRING='czmq 4.0.1'
572 PACKAGE_VERSION='4.0.2'
573 PACKAGE_STRING='czmq 4.0.2'
574574 PACKAGE_BUGREPORT='zeromq-dev@lists.zeromq.org'
575575 PACKAGE_URL=''
576576
627627 ENABLE_CZMQ_SELFTEST_TRUE
628628 ENABLE_ZMAKECERT_FALSE
629629 ENABLE_ZMAKECERT_TRUE
630 ENABLE_DIST_CMAKEFILES_FALSE
631 ENABLE_DIST_CMAKEFILES_TRUE
630632 BUILD_DOC_FALSE
631633 BUILD_DOC_TRUE
632634 INSTALL_MAN_FALSE
787789 with_libzmq
788790 with_uuid
789791 with_docs
792 enable_dist_cmakefiles
790793 enable_zmakecert
791794 enable_czmq_selftest
792795 with_pkgconfigdir
793796 enable_drafts
797 enable_Werror
794798 '
795799 ac_precious_vars='build_alias
796800 host_alias
13521356 # Omit some internal or obsolete options to make the list less imposing.
13531357 # This message is too long to be a string in the A/UX 3.1 sh.
13541358 cat <<_ACEOF
1355 \`configure' configures czmq 4.0.1 to adapt to many kinds of systems.
1359 \`configure' configures czmq 4.0.2 to adapt to many kinds of systems.
13561360
13571361 Usage: $0 [OPTION]... [VAR=VALUE]...
13581362
14221426
14231427 if test -n "$ac_init_help"; then
14241428 case $ac_init_help in
1425 short | recursive ) echo "Configuration of czmq 4.0.1:";;
1429 short | recursive ) echo "Configuration of czmq 4.0.2:";;
14261430 esac
14271431 cat <<\_ACEOF
14281432
14391443 --enable-fast-install[=PKGS]
14401444 optimize for fast installation [default=yes]
14411445 --disable-libtool-lock avoid locking (might break parallel builds)
1446 --enable-dist_cmakefiles
1447 Distribute CMakeLists.txt and related files [default
1448 depends: on if present and not cross compiling]
14421449 --enable-zmakecert Compile and install 'zmakecert' [default=yes]
14431450 --enable-czmq_selftest Compile 'czmq_selftest' in src [default=yes]
14441451 --enable-drafts Build and install draft classes and methods
14451452 [default=yes]
1453 --enable-Werror Add -Wall -Werror to GCC/GXX arguments [default=no;
1454 default=auto if nothing specified]
14461455
14471456 Optional Packages:
14481457 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
15531562 test -n "$ac_init_help" && exit $ac_status
15541563 if $ac_init_version; then
15551564 cat <<\_ACEOF
1556 czmq configure 4.0.1
1565 czmq configure 4.0.2
15571566 generated by GNU Autoconf 2.68
15581567
15591568 Copyright (C) 2010 Free Software Foundation, Inc.
20292038 This file contains any messages produced by compilers while
20302039 running configure, to aid debugging if configure makes a mistake.
20312040
2032 It was created by czmq $as_me 4.0.1, which was
2041 It was created by czmq $as_me 4.0.2, which was
20332042 generated by GNU Autoconf 2.68. Invocation command line was
20342043
20352044 $ $0 $@
28482857
28492858 # Define the identity of the package.
28502859 PACKAGE='czmq'
2851 VERSION='4.0.1'
2860 VERSION='4.0.2'
28522861
28532862
28542863 cat >>confdefs.h <<_ACEOF
30343043 #
30353044 # Libtool -version-info (ABI version)
30363045 #
3037 # Currently 2.0.1 ("stable"). Don't change this unless you
3046 # Currently 4:2:0 ("stable"). Don't change this unless you
30383047 # know exactly what you're doing and have read and understand
30393048 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
30403049 #
30413050 # libczmq -version-info
3042 LTVER="4:0:0"
3051 LTVER="4:2:0"
30433052
30443053
30453054 # Capture c flags
1245512464 fi
1245612465 fi
1245712466
12467 # Optional project-local hook (acinclude.m4, add AC_DEFUN([AX_PROJECT_LOCAL_HOOK], [whatever]) )
1245812468
1245912469 for ac_header in pthread.h
1246012470 do :
1251212522
1251312523 fi
1251412524
12515 # Optional project-local hook (acinclude.m4)
12525
1251612526
1251712527 # Code coverage
1251812528
1326313273 *solaris*)
1326413274 # Define on Solaris to enable all library features
1326513275 CPPFLAGS="-D_PTHREADS $CPPFLAGS"
13276 # Allow definitions of common OS-provided functions that are not in old standards
13277 CPPFLAGS="-D__EXTENSIONS__ $CPPFLAGS"
1326613278
1326713279 $as_echo "#define CZMQ_HAVE_SOLARIS 1" >>confdefs.h
1326813280
1414614158 fi
1414714159
1414814160
14161 # Check whether --enable-dist_cmakefiles was given.
14162 if test "${enable_dist_cmakefiles+set}" = set; then :
14163 enableval=$enable_dist_cmakefiles; enable_dist_cmakefiles=$enableval
14164 else
14165 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for presence of CMake recipes" >&5
14166 $as_echo_n "checking for presence of CMake recipes... " >&6; }
14167 if test "x$cross_compiling" = "xyes"; then
14168 enable_dist_cmakefiles=no
14169 else
14170 as_ac_File=`$as_echo "ac_cv_file_$srcdir/CMakeLists.txt" | $as_tr_sh`
14171 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $srcdir/CMakeLists.txt" >&5
14172 $as_echo_n "checking for $srcdir/CMakeLists.txt... " >&6; }
14173 if eval \${$as_ac_File+:} false; then :
14174 $as_echo_n "(cached) " >&6
14175 else
14176 test "$cross_compiling" = yes &&
14177 as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5
14178 if test -r "$srcdir/CMakeLists.txt"; then
14179 eval "$as_ac_File=yes"
14180 else
14181 eval "$as_ac_File=no"
14182 fi
14183 fi
14184 eval ac_res=\$$as_ac_File
14185 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
14186 $as_echo "$ac_res" >&6; }
14187 if eval test \"x\$"$as_ac_File"\" = x"yes"; then :
14188 enable_dist_cmakefiles=yes
14189 else
14190 enable_dist_cmakefiles=no
14191 fi
14192
14193 fi
14194 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_dist_cmakefiles" >&5
14195 $as_echo "$enable_dist_cmakefiles" >&6; }
14196 fi
14197
14198 if test "x$enable_dist_cmakefiles" = "xyes"; then
14199 ENABLE_DIST_CMAKEFILES_TRUE=
14200 ENABLE_DIST_CMAKEFILES_FALSE='#'
14201 else
14202 ENABLE_DIST_CMAKEFILES_TRUE='#'
14203 ENABLE_DIST_CMAKEFILES_FALSE=
14204 fi
14205
14206
1414914207 # Check for zmakecert intent
1415014208 # Check whether --enable-zmakecert was given.
1415114209 if test "${enable_zmakecert+set}" = set; then :
1431014368 { $as_echo "$as_me:${as_lineno-$LINENO}: Building stable and legacy API (no draft API)" >&5
1431114369 $as_echo "$as_me: Building stable and legacy API (no draft API)" >&6;}
1431214370 pkg_config_defines=""
14371
14372 fi
14373
14374 # Check whether --enable-Werror was given.
14375 if test "${enable_Werror+set}" = set; then :
14376 enableval=$enable_Werror; if test -n "$enableval"; then :
14377 enable_Werror=$enableval
14378 else
14379 enable_Werror=auto
14380 fi
14381 else
14382 enable_Werror=no
14383 fi
14384
14385
14386 if test "x$enable_Werror" = "xyes" || test "x$enable_Werror" = "xauto"; then :
14387 if test -n "$CC"; then :
14388 if $CC --version 2>&1 | grep 'Free Software Foundation' > /dev/null; then :
14389 { $as_echo "$as_me:${as_lineno-$LINENO}: Enabling pedantic errors for GNU C" >&5
14390 $as_echo "$as_me: Enabling pedantic errors for GNU C" >&6;}
14391 CFLAGS="$CFLAGS -Wall -Werror"
14392 else
14393 { $as_echo "$as_me:${as_lineno-$LINENO}: Not enabling pedantic errors: compiler not supported by this recipe (not GNU C)" >&5
14394 $as_echo "$as_me: Not enabling pedantic errors: compiler not supported by this recipe (not GNU C)" >&6;}
14395 if test "x$enable_Werror" = "xyes"; then :
14396 as_fn_error $? "--enable-Werror=yes was requested and can not be satisfied for C: $CC" "$LINENO" 5
14397 fi
14398
14399 fi
14400 fi
14401 if test -n "$CXX"; then :
14402 if $CXX --version 2>&1 | grep 'Free Software Foundation' > /dev/null; then :
14403 { $as_echo "$as_me:${as_lineno-$LINENO}: Enabling pedantic errors for GNU C++" >&5
14404 $as_echo "$as_me: Enabling pedantic errors for GNU C++" >&6;}
14405 CXXFLAGS="$CXXFLAGS -Wall -Werror"
14406 else
14407 { $as_echo "$as_me:${as_lineno-$LINENO}: Not enabling pedantic errors: compiler not supported by this recipe (not GNU C++)" >&5
14408 $as_echo "$as_me: Not enabling pedantic errors: compiler not supported by this recipe (not GNU C++)" >&6;}
14409 if test "x$enable_Werror" = "xyes"; then :
14410 as_fn_error $? "--enable-Werror=yes was requested and can not be satisfied for C++: $CXX" "$LINENO" 5
14411 fi
14412
14413 fi
14414 fi
14415 if test -n "$CPP"; then :
14416 if $CPP --version 2>&1 | grep 'Free Software Foundation' > /dev/null; then :
14417 { $as_echo "$as_me:${as_lineno-$LINENO}: Enabling pedantic errors for GNU CPP preprocessor" >&5
14418 $as_echo "$as_me: Enabling pedantic errors for GNU CPP preprocessor" >&6;}
14419 CPPFLAGS="$CPPFLAGS -Wall -Werror"
14420 else
14421 { $as_echo "$as_me:${as_lineno-$LINENO}: Not enabling pedantic errors: preprocessor not supported by this recipe (not GNU CPP)" >&5
14422 $as_echo "$as_me: Not enabling pedantic errors: preprocessor not supported by this recipe (not GNU CPP)" >&6;}
14423 if test "x$enable_Werror" = "xyes"; then :
14424 as_fn_error $? "--enable-Werror=yes was requested and can not be satisfied for CPP: $CPP" "$LINENO" 5
14425 fi
14426
14427 fi
14428 fi
1431314429
1431414430 fi
1431514431
1448414600 as_fn_error $? "conditional \"BUILD_DOC\" was never defined.
1448514601 Usually this means the macro was only invoked conditionally." "$LINENO" 5
1448614602 fi
14603 if test -z "${ENABLE_DIST_CMAKEFILES_TRUE}" && test -z "${ENABLE_DIST_CMAKEFILES_FALSE}"; then
14604 as_fn_error $? "conditional \"ENABLE_DIST_CMAKEFILES\" was never defined.
14605 Usually this means the macro was only invoked conditionally." "$LINENO" 5
14606 fi
1448714607 if test -z "${ENABLE_ZMAKECERT_TRUE}" && test -z "${ENABLE_ZMAKECERT_FALSE}"; then
1448814608 as_fn_error $? "conditional \"ENABLE_ZMAKECERT\" was never defined.
1448914609 Usually this means the macro was only invoked conditionally." "$LINENO" 5
1490515025 # report actual input values of CONFIG_FILES etc. instead of their
1490615026 # values after options handling.
1490715027 ac_log="
14908 This file was extended by czmq $as_me 4.0.1, which was
15028 This file was extended by czmq $as_me 4.0.2, which was
1490915029 generated by GNU Autoconf 2.68. Invocation command line was
1491015030
1491115031 CONFIG_FILES = $CONFIG_FILES
1497115091 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
1497215092 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
1497315093 ac_cs_version="\\
14974 czmq config.status 4.0.1
15094 czmq config.status 4.0.2
1497515095 configured by $0, generated by GNU Autoconf 2.68,
1497615096 with options \\"\$ac_cs_config\\"
1497715097
1679516915 echo
1679616916 echo C compiler.................... : $CC
1679716917 echo C compiler flags.............. : $CFLAGS
16918 echo C++ compiler.................. : $CXX
16919 echo C++ compiler flags............ : $CXXFLAGS
1679816920 echo Configure date................ : $BUILD_DATE
1679916921 echo Build architecture............ : $BUILD_ARCH
1680016922 echo Build docs.................... : $czmq_build_doc
1681616938 echo '##########################################################################'
1681716939
1681816940 echo
16819 echo Configure complete! Now procced with:
16941 echo Configure complete! Now proceed with:
1682016942 echo " - 'make' compile the project"
1682116943 echo " - 'make check' run the project's selftest"
1682216944 echo " - 'make install' install the project to $prefix"
66 # Process this file with autoconf to produce a configure script.
77 AC_PREREQ(2.61)
88 #
9 AC_INIT([czmq],[4.0.1],[zeromq-dev@lists.zeromq.org])
9 AC_INIT([czmq],[4.0.2],[zeromq-dev@lists.zeromq.org])
1010
1111 AC_CONFIG_AUX_DIR(config)
1212 AC_CONFIG_MACRO_DIR(config)
3030 #
3131 # Libtool -version-info (ABI version)
3232 #
33 # Currently 2.0.1 ("stable"). Don't change this unless you
33 # Currently 4:2:0 ("stable"). Don't change this unless you
3434 # know exactly what you're doing and have read and understand
3535 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
3636 #
3737 # libczmq -version-info
38 LTVER="4:0:0"
38 LTVER="4:2:0"
3939 AC_SUBST(LTVER)
4040
4141 # Capture c flags
5151 AC_PROG_AWK
5252 PKG_PROG_PKG_CONFIG
5353
54 AX_PROJECT_LOCAL_HOOK # Optional project-local hook (acinclude.m4)
54 # Optional project-local hook (acinclude.m4, add AC_DEFUN([AX_PROJECT_LOCAL_HOOK], [whatever]) )
55 AX_PROJECT_LOCAL_HOOK
5556
5657 # Code coverage
5758 AC_ARG_WITH(gcov, [AS_HELP_STRING([--with-gcov=yes/no],
257258 *solaris*)
258259 # Define on Solaris to enable all library features
259260 CPPFLAGS="-D_PTHREADS $CPPFLAGS"
261 # Allow definitions of common OS-provided functions that are not in old standards
262 CPPFLAGS="-D__EXTENSIONS__ $CPPFLAGS"
260263 AC_DEFINE(CZMQ_HAVE_SOLARIS, 1, [Have Solaris OS])
261264 CFLAGS="${CFLAGS} -lsocket -lssp"
262265 ;;
365368 AM_CONDITIONAL(INSTALL_MAN, test "x$czmq_install_man" = "xyes")
366369 AM_CONDITIONAL(BUILD_DOC, test "x$czmq_build_doc" = "xyes")
367370
371 AC_ARG_ENABLE([dist_cmakefiles],
372 AS_HELP_STRING([--enable-dist_cmakefiles],
373 [Distribute CMakeLists.txt and related files [default depends: on if present and not cross compiling]]),
374 [enable_dist_cmakefiles=$enableval],
375 [AC_MSG_CHECKING([for presence of CMake recipes])
376 if test "x$cross_compiling" = "xyes"; then
377 enable_dist_cmakefiles=no
378 else
379 AC_CHECK_FILE($srcdir/CMakeLists.txt, [enable_dist_cmakefiles=yes], [enable_dist_cmakefiles=no])
380 fi
381 AC_MSG_RESULT([$enable_dist_cmakefiles])])
382 AM_CONDITIONAL(ENABLE_DIST_CMAKEFILES, test "x$enable_dist_cmakefiles" = "xyes")
383
368384 # Check for zmakecert intent
369385 AC_ARG_ENABLE([zmakecert],
370386 AS_HELP_STRING([--enable-zmakecert],
423439 AC_SUBST(pkg_config_defines, "")
424440 fi
425441
442 AC_ARG_ENABLE([Werror],
443 AS_HELP_STRING([--enable-Werror],
444 [Add -Wall -Werror to GCC/GXX arguments [default=no; default=auto if nothing specified]]),
445 [AS_IF([test -n "$enableval"], [enable_Werror=$enableval], [enable_Werror=auto])],
446 [enable_Werror=no])
447
448 AS_IF([test "x$enable_Werror" = "xyes" || test "x$enable_Werror" = "xauto"],
449 [AS_IF([test -n "$CC"],[AS_IF([$CC --version 2>&1 | grep 'Free Software Foundation' > /dev/null],
450 [AC_MSG_NOTICE([Enabling pedantic errors for GNU C])
451 CFLAGS="$CFLAGS -Wall -Werror"],
452 [AC_MSG_NOTICE([Not enabling pedantic errors: compiler not supported by this recipe (not GNU C)])
453 AS_IF([test "x$enable_Werror" = "xyes"], [AC_MSG_ERROR([--enable-Werror=yes was requested and can not be satisfied for C: $CC])])
454 ])])
455 AS_IF([test -n "$CXX"],[AS_IF([$CXX --version 2>&1 | grep 'Free Software Foundation' > /dev/null],
456 [AC_MSG_NOTICE([Enabling pedantic errors for GNU C++])
457 CXXFLAGS="$CXXFLAGS -Wall -Werror"],
458 [AC_MSG_NOTICE([Not enabling pedantic errors: compiler not supported by this recipe (not GNU C++)])
459 AS_IF([test "x$enable_Werror" = "xyes"], [AC_MSG_ERROR([--enable-Werror=yes was requested and can not be satisfied for C++: $CXX])])
460 ])])
461 AS_IF([test -n "$CPP"],[AS_IF([$CPP --version 2>&1 | grep 'Free Software Foundation' > /dev/null],
462 [AC_MSG_NOTICE([Enabling pedantic errors for GNU CPP preprocessor])
463 CPPFLAGS="$CPPFLAGS -Wall -Werror"],
464 [AC_MSG_NOTICE([Not enabling pedantic errors: preprocessor not supported by this recipe (not GNU CPP)])
465 AS_IF([test "x$enable_Werror" = "xyes"], [AC_MSG_ERROR([--enable-Werror=yes was requested and can not be satisfied for CPP: $CPP])])
466 ])])
467 ])
468
426469 # Specify output files
427470 AC_CONFIG_FILES([Makefile
428471 doc/Makefile
463506 echo
464507 echo C compiler.................... : $CC
465508 echo C compiler flags.............. : $CFLAGS
509 echo C++ compiler.................. : $CXX
510 echo C++ compiler flags............ : $CXXFLAGS
466511 echo Configure date................ : $BUILD_DATE
467512 echo Build architecture............ : $BUILD_ARCH
468513 echo Build docs.................... : $czmq_build_doc
484529 echo '##########################################################################'
485530
486531 echo
487 echo Configure complete! Now procced with:
532 echo Configure complete! Now proceed with:
488533 echo " - 'make' compile the project"
489534 echo " - 'make check' run the project's selftest"
490535 echo " - 'make install' install the project to $prefix"
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 # NOTE: stub doc/czmq.txt is generated by GSL from project.xml and
5 # then comitted to SCM and maintained manually to describe the project.
46 MAN1 = zmakecert.1
57 MAN3 = zactor.3 zarmour.3 zcert.3 zcertstore.3 zchunk.3 zclock.3 zconfig.3 zdigest.3 zdir.3 zdir_patch.3 zfile.3 zframe.3 zhash.3 zhashx.3 ziflist.3 zlist.3 zlistx.3 zloop.3 zmsg.3 zpoller.3 zproc.3 zsock.3 zstr.3 ztimerset.3 ztrie.3 zuuid.3 zauth.3 zbeacon.3 zgossip.3 zmonitor.3 zproxy.3 zrex.3 zsys.3
68 MAN7 = czmq.7
79 MAN_DOC = $(MAN1) $(MAN3) $(MAN7)
810
9 MAN_TXT = $(MAN1:%.1=%.txt)
10 MAN_TXT += $(MAN3:%.3=%.txt)
11 MAN_TXT += $(MAN7:%.7=%.txt)
11 # Assumption: the .7 pages only cover the project and are maintained manually
12 MAN_TXT = $(MAN7:%.7=%.txt)
1213
13 EXTRA_DIST = asciidoc.conf $(MAN_TXT)
14 EXTRA_DIST = asciidoc.conf mkman
1415
1516 if INSTALL_MAN
1617 dist_man_MANS = $(MAN_DOC)
1718 endif
1819
1920 if BUILD_DOC
21 MAN_TXT += $(MAN1:%.1=%.txt)
22 MAN_TXT += $(MAN3:%.3=%.txt)
23
2024 DISTCLEANFILES = $(MAN_DOC)
2125
2226 dist-hook : $(MAN_DOC)
2327
2428 SUFFIXES=.txt .xml .1 .3 .7
29
30 $(builddir)/czmq.txt: $(srcdir)/czmq.txt
31 if [ "$@" != "$<" ] || [ ! -s "$@" ] ; then \
32 cp "$<" "$@" || exit ; \
33 fi
2534
2635 .txt.xml:
2736 asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \
3342 .xml.7:
3443 xmlto man $<
3544
36 zactor.txt:
37 ./mkman $@
38 zarmour.txt:
39 ./mkman $@
40 zcert.txt:
41 ./mkman $@
42 zcertstore.txt:
43 ./mkman $@
44 zchunk.txt:
45 ./mkman $@
46 zclock.txt:
47 ./mkman $@
48 zconfig.txt:
49 ./mkman $@
50 zdigest.txt:
51 ./mkman $@
52 zdir.txt:
53 ./mkman $@
54 zdir_patch.txt:
55 ./mkman $@
56 zfile.txt:
57 ./mkman $@
58 zframe.txt:
59 ./mkman $@
60 zhash.txt:
61 ./mkman $@
62 zhashx.txt:
63 ./mkman $@
64 ziflist.txt:
65 ./mkman $@
66 zlist.txt:
67 ./mkman $@
68 zlistx.txt:
69 ./mkman $@
70 zloop.txt:
71 ./mkman $@
72 zmsg.txt:
73 ./mkman $@
74 zpoller.txt:
75 ./mkman $@
76 zproc.txt:
77 ./mkman $@
78 zsock.txt:
79 ./mkman $@
80 zstr.txt:
81 ./mkman $@
82 ztimerset.txt:
83 ./mkman $@
84 ztrie.txt:
85 ./mkman $@
86 zuuid.txt:
87 ./mkman $@
88 zauth.txt:
89 ./mkman $@
90 zbeacon.txt:
91 ./mkman $@
92 zgossip.txt:
93 ./mkman $@
94 zmonitor.txt:
95 ./mkman $@
96 zproxy.txt:
97 ./mkman $@
98 zrex.txt:
99 ./mkman $@
100 zsys.txt:
101 ./mkman $@
102 zmakecert.txt:
103 ./mkman zmakecert $@
45 GENERATED_DOCS =
46 .txt.doc:
47 # No-op, docs and texts are generated by mkman in one shot - just
48 # make a dependency that can not parallelize and break stuff
49
50 GENERATED_DOCS += zactor.txt zactor.doc
51 zactor.txt: $(top_srcdir)/src/zactor.c
52 $(srcdir)/mkman zactor $(builddir)/zactor $(srcdir)/..
53
54 GENERATED_DOCS += zarmour.txt zarmour.doc
55 zarmour.txt: $(top_srcdir)/src/zarmour.c
56 $(srcdir)/mkman zarmour $(builddir)/zarmour $(srcdir)/..
57
58 GENERATED_DOCS += zcert.txt zcert.doc
59 zcert.txt: $(top_srcdir)/src/zcert.c
60 $(srcdir)/mkman zcert $(builddir)/zcert $(srcdir)/..
61
62 GENERATED_DOCS += zcertstore.txt zcertstore.doc
63 zcertstore.txt: $(top_srcdir)/src/zcertstore.c
64 $(srcdir)/mkman zcertstore $(builddir)/zcertstore $(srcdir)/..
65
66 GENERATED_DOCS += zchunk.txt zchunk.doc
67 zchunk.txt: $(top_srcdir)/src/zchunk.c
68 $(srcdir)/mkman zchunk $(builddir)/zchunk $(srcdir)/..
69
70 GENERATED_DOCS += zclock.txt zclock.doc
71 zclock.txt: $(top_srcdir)/src/zclock.c
72 $(srcdir)/mkman zclock $(builddir)/zclock $(srcdir)/..
73
74 GENERATED_DOCS += zconfig.txt zconfig.doc
75 zconfig.txt: $(top_srcdir)/src/zconfig.c
76 $(srcdir)/mkman zconfig $(builddir)/zconfig $(srcdir)/..
77
78 GENERATED_DOCS += zdigest.txt zdigest.doc
79 zdigest.txt: $(top_srcdir)/src/zdigest.c
80 $(srcdir)/mkman zdigest $(builddir)/zdigest $(srcdir)/..
81
82 GENERATED_DOCS += zdir.txt zdir.doc
83 zdir.txt: $(top_srcdir)/src/zdir.c
84 $(srcdir)/mkman zdir $(builddir)/zdir $(srcdir)/..
85
86 GENERATED_DOCS += zdir_patch.txt zdir_patch.doc
87 zdir_patch.txt: $(top_srcdir)/src/zdir_patch.c
88 $(srcdir)/mkman zdir_patch $(builddir)/zdir_patch $(srcdir)/..
89
90 GENERATED_DOCS += zfile.txt zfile.doc
91 zfile.txt: $(top_srcdir)/src/zfile.c
92 $(srcdir)/mkman zfile $(builddir)/zfile $(srcdir)/..
93
94 GENERATED_DOCS += zframe.txt zframe.doc
95 zframe.txt: $(top_srcdir)/src/zframe.c
96 $(srcdir)/mkman zframe $(builddir)/zframe $(srcdir)/..
97
98 GENERATED_DOCS += zhash.txt zhash.doc
99 zhash.txt: $(top_srcdir)/src/zhash.c
100 $(srcdir)/mkman zhash $(builddir)/zhash $(srcdir)/..
101
102 GENERATED_DOCS += zhashx.txt zhashx.doc
103 zhashx.txt: $(top_srcdir)/src/zhashx.c
104 $(srcdir)/mkman zhashx $(builddir)/zhashx $(srcdir)/..
105
106 GENERATED_DOCS += ziflist.txt ziflist.doc
107 ziflist.txt: $(top_srcdir)/src/ziflist.c
108 $(srcdir)/mkman ziflist $(builddir)/ziflist $(srcdir)/..
109
110 GENERATED_DOCS += zlist.txt zlist.doc
111 zlist.txt: $(top_srcdir)/src/zlist.c
112 $(srcdir)/mkman zlist $(builddir)/zlist $(srcdir)/..
113
114 GENERATED_DOCS += zlistx.txt zlistx.doc
115 zlistx.txt: $(top_srcdir)/src/zlistx.c
116 $(srcdir)/mkman zlistx $(builddir)/zlistx $(srcdir)/..
117
118 GENERATED_DOCS += zloop.txt zloop.doc
119 zloop.txt: $(top_srcdir)/src/zloop.c
120 $(srcdir)/mkman zloop $(builddir)/zloop $(srcdir)/..
121
122 GENERATED_DOCS += zmsg.txt zmsg.doc
123 zmsg.txt: $(top_srcdir)/src/zmsg.c
124 $(srcdir)/mkman zmsg $(builddir)/zmsg $(srcdir)/..
125
126 GENERATED_DOCS += zpoller.txt zpoller.doc
127 zpoller.txt: $(top_srcdir)/src/zpoller.c
128 $(srcdir)/mkman zpoller $(builddir)/zpoller $(srcdir)/..
129
130 GENERATED_DOCS += zproc.txt zproc.doc
131 zproc.txt: $(top_srcdir)/src/zproc.c
132 $(srcdir)/mkman zproc $(builddir)/zproc $(srcdir)/..
133
134 GENERATED_DOCS += zsock.txt zsock.doc
135 zsock.txt: $(top_srcdir)/src/zsock.c
136 $(srcdir)/mkman zsock $(builddir)/zsock $(srcdir)/..
137
138 GENERATED_DOCS += zstr.txt zstr.doc
139 zstr.txt: $(top_srcdir)/src/zstr.c
140 $(srcdir)/mkman zstr $(builddir)/zstr $(srcdir)/..
141
142 GENERATED_DOCS += ztimerset.txt ztimerset.doc
143 ztimerset.txt: $(top_srcdir)/src/ztimerset.c
144 $(srcdir)/mkman ztimerset $(builddir)/ztimerset $(srcdir)/..
145
146 GENERATED_DOCS += ztrie.txt ztrie.doc
147 ztrie.txt: $(top_srcdir)/src/ztrie.c
148 $(srcdir)/mkman ztrie $(builddir)/ztrie $(srcdir)/..
149
150 GENERATED_DOCS += zuuid.txt zuuid.doc
151 zuuid.txt: $(top_srcdir)/src/zuuid.c
152 $(srcdir)/mkman zuuid $(builddir)/zuuid $(srcdir)/..
153
154 GENERATED_DOCS += zauth.txt zauth.doc
155 zauth.txt: $(top_srcdir)/src/zauth.c
156 $(srcdir)/mkman zauth $(builddir)/zauth $(srcdir)/..
157
158 GENERATED_DOCS += zbeacon.txt zbeacon.doc
159 zbeacon.txt: $(top_srcdir)/src/zbeacon.c
160 $(srcdir)/mkman zbeacon $(builddir)/zbeacon $(srcdir)/..
161
162 GENERATED_DOCS += zgossip.txt zgossip.doc
163 zgossip.txt: $(top_srcdir)/src/zgossip.c
164 $(srcdir)/mkman zgossip $(builddir)/zgossip $(srcdir)/..
165
166 GENERATED_DOCS += zmonitor.txt zmonitor.doc
167 zmonitor.txt: $(top_srcdir)/src/zmonitor.c
168 $(srcdir)/mkman zmonitor $(builddir)/zmonitor $(srcdir)/..
169
170 GENERATED_DOCS += zproxy.txt zproxy.doc
171 zproxy.txt: $(top_srcdir)/src/zproxy.c
172 $(srcdir)/mkman zproxy $(builddir)/zproxy $(srcdir)/..
173
174 GENERATED_DOCS += zrex.txt zrex.doc
175 zrex.txt: $(top_srcdir)/src/zrex.c
176 $(srcdir)/mkman zrex $(builddir)/zrex $(srcdir)/..
177
178 GENERATED_DOCS += zsys.txt zsys.doc
179 zsys.txt: $(top_srcdir)/src/zsys.c
180 $(srcdir)/mkman zsys $(builddir)/zsys $(srcdir)/..
181
182 GENERATED_DOCS += zmakecert.txt zmakecert.doc
183 zmakecert.txt: $(top_srcdir)/src/zmakecert.c
184 $(srcdir)/mkman zmakecert $(builddir)/zmakecert $(srcdir)/..
185
186
104187 clean:
105 rm -f *.1 *.3 *.7
106 ./mkman zactor
107 ./mkman zarmour
108 ./mkman zcert
109 ./mkman zcertstore
110 ./mkman zchunk
111 ./mkman zclock
112 ./mkman zconfig
113 ./mkman zdigest
114 ./mkman zdir
115 ./mkman zdir_patch
116 ./mkman zfile
117 ./mkman zframe
118 ./mkman zhash
119 ./mkman zhashx
120 ./mkman ziflist
121 ./mkman zlist
122 ./mkman zlistx
123 ./mkman zloop
124 ./mkman zmsg
125 ./mkman zpoller
126 ./mkman zproc
127 ./mkman zsock
128 ./mkman zstr
129 ./mkman ztimerset
130 ./mkman ztrie
131 ./mkman zuuid
132 ./mkman zauth
133 ./mkman zbeacon
134 ./mkman zgossip
135 ./mkman zmonitor
136 ./mkman zproxy
137 ./mkman zrex
138 ./mkman zsys
139 ./mkman zmakecert zmakecert
188 rm -f *.1 *.3 *.7 $(GENERATED_DOCS)
189 doc: $(GENERATED_DOCS)
140190
141191 endif
192
193 EXTRA_DIST += $(MAN_TXT)
142194 ################################################################################
143195 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
144196 # Read the zproject/README.md for information about making permanent changes. #
3232 POST_UNINSTALL = :
3333 build_triplet = @build@
3434 host_triplet = @host@
35 @BUILD_DOC_TRUE@am__append_1 = $(MAN1:%.1=%.txt) $(MAN3:%.3=%.txt)
3536 subdir = doc
3637 DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.am \
3738 $(srcdir)/Makefile.in
231232 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
232233 # Read the zproject/README.md for information about making permanent changes. #
233234 ################################################################################
235 # NOTE: stub doc/czmq.txt is generated by GSL from project.xml and
236 # then comitted to SCM and maintained manually to describe the project.
234237 MAN1 = zmakecert.1
235238 MAN3 = zactor.3 zarmour.3 zcert.3 zcertstore.3 zchunk.3 zclock.3 zconfig.3 zdigest.3 zdir.3 zdir_patch.3 zfile.3 zframe.3 zhash.3 zhashx.3 ziflist.3 zlist.3 zlistx.3 zloop.3 zmsg.3 zpoller.3 zproc.3 zsock.3 zstr.3 ztimerset.3 ztrie.3 zuuid.3 zauth.3 zbeacon.3 zgossip.3 zmonitor.3 zproxy.3 zrex.3 zsys.3
236239 MAN7 = czmq.7
237240 MAN_DOC = $(MAN1) $(MAN3) $(MAN7)
238 MAN_TXT = $(MAN1:%.1=%.txt) $(MAN3:%.3=%.txt) $(MAN7:%.7=%.txt)
239 EXTRA_DIST = asciidoc.conf $(MAN_TXT)
241
242 # Assumption: the .7 pages only cover the project and are maintained manually
243 MAN_TXT = $(MAN7:%.7=%.txt) $(am__append_1)
244 EXTRA_DIST = asciidoc.conf mkman $(MAN_TXT)
240245 @INSTALL_MAN_TRUE@dist_man_MANS = $(MAN_DOC)
241246 @BUILD_DOC_TRUE@DISTCLEANFILES = $(MAN_DOC)
242247 @BUILD_DOC_TRUE@SUFFIXES = .txt .xml .1 .3 .7
248 # No-op, docs and texts are generated by mkman in one shot - just
249 # make a dependency that can not parallelize and break stuff
250 @BUILD_DOC_TRUE@GENERATED_DOCS = zactor.txt zactor.doc zarmour.txt \
251 @BUILD_DOC_TRUE@ zarmour.doc zcert.txt zcert.doc zcertstore.txt \
252 @BUILD_DOC_TRUE@ zcertstore.doc zchunk.txt zchunk.doc \
253 @BUILD_DOC_TRUE@ zclock.txt zclock.doc zconfig.txt zconfig.doc \
254 @BUILD_DOC_TRUE@ zdigest.txt zdigest.doc zdir.txt zdir.doc \
255 @BUILD_DOC_TRUE@ zdir_patch.txt zdir_patch.doc zfile.txt \
256 @BUILD_DOC_TRUE@ zfile.doc zframe.txt zframe.doc zhash.txt \
257 @BUILD_DOC_TRUE@ zhash.doc zhashx.txt zhashx.doc ziflist.txt \
258 @BUILD_DOC_TRUE@ ziflist.doc zlist.txt zlist.doc zlistx.txt \
259 @BUILD_DOC_TRUE@ zlistx.doc zloop.txt zloop.doc zmsg.txt \
260 @BUILD_DOC_TRUE@ zmsg.doc zpoller.txt zpoller.doc zproc.txt \
261 @BUILD_DOC_TRUE@ zproc.doc zsock.txt zsock.doc zstr.txt \
262 @BUILD_DOC_TRUE@ zstr.doc ztimerset.txt ztimerset.doc ztrie.txt \
263 @BUILD_DOC_TRUE@ ztrie.doc zuuid.txt zuuid.doc zauth.txt \
264 @BUILD_DOC_TRUE@ zauth.doc zbeacon.txt zbeacon.doc zgossip.txt \
265 @BUILD_DOC_TRUE@ zgossip.doc zmonitor.txt zmonitor.doc \
266 @BUILD_DOC_TRUE@ zproxy.txt zproxy.doc zrex.txt zrex.doc \
267 @BUILD_DOC_TRUE@ zsys.txt zsys.doc zmakecert.txt zmakecert.doc
243268 all: all-am
244269
245270 .SUFFIXES:
246 .SUFFIXES: .txt .xml .1 .3 .7
271 .SUFFIXES: .txt .xml .1 .3 .7 .doc
247272 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
248273 @for dep in $?; do \
249274 case '$(am__configure_deps)' in \
566591
567592 @BUILD_DOC_TRUE@dist-hook : $(MAN_DOC)
568593
594 @BUILD_DOC_TRUE@$(builddir)/czmq.txt: $(srcdir)/czmq.txt
595 @BUILD_DOC_TRUE@ if [ "$@" != "$<" ] || [ ! -s "$@" ] ; then \
596 @BUILD_DOC_TRUE@ cp "$<" "$@" || exit ; \
597 @BUILD_DOC_TRUE@ fi
598
569599 @BUILD_DOC_TRUE@.txt.xml:
570600 @BUILD_DOC_TRUE@ asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \
571601 @BUILD_DOC_TRUE@ -aczmq_version=@PACKAGE_VERSION@ -o$@ $<
575605 @BUILD_DOC_TRUE@ xmlto man $<
576606 @BUILD_DOC_TRUE@.xml.7:
577607 @BUILD_DOC_TRUE@ xmlto man $<
578
579 @BUILD_DOC_TRUE@zactor.txt:
580 @BUILD_DOC_TRUE@ ./mkman $@
581 @BUILD_DOC_TRUE@zarmour.txt:
582 @BUILD_DOC_TRUE@ ./mkman $@
583 @BUILD_DOC_TRUE@zcert.txt:
584 @BUILD_DOC_TRUE@ ./mkman $@
585 @BUILD_DOC_TRUE@zcertstore.txt:
586 @BUILD_DOC_TRUE@ ./mkman $@
587 @BUILD_DOC_TRUE@zchunk.txt:
588 @BUILD_DOC_TRUE@ ./mkman $@
589 @BUILD_DOC_TRUE@zclock.txt:
590 @BUILD_DOC_TRUE@ ./mkman $@
591 @BUILD_DOC_TRUE@zconfig.txt:
592 @BUILD_DOC_TRUE@ ./mkman $@
593 @BUILD_DOC_TRUE@zdigest.txt:
594 @BUILD_DOC_TRUE@ ./mkman $@
595 @BUILD_DOC_TRUE@zdir.txt:
596 @BUILD_DOC_TRUE@ ./mkman $@
597 @BUILD_DOC_TRUE@zdir_patch.txt:
598 @BUILD_DOC_TRUE@ ./mkman $@
599 @BUILD_DOC_TRUE@zfile.txt:
600 @BUILD_DOC_TRUE@ ./mkman $@
601 @BUILD_DOC_TRUE@zframe.txt:
602 @BUILD_DOC_TRUE@ ./mkman $@
603 @BUILD_DOC_TRUE@zhash.txt:
604 @BUILD_DOC_TRUE@ ./mkman $@
605 @BUILD_DOC_TRUE@zhashx.txt:
606 @BUILD_DOC_TRUE@ ./mkman $@
607 @BUILD_DOC_TRUE@ziflist.txt:
608 @BUILD_DOC_TRUE@ ./mkman $@
609 @BUILD_DOC_TRUE@zlist.txt:
610 @BUILD_DOC_TRUE@ ./mkman $@
611 @BUILD_DOC_TRUE@zlistx.txt:
612 @BUILD_DOC_TRUE@ ./mkman $@
613 @BUILD_DOC_TRUE@zloop.txt:
614 @BUILD_DOC_TRUE@ ./mkman $@
615 @BUILD_DOC_TRUE@zmsg.txt:
616 @BUILD_DOC_TRUE@ ./mkman $@
617 @BUILD_DOC_TRUE@zpoller.txt:
618 @BUILD_DOC_TRUE@ ./mkman $@
619 @BUILD_DOC_TRUE@zproc.txt:
620 @BUILD_DOC_TRUE@ ./mkman $@
621 @BUILD_DOC_TRUE@zsock.txt:
622 @BUILD_DOC_TRUE@ ./mkman $@
623 @BUILD_DOC_TRUE@zstr.txt:
624 @BUILD_DOC_TRUE@ ./mkman $@
625 @BUILD_DOC_TRUE@ztimerset.txt:
626 @BUILD_DOC_TRUE@ ./mkman $@
627 @BUILD_DOC_TRUE@ztrie.txt:
628 @BUILD_DOC_TRUE@ ./mkman $@
629 @BUILD_DOC_TRUE@zuuid.txt:
630 @BUILD_DOC_TRUE@ ./mkman $@
631 @BUILD_DOC_TRUE@zauth.txt:
632 @BUILD_DOC_TRUE@ ./mkman $@
633 @BUILD_DOC_TRUE@zbeacon.txt:
634 @BUILD_DOC_TRUE@ ./mkman $@
635 @BUILD_DOC_TRUE@zgossip.txt:
636 @BUILD_DOC_TRUE@ ./mkman $@
637 @BUILD_DOC_TRUE@zmonitor.txt:
638 @BUILD_DOC_TRUE@ ./mkman $@
639 @BUILD_DOC_TRUE@zproxy.txt:
640 @BUILD_DOC_TRUE@ ./mkman $@
641 @BUILD_DOC_TRUE@zrex.txt:
642 @BUILD_DOC_TRUE@ ./mkman $@
643 @BUILD_DOC_TRUE@zsys.txt:
644 @BUILD_DOC_TRUE@ ./mkman $@
645 @BUILD_DOC_TRUE@zmakecert.txt:
646 @BUILD_DOC_TRUE@ ./mkman zmakecert $@
608 @BUILD_DOC_TRUE@.txt.doc:
609 @BUILD_DOC_TRUE@zactor.txt: $(top_srcdir)/src/zactor.c
610 @BUILD_DOC_TRUE@ $(srcdir)/mkman zactor $(builddir)/zactor $(srcdir)/..
611 @BUILD_DOC_TRUE@zarmour.txt: $(top_srcdir)/src/zarmour.c
612 @BUILD_DOC_TRUE@ $(srcdir)/mkman zarmour $(builddir)/zarmour $(srcdir)/..
613 @BUILD_DOC_TRUE@zcert.txt: $(top_srcdir)/src/zcert.c
614 @BUILD_DOC_TRUE@ $(srcdir)/mkman zcert $(builddir)/zcert $(srcdir)/..
615 @BUILD_DOC_TRUE@zcertstore.txt: $(top_srcdir)/src/zcertstore.c
616 @BUILD_DOC_TRUE@ $(srcdir)/mkman zcertstore $(builddir)/zcertstore $(srcdir)/..
617 @BUILD_DOC_TRUE@zchunk.txt: $(top_srcdir)/src/zchunk.c
618 @BUILD_DOC_TRUE@ $(srcdir)/mkman zchunk $(builddir)/zchunk $(srcdir)/..
619 @BUILD_DOC_TRUE@zclock.txt: $(top_srcdir)/src/zclock.c
620 @BUILD_DOC_TRUE@ $(srcdir)/mkman zclock $(builddir)/zclock $(srcdir)/..
621 @BUILD_DOC_TRUE@zconfig.txt: $(top_srcdir)/src/zconfig.c
622 @BUILD_DOC_TRUE@ $(srcdir)/mkman zconfig $(builddir)/zconfig $(srcdir)/..
623 @BUILD_DOC_TRUE@zdigest.txt: $(top_srcdir)/src/zdigest.c
624 @BUILD_DOC_TRUE@ $(srcdir)/mkman zdigest $(builddir)/zdigest $(srcdir)/..
625 @BUILD_DOC_TRUE@zdir.txt: $(top_srcdir)/src/zdir.c
626 @BUILD_DOC_TRUE@ $(srcdir)/mkman zdir $(builddir)/zdir $(srcdir)/..
627 @BUILD_DOC_TRUE@zdir_patch.txt: $(top_srcdir)/src/zdir_patch.c
628 @BUILD_DOC_TRUE@ $(srcdir)/mkman zdir_patch $(builddir)/zdir_patch $(srcdir)/..
629 @BUILD_DOC_TRUE@zfile.txt: $(top_srcdir)/src/zfile.c
630 @BUILD_DOC_TRUE@ $(srcdir)/mkman zfile $(builddir)/zfile $(srcdir)/..
631 @BUILD_DOC_TRUE@zframe.txt: $(top_srcdir)/src/zframe.c
632 @BUILD_DOC_TRUE@ $(srcdir)/mkman zframe $(builddir)/zframe $(srcdir)/..
633 @BUILD_DOC_TRUE@zhash.txt: $(top_srcdir)/src/zhash.c
634 @BUILD_DOC_TRUE@ $(srcdir)/mkman zhash $(builddir)/zhash $(srcdir)/..
635 @BUILD_DOC_TRUE@zhashx.txt: $(top_srcdir)/src/zhashx.c
636 @BUILD_DOC_TRUE@ $(srcdir)/mkman zhashx $(builddir)/zhashx $(srcdir)/..
637 @BUILD_DOC_TRUE@ziflist.txt: $(top_srcdir)/src/ziflist.c
638 @BUILD_DOC_TRUE@ $(srcdir)/mkman ziflist $(builddir)/ziflist $(srcdir)/..
639 @BUILD_DOC_TRUE@zlist.txt: $(top_srcdir)/src/zlist.c
640 @BUILD_DOC_TRUE@ $(srcdir)/mkman zlist $(builddir)/zlist $(srcdir)/..
641 @BUILD_DOC_TRUE@zlistx.txt: $(top_srcdir)/src/zlistx.c
642 @BUILD_DOC_TRUE@ $(srcdir)/mkman zlistx $(builddir)/zlistx $(srcdir)/..
643 @BUILD_DOC_TRUE@zloop.txt: $(top_srcdir)/src/zloop.c
644 @BUILD_DOC_TRUE@ $(srcdir)/mkman zloop $(builddir)/zloop $(srcdir)/..
645 @BUILD_DOC_TRUE@zmsg.txt: $(top_srcdir)/src/zmsg.c
646 @BUILD_DOC_TRUE@ $(srcdir)/mkman zmsg $(builddir)/zmsg $(srcdir)/..
647 @BUILD_DOC_TRUE@zpoller.txt: $(top_srcdir)/src/zpoller.c
648 @BUILD_DOC_TRUE@ $(srcdir)/mkman zpoller $(builddir)/zpoller $(srcdir)/..
649 @BUILD_DOC_TRUE@zproc.txt: $(top_srcdir)/src/zproc.c
650 @BUILD_DOC_TRUE@ $(srcdir)/mkman zproc $(builddir)/zproc $(srcdir)/..
651 @BUILD_DOC_TRUE@zsock.txt: $(top_srcdir)/src/zsock.c
652 @BUILD_DOC_TRUE@ $(srcdir)/mkman zsock $(builddir)/zsock $(srcdir)/..
653 @BUILD_DOC_TRUE@zstr.txt: $(top_srcdir)/src/zstr.c
654 @BUILD_DOC_TRUE@ $(srcdir)/mkman zstr $(builddir)/zstr $(srcdir)/..
655 @BUILD_DOC_TRUE@ztimerset.txt: $(top_srcdir)/src/ztimerset.c
656 @BUILD_DOC_TRUE@ $(srcdir)/mkman ztimerset $(builddir)/ztimerset $(srcdir)/..
657 @BUILD_DOC_TRUE@ztrie.txt: $(top_srcdir)/src/ztrie.c
658 @BUILD_DOC_TRUE@ $(srcdir)/mkman ztrie $(builddir)/ztrie $(srcdir)/..
659 @BUILD_DOC_TRUE@zuuid.txt: $(top_srcdir)/src/zuuid.c
660 @BUILD_DOC_TRUE@ $(srcdir)/mkman zuuid $(builddir)/zuuid $(srcdir)/..
661 @BUILD_DOC_TRUE@zauth.txt: $(top_srcdir)/src/zauth.c
662 @BUILD_DOC_TRUE@ $(srcdir)/mkman zauth $(builddir)/zauth $(srcdir)/..
663 @BUILD_DOC_TRUE@zbeacon.txt: $(top_srcdir)/src/zbeacon.c
664 @BUILD_DOC_TRUE@ $(srcdir)/mkman zbeacon $(builddir)/zbeacon $(srcdir)/..
665 @BUILD_DOC_TRUE@zgossip.txt: $(top_srcdir)/src/zgossip.c
666 @BUILD_DOC_TRUE@ $(srcdir)/mkman zgossip $(builddir)/zgossip $(srcdir)/..
667 @BUILD_DOC_TRUE@zmonitor.txt: $(top_srcdir)/src/zmonitor.c
668 @BUILD_DOC_TRUE@ $(srcdir)/mkman zmonitor $(builddir)/zmonitor $(srcdir)/..
669 @BUILD_DOC_TRUE@zproxy.txt: $(top_srcdir)/src/zproxy.c
670 @BUILD_DOC_TRUE@ $(srcdir)/mkman zproxy $(builddir)/zproxy $(srcdir)/..
671 @BUILD_DOC_TRUE@zrex.txt: $(top_srcdir)/src/zrex.c
672 @BUILD_DOC_TRUE@ $(srcdir)/mkman zrex $(builddir)/zrex $(srcdir)/..
673 @BUILD_DOC_TRUE@zsys.txt: $(top_srcdir)/src/zsys.c
674 @BUILD_DOC_TRUE@ $(srcdir)/mkman zsys $(builddir)/zsys $(srcdir)/..
675 @BUILD_DOC_TRUE@zmakecert.txt: $(top_srcdir)/src/zmakecert.c
676 @BUILD_DOC_TRUE@ $(srcdir)/mkman zmakecert $(builddir)/zmakecert $(srcdir)/..
677
647678 @BUILD_DOC_TRUE@clean:
648 @BUILD_DOC_TRUE@ rm -f *.1 *.3 *.7
649 @BUILD_DOC_TRUE@ ./mkman zactor
650 @BUILD_DOC_TRUE@ ./mkman zarmour
651 @BUILD_DOC_TRUE@ ./mkman zcert
652 @BUILD_DOC_TRUE@ ./mkman zcertstore
653 @BUILD_DOC_TRUE@ ./mkman zchunk
654 @BUILD_DOC_TRUE@ ./mkman zclock
655 @BUILD_DOC_TRUE@ ./mkman zconfig
656 @BUILD_DOC_TRUE@ ./mkman zdigest
657 @BUILD_DOC_TRUE@ ./mkman zdir
658 @BUILD_DOC_TRUE@ ./mkman zdir_patch
659 @BUILD_DOC_TRUE@ ./mkman zfile
660 @BUILD_DOC_TRUE@ ./mkman zframe
661 @BUILD_DOC_TRUE@ ./mkman zhash
662 @BUILD_DOC_TRUE@ ./mkman zhashx
663 @BUILD_DOC_TRUE@ ./mkman ziflist
664 @BUILD_DOC_TRUE@ ./mkman zlist
665 @BUILD_DOC_TRUE@ ./mkman zlistx
666 @BUILD_DOC_TRUE@ ./mkman zloop
667 @BUILD_DOC_TRUE@ ./mkman zmsg
668 @BUILD_DOC_TRUE@ ./mkman zpoller
669 @BUILD_DOC_TRUE@ ./mkman zproc
670 @BUILD_DOC_TRUE@ ./mkman zsock
671 @BUILD_DOC_TRUE@ ./mkman zstr
672 @BUILD_DOC_TRUE@ ./mkman ztimerset
673 @BUILD_DOC_TRUE@ ./mkman ztrie
674 @BUILD_DOC_TRUE@ ./mkman zuuid
675 @BUILD_DOC_TRUE@ ./mkman zauth
676 @BUILD_DOC_TRUE@ ./mkman zbeacon
677 @BUILD_DOC_TRUE@ ./mkman zgossip
678 @BUILD_DOC_TRUE@ ./mkman zmonitor
679 @BUILD_DOC_TRUE@ ./mkman zproxy
680 @BUILD_DOC_TRUE@ ./mkman zrex
681 @BUILD_DOC_TRUE@ ./mkman zsys
682 @BUILD_DOC_TRUE@ ./mkman zmakecert zmakecert
683
679 @BUILD_DOC_TRUE@ rm -f *.1 *.3 *.7 $(GENERATED_DOCS)
680 @BUILD_DOC_TRUE@doc: $(GENERATED_DOCS)
684681 ################################################################################
685682 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
686683 # Read the zproject/README.md for information about making permanent changes. #
0 '\" t
1 .\" Title: czmq
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "CZMQ" "7" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 czmq \- high\-level C binding for ZeroMQ
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 #include <czmq\&.h>
35
36 cc [\*(Aqflags\*(Aq] \*(Aqfiles\*(Aq \-lzmq \-lczmq [\*(Aqlibraries\*(Aq]
37 .fi
38 .SH "DESCRIPTION"
39 .SS "Classes"
40 .sp
41 These classes provide the main socket and message API:
42 .sp
43 .RS 4
44 .ie n \{\
45 \h'-04'\(bu\h'+03'\c
46 .\}
47 .el \{\
48 .sp -1
49 .IP \(bu 2.3
50 .\}
51
52 \fBzsock\fR(3)
53 \- working with ZeroMQ sockets (high\-level)
54 .RE
55 .sp
56 .RS 4
57 .ie n \{\
58 \h'-04'\(bu\h'+03'\c
59 .\}
60 .el \{\
61 .sp -1
62 .IP \(bu 2.3
63 .\}
64
65 \fBzstr\fR(3)
66 \- sending and receiving strings
67 .RE
68 .sp
69 .RS 4
70 .ie n \{\
71 \h'-04'\(bu\h'+03'\c
72 .\}
73 .el \{\
74 .sp -1
75 .IP \(bu 2.3
76 .\}
77
78 \fBzmsg\fR(3)
79 \- working with multipart messages
80 .RE
81 .sp
82 .RS 4
83 .ie n \{\
84 \h'-04'\(bu\h'+03'\c
85 .\}
86 .el \{\
87 .sp -1
88 .IP \(bu 2.3
89 .\}
90
91 \fBzframe\fR(3)
92 \- working with single message frames
93 .RE
94 .sp
95 .RS 4
96 .ie n \{\
97 \h'-04'\(bu\h'+03'\c
98 .\}
99 .el \{\
100 .sp -1
101 .IP \(bu 2.3
102 .\}
103
104 \fBzactor\fR(3)
105 \- Actor class (socket + thread)
106 .RE
107 .sp
108 .RS 4
109 .ie n \{\
110 \h'-04'\(bu\h'+03'\c
111 .\}
112 .el \{\
113 .sp -1
114 .IP \(bu 2.3
115 .\}
116
117 \fBzloop\fR(3)
118 \- event\-driven reactor
119 .RE
120 .sp
121 .RS 4
122 .ie n \{\
123 \h'-04'\(bu\h'+03'\c
124 .\}
125 .el \{\
126 .sp -1
127 .IP \(bu 2.3
128 .\}
129
130 \fBzpoller\fR(3)
131 \- trivial socket poller class
132 .RE
133 .sp
134 .RS 4
135 .ie n \{\
136 \h'-04'\(bu\h'+03'\c
137 .\}
138 .el \{\
139 .sp -1
140 .IP \(bu 2.3
141 .\}
142
143 \fBzproxy\fR(3)
144 \- proxy actor (like zmq_proxy_steerable)
145 .RE
146 .sp
147 .RS 4
148 .ie n \{\
149 \h'-04'\(bu\h'+03'\c
150 .\}
151 .el \{\
152 .sp -1
153 .IP \(bu 2.3
154 .\}
155
156 \fBzmonitor\fR(3)
157 \- monitor events on ZeroMQ sockets
158 .RE
159 .sp
160 These classes support authentication and encryption:
161 .sp
162 .RS 4
163 .ie n \{\
164 \h'-04'\(bu\h'+03'\c
165 .\}
166 .el \{\
167 .sp -1
168 .IP \(bu 2.3
169 .\}
170
171 \fBzauth\fR(3)
172 \- authentication actor for ZeroMQ servers
173 .RE
174 .sp
175 .RS 4
176 .ie n \{\
177 \h'-04'\(bu\h'+03'\c
178 .\}
179 .el \{\
180 .sp -1
181 .IP \(bu 2.3
182 .\}
183
184 \fBzcert\fR(3)
185 \- work with CURVE security certificates
186 .RE
187 .sp
188 .RS 4
189 .ie n \{\
190 \h'-04'\(bu\h'+03'\c
191 .\}
192 .el \{\
193 .sp -1
194 .IP \(bu 2.3
195 .\}
196
197 \fBzcertstore\fR(3)
198 \- work with CURVE security certificate stores
199 .RE
200 .sp
201 These classes provide generic containers:
202 .sp
203 .RS 4
204 .ie n \{\
205 \h'-04'\(bu\h'+03'\c
206 .\}
207 .el \{\
208 .sp -1
209 .IP \(bu 2.3
210 .\}
211
212 \fBzhash\fR(3)
213 \- simple generic hash container
214 .RE
215 .sp
216 .RS 4
217 .ie n \{\
218 \h'-04'\(bu\h'+03'\c
219 .\}
220 .el \{\
221 .sp -1
222 .IP \(bu 2.3
223 .\}
224
225 \fBzhashx\fR(3)
226 \- extended generic hash container
227 .RE
228 .sp
229 .RS 4
230 .ie n \{\
231 \h'-04'\(bu\h'+03'\c
232 .\}
233 .el \{\
234 .sp -1
235 .IP \(bu 2.3
236 .\}
237
238 \fBzlist\fR(3)
239 \- simple generic list container
240 .RE
241 .sp
242 .RS 4
243 .ie n \{\
244 \h'-04'\(bu\h'+03'\c
245 .\}
246 .el \{\
247 .sp -1
248 .IP \(bu 2.3
249 .\}
250
251 \fBzlistx\fR(3)
252 \- extended generic list container
253 .RE
254 .sp
255 These classes wrap\-up non\-portable functionality:
256 .sp
257 .RS 4
258 .ie n \{\
259 \h'-04'\(bu\h'+03'\c
260 .\}
261 .el \{\
262 .sp -1
263 .IP \(bu 2.3
264 .\}
265
266 \fBzbeacon\fR(3)
267 \- LAN discovery and presence
268 .RE
269 .sp
270 .RS 4
271 .ie n \{\
272 \h'-04'\(bu\h'+03'\c
273 .\}
274 .el \{\
275 .sp -1
276 .IP \(bu 2.3
277 .\}
278
279 \fBzclock\fR(3)
280 \- millisecond clocks and delays
281 .RE
282 .sp
283 .RS 4
284 .ie n \{\
285 \h'-04'\(bu\h'+03'\c
286 .\}
287 .el \{\
288 .sp -1
289 .IP \(bu 2.3
290 .\}
291
292 \fBzdir\fR(3)
293 \- work with file\-system directories
294 .RE
295 .sp
296 .RS 4
297 .ie n \{\
298 \h'-04'\(bu\h'+03'\c
299 .\}
300 .el \{\
301 .sp -1
302 .IP \(bu 2.3
303 .\}
304
305 \fBzdir_patch\fR(3)
306 \- work with directory differences
307 .RE
308 .sp
309 .RS 4
310 .ie n \{\
311 \h'-04'\(bu\h'+03'\c
312 .\}
313 .el \{\
314 .sp -1
315 .IP \(bu 2.3
316 .\}
317
318 \fBzfile\fR(3)
319 \- work with file\-system files
320 .RE
321 .sp
322 .RS 4
323 .ie n \{\
324 \h'-04'\(bu\h'+03'\c
325 .\}
326 .el \{\
327 .sp -1
328 .IP \(bu 2.3
329 .\}
330
331 \fBzsys\fR(3)
332 \- system\-level methods
333 .RE
334 .sp
335 .RS 4
336 .ie n \{\
337 \h'-04'\(bu\h'+03'\c
338 .\}
339 .el \{\
340 .sp -1
341 .IP \(bu 2.3
342 .\}
343
344 \fBzuuid\fR(3)
345 \- UUID support class
346 .RE
347 .sp
348 .RS 4
349 .ie n \{\
350 \h'-04'\(bu\h'+03'\c
351 .\}
352 .el \{\
353 .sp -1
354 .IP \(bu 2.3
355 .\}
356
357 \fBziflist\fR(3)
358 \- list available network interfaces
359 .RE
360 .sp
361 And these utility classes add value:
362 .sp
363 .RS 4
364 .ie n \{\
365 \h'-04'\(bu\h'+03'\c
366 .\}
367 .el \{\
368 .sp -1
369 .IP \(bu 2.3
370 .\}
371
372 \fBzchunk\fR(3)
373 \- work with memory chunks
374 .RE
375 .sp
376 .RS 4
377 .ie n \{\
378 \h'-04'\(bu\h'+03'\c
379 .\}
380 .el \{\
381 .sp -1
382 .IP \(bu 2.3
383 .\}
384
385 \fBzconfig\fR(3)
386 \- work with textual config files
387 .RE
388 .sp
389 .RS 4
390 .ie n \{\
391 \h'-04'\(bu\h'+03'\c
392 .\}
393 .el \{\
394 .sp -1
395 .IP \(bu 2.3
396 .\}
397
398 \fBzrex\fR(3)
399 \- work with regular expressions
400 .RE
401 .sp
402 .RS 4
403 .ie n \{\
404 \h'-04'\(bu\h'+03'\c
405 .\}
406 .el \{\
407 .sp -1
408 .IP \(bu 2.3
409 .\}
410
411 \fBzgossip\fR(3)
412 \- decentralized configuration management
413 .RE
414 .sp
415 These classes are deprecated:
416 .sp
417 .RS 4
418 .ie n \{\
419 \h'-04'\(bu\h'+03'\c
420 .\}
421 .el \{\
422 .sp -1
423 .IP \(bu 2.3
424 .\}
425
426 \fBzctx\fR(3)
427 \- working with ZeroMQ contexts
428 .RE
429 .sp
430 .RS 4
431 .ie n \{\
432 \h'-04'\(bu\h'+03'\c
433 .\}
434 .el \{\
435 .sp -1
436 .IP \(bu 2.3
437 .\}
438
439 \fBzsocket\fR(3)
440 \- working with ZeroMQ sockets (low\-level)
441 .RE
442 .sp
443 .RS 4
444 .ie n \{\
445 \h'-04'\(bu\h'+03'\c
446 .\}
447 .el \{\
448 .sp -1
449 .IP \(bu 2.3
450 .\}
451
452 \fBzsockopt\fR(3)
453 \- get/set ZeroMQ socket options
454 .RE
455 .sp
456 .RS 4
457 .ie n \{\
458 \h'-04'\(bu\h'+03'\c
459 .\}
460 .el \{\
461 .sp -1
462 .IP \(bu 2.3
463 .\}
464
465 \fBzthread\fR(3)
466 \- working with system threads
467 .RE
468 .sp
469 .RS 4
470 .ie n \{\
471 \h'-04'\(bu\h'+03'\c
472 .\}
473 .el \{\
474 .sp -1
475 .IP \(bu 2.3
476 .\}
477
478 \fBzauth_v2\fR(3)
479 \- authentication for ZeroMQ servers
480 .RE
481 .sp
482 .RS 4
483 .ie n \{\
484 \h'-04'\(bu\h'+03'\c
485 .\}
486 .el \{\
487 .sp -1
488 .IP \(bu 2.3
489 .\}
490
491 \fBzbeacon_v2\fR(3)
492 \- LAN discovery and presence
493 .RE
494 .sp
495 .RS 4
496 .ie n \{\
497 \h'-04'\(bu\h'+03'\c
498 .\}
499 .el \{\
500 .sp -1
501 .IP \(bu 2.3
502 .\}
503
504 \fBzmonitor_v2\fR(3)
505 \- socket event monitor
506 .RE
507 .sp
508 .RS 4
509 .ie n \{\
510 \h'-04'\(bu\h'+03'\c
511 .\}
512 .el \{\
513 .sp -1
514 .IP \(bu 2.3
515 .\}
516
517 \fBzproxy_v2\fR(3)
518 \- zmq_proxy wrapper
519 .RE
520 .SS "Scope and Goals"
521 .sp
522 CZMQ has these goals:
523 .sp
524 .RS 4
525 .ie n \{\
526 \h'-04'\(bu\h'+03'\c
527 .\}
528 .el \{\
529 .sp -1
530 .IP \(bu 2.3
531 .\}
532 To wrap the \(/OMQ core API in semantics that are natural and lead to shorter, more readable applications\&.
533 .RE
534 .sp
535 .RS 4
536 .ie n \{\
537 \h'-04'\(bu\h'+03'\c
538 .\}
539 .el \{\
540 .sp -1
541 .IP \(bu 2.3
542 .\}
543 To hide the differences between versions of \(/OMQ\&.
544 .RE
545 .sp
546 .RS 4
547 .ie n \{\
548 \h'-04'\(bu\h'+03'\c
549 .\}
550 .el \{\
551 .sp -1
552 .IP \(bu 2.3
553 .\}
554 To provide a space for development of more sophisticated API semantics\&.
555 .RE
556 .SS "Ownership and License"
557 .sp
558 CZMQ is maintained by the ZeroMQ community at github\&.com/zeromq\&. Its other authors and contributors are listed in the AUTHORS file\&.
559 .sp
560 The contributors are listed in AUTHORS\&. This project uses the MPL v2 license, see LICENSE\&.
561 .SS "Contributing"
562 .sp
563 To submit an issue use the issue tracker at \m[blue]\fBhttp://github\&.com/zeromq/czmq/issues\fR\m[]\&. All discussion happens on the zeromq\-dev list or #zeromq IRC channel at irc\&.freenode\&.net\&.
564 .sp
565 The proper way to submit patches is to clone this repository, make your changes, and use git to create a patch or a pull request\&. See \m[blue]\fBhttp://www\&.zeromq\&.org/docs:contributing\fR\m[]\&. All contributors are listed in AUTHORS\&.
566 .sp
567 All classes are maintained by a single person, who is the responsible editor for that class and who is named in the header as such\&. This is usually the originator of the class\&. When several people collaborate on a class, one single person is always the lead maintainer and the one to blame when it breaks\&.
568 .sp
569 The general rule is, if you contribute code to CZMQ you must be willing to maintain it as long as there are users of it\&. Code with no active maintainer will in general be deprecated and/or removed\&.
570 .SH "USING CZMQ"
571 .SS "Building and Installing"
572 .sp
573 CZMQ uses autotools for packaging\&. To build from git (all example commands are for Linux):
574 .sp
575 .if n \{\
576 .RS 4
577 .\}
578 .nf
579 git clone git://github\&.com/zeromq/czmq\&.git
580 cd czmq
581 sh autogen\&.sh
582 \&./configure
583 make all
584 sudo make install
585 sudo ldconfig
586 .fi
587 .if n \{\
588 .RE
589 .\}
590 .sp
591 You will need the pkg\-config, libtool, and autoreconf packages\&. Set the LD_LIBRARY_PATH to /usr/local/libs unless you install elsewhere\&.
592 .sp
593 After building, you can run the CZMQ selftests:
594 .sp
595 .if n \{\
596 .RS 4
597 .\}
598 .nf
599 cd src
600 \&./czmq_selftest
601 .fi
602 .if n \{\
603 .RE
604 .\}
605 .SS "Linking with an Application"
606 .sp
607 Include czmq\&.h in your application and link with CZMQ\&. Here is a typical gcc link command:
608 .sp
609 .if n \{\
610 .RS 4
611 .\}
612 .nf
613 gcc \-lczmq \-lzmq myapp\&.c \-o myapp
614 .fi
615 .if n \{\
616 .RE
617 .\}
618 .sp
619 You should read czmq\&.h\&. This file includes zmq\&.h and the system header files that typical \(/OMQ applications will need\&. The provided \fIc\fR shell script lets you write simple portable build scripts:
620 .sp
621 .if n \{\
622 .RS 4
623 .\}
624 .nf
625 c \-lczmq \-lzmq \-l myapp
626 .fi
627 .if n \{\
628 .RE
629 .\}
630 .SS "The Class Model"
631 .sp
632 CZMQ consists of classes, each class consisting of a \&.h and a \&.c\&. Classes may depend on other classes\&.
633 .sp
634 czmq\&.h includes all classes header files, all the time\&. For the user, CZMQ forms one single package\&. All classes start by including czmq\&.h\&. All applications that use CZMQ start by including czmq\&.h\&. czmq\&.h also defines a limited number of small, useful macros and typedefs that have proven useful for writing clearer C code\&.
635 .sp
636 All classes (with some exceptions) are based on a flat C class system and follow these rules (where \fIzclass\fR is the class name):
637 .sp
638 .RS 4
639 .ie n \{\
640 \h'-04'\(bu\h'+03'\c
641 .\}
642 .el \{\
643 .sp -1
644 .IP \(bu 2.3
645 .\}
646 Class typedef:
647 zclass_t
648 .RE
649 .sp
650 .RS 4
651 .ie n \{\
652 \h'-04'\(bu\h'+03'\c
653 .\}
654 .el \{\
655 .sp -1
656 .IP \(bu 2.3
657 .\}
658 Constructor:
659 zclass_new
660 .RE
661 .sp
662 .RS 4
663 .ie n \{\
664 \h'-04'\(bu\h'+03'\c
665 .\}
666 .el \{\
667 .sp -1
668 .IP \(bu 2.3
669 .\}
670 Destructor:
671 zclass_destroy
672 .RE
673 .sp
674 .RS 4
675 .ie n \{\
676 \h'-04'\(bu\h'+03'\c
677 .\}
678 .el \{\
679 .sp -1
680 .IP \(bu 2.3
681 .\}
682 Property methods:
683 zclass_property_set,
684 zclass_property
685 .RE
686 .sp
687 .RS 4
688 .ie n \{\
689 \h'-04'\(bu\h'+03'\c
690 .\}
691 .el \{\
692 .sp -1
693 .IP \(bu 2.3
694 .\}
695 Class structures are private (defined in the \&.c source but not the \&.h)
696 .RE
697 .sp
698 .RS 4
699 .ie n \{\
700 \h'-04'\(bu\h'+03'\c
701 .\}
702 .el \{\
703 .sp -1
704 .IP \(bu 2.3
705 .\}
706 Properties are accessed only via methods named as described above\&.
707 .RE
708 .sp
709 .RS 4
710 .ie n \{\
711 \h'-04'\(bu\h'+03'\c
712 .\}
713 .el \{\
714 .sp -1
715 .IP \(bu 2.3
716 .\}
717 In the class source code the object is always called
718 self\&.
719 .RE
720 .sp
721 .RS 4
722 .ie n \{\
723 \h'-04'\(bu\h'+03'\c
724 .\}
725 .el \{\
726 .sp -1
727 .IP \(bu 2.3
728 .\}
729 The constructor may take arbitrary arguments, and returns NULL on failure, or a new object\&.
730 .RE
731 .sp
732 .RS 4
733 .ie n \{\
734 \h'-04'\(bu\h'+03'\c
735 .\}
736 .el \{\
737 .sp -1
738 .IP \(bu 2.3
739 .\}
740 The destructor takes a pointer to an object reference and nullifies it\&.
741 .RE
742 .sp
743 Return values for methods are:
744 .sp
745 .RS 4
746 .ie n \{\
747 \h'-04'\(bu\h'+03'\c
748 .\}
749 .el \{\
750 .sp -1
751 .IP \(bu 2.3
752 .\}
753 For methods that return an object reference, either the reference, or NULL on failure\&.
754 .RE
755 .sp
756 .RS 4
757 .ie n \{\
758 \h'-04'\(bu\h'+03'\c
759 .\}
760 .el \{\
761 .sp -1
762 .IP \(bu 2.3
763 .\}
764 For methods that signal success/failure, a return value of 0 means success, \-1 failure\&.
765 .RE
766 .sp
767 Private/static functions in a class are named s_functionname and are not exported via the header file\&.
768 .sp
769 All classes (with some exceptions) have a test method called zclass_test\&.
770 .SH "DESIGN IDEOLOGY"
771 .SS "The Problem with C"
772 .sp
773 C has the significant advantage of being a small language that, if we take a little care with formatting and naming, can be easily interchanged between developers\&. Every C developer will use much the same 90% of the language\&. Larger languages like C++ provide powerful abstractions like STL containers but at the cost of interchange\&.
774 .sp
775 The huge problem with C is that any realistic application needs packages of functionality to bring the language up to the levels we expect for the 21st century\&. Much can be done by using external libraries but every additional library is a dependency that makes the resulting applications harder to build and port\&. While C itself is a highly portable language (and can be made more so by careful use of the preprocessor), most C libraries consider themselves part of the operating system, and as such do not attempt to be portable\&.
776 .sp
777 The answer to this, as we learned from building enterprise\-level C applications at iMatix from 1995\-2005, is to create our own fully portable, high\-quality libraries of pre\-packaged functionality, in C\&. Doing this right solves both the requirements of richness of the language, and of portability of the final applications\&.
778 .SS "A Simple Class Model"
779 .sp
780 C has no standard API style\&. It is one thing to write a useful component, but something else to provide an API that is consistent and obvious across many components\&. We learned from building OpenAMQ (\m[blue]\fBhttp://www\&.openamq\&.org\fR\m[]), a messaging client and server of 0\&.5M LoC, that a consistent model for extending C makes life for the application developer much easier\&.
781 .sp
782 The general model is that of a class (the source package) that provides objects (in fact C structures)\&. The application creates objects and then works with them\&. When done, the application destroys the object\&. In C, we tend to use the same name for the object as the class, when we can, and it looks like this (to take a fictitious CZMQ class):
783 .sp
784 .if n \{\
785 .RS 4
786 .\}
787 .nf
788 zregexp_t *regexp = zregexp_new (regexp_string);
789 if (!regexp)
790 printf ("E: invalid regular expression: %s\en", regexp_string);
791 else
792 if (zregexp_match (regexp, input_buffer))
793 printf ("I: successful match for %s\en", input buffer);
794 zregexp_destroy (&amp;regexp);
795 .fi
796 .if n \{\
797 .RE
798 .\}
799 .sp
800 As far as the C program is concerned, the object is a reference to a structure (not a void pointer)\&. We pass the object reference to all methods, since this is still C\&. We could do weird stuff like put method addresses into the structure so that we can emulate a C++ syntax but it\(cqs not worthwhile\&. The goal is not to emulate an OO system, it\(cqs simply to gain consistency\&. The constructor returns an object reference, or NULL if it fails\&. The destructor nullifies the class pointer, and is idempotent\&.
801 .sp
802 What we aim at here is the simplest possible consistent syntax\&.
803 .sp
804 No model is fully consistent, and classes can define their own rules if it helps make a better result\&. For example:
805 .sp
806 .RS 4
807 .ie n \{\
808 \h'-04'\(bu\h'+03'\c
809 .\}
810 .el \{\
811 .sp -1
812 .IP \(bu 2.3
813 .\}
814 Some classes may not be opaque\&. For example, we have cases of generated serialization classes that encode and decode structures to/from binary buffers\&. It feels clumsy to have to use methods to access the properties of these classes\&.
815 .RE
816 .sp
817 .RS 4
818 .ie n \{\
819 \h'-04'\(bu\h'+03'\c
820 .\}
821 .el \{\
822 .sp -1
823 .IP \(bu 2.3
824 .\}
825 While every class has a new method that is the formal constructor, some methods may also act as constructors\&. For example, a "dup" method might take one object and return a second object\&.
826 .RE
827 .sp
828 .RS 4
829 .ie n \{\
830 \h'-04'\(bu\h'+03'\c
831 .\}
832 .el \{\
833 .sp -1
834 .IP \(bu 2.3
835 .\}
836 While every class has a destroy method that is the formal destructor, some methods may also act as destructors\&. For example, a method that sends an object may also destroy the object (so that ownership of any buffers can passed to background threads)\&. Such methods take the same "pointer to a reference" argument as the destroy method\&.
837 .RE
838 .SS "Naming Style"
839 .sp
840 CZMQ aims for short, consistent names, following the theory that names we use most often should be shortest\&. Classes get one\-word names, unless they are part of a family of classes in which case they may be two words, the first being the family name\&. Methods, similarly, get one\-word names and we aim for consistency across classes (so a method that does something semantically similar in two classes will get the same name in both)\&. So the canonical name for any method is:
841 .sp
842 .if n \{\
843 .RS 4
844 .\}
845 .nf
846 zclassname_methodname
847 .fi
848 .if n \{\
849 .RE
850 .\}
851 .sp
852 And the reader can easily parse this without needing special syntax to separate the class name from the method name\&.
853 .SS "Containers"
854 .sp
855 After a long experiment with containers, we\(cqve decided that we need exactly two containers:
856 .sp
857 .RS 4
858 .ie n \{\
859 \h'-04'\(bu\h'+03'\c
860 .\}
861 .el \{\
862 .sp -1
863 .IP \(bu 2.3
864 .\}
865 A singly\-linked list\&.
866 .RE
867 .sp
868 .RS 4
869 .ie n \{\
870 \h'-04'\(bu\h'+03'\c
871 .\}
872 .el \{\
873 .sp -1
874 .IP \(bu 2.3
875 .\}
876 A hash table using text keys\&.
877 .RE
878 .sp
879 These are zlist and zhash, respectively\&. Both store void pointers, with no attempt to manage the details of contained objects\&. You can use these containers to create lists of lists, hashes of lists, hashes of hashes, etc\&.
880 .sp
881 We assume that at some point we\(cqll need to switch to a doubly\-linked list\&.
882 .SS "Portability"
883 .sp
884 Creating a portable C application can be rewarding in terms of maintaining a single code base across many platforms, and keeping (expensive) system\-specific knowledge separate from application developers\&. In most projects (like \(/OMQ core), there is no portability layer and application code does conditional compilation for all mixes of platforms\&. This leads to quite messy code\&.
885 .sp
886 czmq acts as a portability layer, similar to but thinner than libraries like the [Apache Portable Runtime](\m[blue]\fBhttp://apr\&.apache\&.org\fR\m[]) (APR)\&.
887 .sp
888 These are the places a C application is subject to arbitrary system differences:
889 .sp
890 .RS 4
891 .ie n \{\
892 \h'-04'\(bu\h'+03'\c
893 .\}
894 .el \{\
895 .sp -1
896 .IP \(bu 2.3
897 .\}
898 Different compilers may offer slightly different variants of the C language, often lacking specific types or using neat non\-portable names\&. Windows is a big culprit here\&. We solve this by
899 \fIpatching\fR
900 the language in czmq_prelude\&.h, e\&.g\&. defining int64_t on Windows\&.
901 .RE
902 .sp
903 .RS 4
904 .ie n \{\
905 \h'-04'\(bu\h'+03'\c
906 .\}
907 .el \{\
908 .sp -1
909 .IP \(bu 2.3
910 .\}
911 System header files are inconsistent, i\&.e\&. you need to include different files depending on the OS type and version\&. We solve this by pulling in all necessary header files in czmq_prelude\&.h\&. This is a proven brute\-force approach that increases recompilation times but eliminates a major source of pain\&.
912 .RE
913 .sp
914 .RS 4
915 .ie n \{\
916 \h'-04'\(bu\h'+03'\c
917 .\}
918 .el \{\
919 .sp -1
920 .IP \(bu 2.3
921 .\}
922 System libraries are inconsistent, i\&.e\&. you need to link with different libraries depending on the OS type and version\&. We solve this with an external compilation tool,
923 \fIC\fR, which detects the OS type and version (at runtime) and builds the necessary link commands\&.
924 .RE
925 .sp
926 .RS 4
927 .ie n \{\
928 \h'-04'\(bu\h'+03'\c
929 .\}
930 .el \{\
931 .sp -1
932 .IP \(bu 2.3
933 .\}
934 System functions are inconsistent, i\&.e\&. you need to call different functions depending, again, on OS type and version\&. We solve this by building small abstract classes that handle specific areas of functionality, and doing conditional compilation in these\&.
935 .RE
936 .sp
937 An example of the last:
938 .sp
939 .if n \{\
940 .RS 4
941 .\}
942 .nf
943 #if (defined (__UNIX__))
944 pid = GetCurrentProcessId();
945 #elif (defined (__WINDOWS__))
946 pid = getpid ();
947 #else
948 pid = 0;
949 #endif
950 .fi
951 .if n \{\
952 .RE
953 .\}
954 .sp
955 CZMQ uses the GNU autotools system, so non\-portable code can use the macros this defines\&. It can also use macros defined by the czmq_prelude\&.h header file\&.
956 .SS "Technical Aspects"
957 .sp
958 .RS 4
959 .ie n \{\
960 \h'-04'\(bu\h'+03'\c
961 .\}
962 .el \{\
963 .sp -1
964 .IP \(bu 2.3
965 .\}
966
967 \fBThread safety\fR: the use of opaque structures is thread safe, though \(/OMQ applications should not share state between threads in any case\&.
968 .RE
969 .sp
970 .RS 4
971 .ie n \{\
972 \h'-04'\(bu\h'+03'\c
973 .\}
974 .el \{\
975 .sp -1
976 .IP \(bu 2.3
977 .\}
978
979 \fBName spaces\fR: we prefix class names with
980 z, which ensures that all exported functions are globally safe\&.
981 .RE
982 .sp
983 .RS 4
984 .ie n \{\
985 \h'-04'\(bu\h'+03'\c
986 .\}
987 .el \{\
988 .sp -1
989 .IP \(bu 2.3
990 .\}
991
992 \fBLibrary versioning\fR: we don\(cqt make any attempt to version the library at this stage\&. Classes are in our experience highly stable once they are built and tested, the only changes typically being added methods\&.
993 .RE
994 .sp
995 .RS 4
996 .ie n \{\
997 \h'-04'\(bu\h'+03'\c
998 .\}
999 .el \{\
1000 .sp -1
1001 .IP \(bu 2.3
1002 .\}
1003
1004 \fBPerformance\fR: for critical path processing, you may want to avoid creating and destroying classes\&. However on modern Linux systems the heap allocator is very fast\&. Individual classes can choose whether or not to nullify their data on allocation\&.
1005 .RE
1006 .sp
1007 .RS 4
1008 .ie n \{\
1009 \h'-04'\(bu\h'+03'\c
1010 .\}
1011 .el \{\
1012 .sp -1
1013 .IP \(bu 2.3
1014 .\}
1015
1016 \fBSelf\-testing\fR: every class has a
1017 selftest
1018 method that runs through the methods of the class\&. In theory, calling all selftest functions of all classes does a full unit test of the library\&. The
1019 czmq_selftest
1020 application does this\&.
1021 .RE
1022 .sp
1023 .RS 4
1024 .ie n \{\
1025 \h'-04'\(bu\h'+03'\c
1026 .\}
1027 .el \{\
1028 .sp -1
1029 .IP \(bu 2.3
1030 .\}
1031
1032 \fBMemory management\fR: CZMQ classes do not use any special memory management techiques to detect leaks\&. We\(cqve done this in the past but it makes the code relatively complex\&. Instead, we do memory leak testing using tools like valgrind\&.
1033 .RE
1034 .SH "UNDER THE HOOD"
1035 .SS "Adding a New Class"
1036 .sp
1037 If you define a new CZMQ class myclass you need to:
1038 .sp
1039 .RS 4
1040 .ie n \{\
1041 \h'-04'\(bu\h'+03'\c
1042 .\}
1043 .el \{\
1044 .sp -1
1045 .IP \(bu 2.3
1046 .\}
1047 Write the
1048 zmyclass\&.c
1049 and
1050 zmyclass\&.h
1051 source files, in
1052 src
1053 and
1054 include
1055 respectively\&.
1056 .RE
1057 .sp
1058 .RS 4
1059 .ie n \{\
1060 \h'-04'\(bu\h'+03'\c
1061 .\}
1062 .el \{\
1063 .sp -1
1064 .IP \(bu 2.3
1065 .\}
1066 Add`#include <zmyclass\&.h>` to
1067 include/czmq\&.h\&.
1068 .RE
1069 .sp
1070 .RS 4
1071 .ie n \{\
1072 \h'-04'\(bu\h'+03'\c
1073 .\}
1074 .el \{\
1075 .sp -1
1076 .IP \(bu 2.3
1077 .\}
1078 Add the myclass header and test call to
1079 src/czmq_selftest\&.c\&.
1080 .RE
1081 .sp
1082 .RS 4
1083 .ie n \{\
1084 \h'-04'\(bu\h'+03'\c
1085 .\}
1086 .el \{\
1087 .sp -1
1088 .IP \(bu 2.3
1089 .\}
1090 Add a reference documentation to
1091 \fIdoc/zmyclass\&.txt\fR\&.
1092 .RE
1093 .sp
1094 .RS 4
1095 .ie n \{\
1096 \h'-04'\(bu\h'+03'\c
1097 .\}
1098 .el \{\
1099 .sp -1
1100 .IP \(bu 2.3
1101 .\}
1102 Add myclass to \*(Aqsrc/Makefile\&.am` and
1103 doc/Makefile\&.am\&.
1104 .RE
1105 .sp
1106 The bin/newclass\&.sh shell script will automate these steps for you\&.
1107 .SS "Coding Style"
1108 .sp
1109 In general the zctx class defines the style for the whole library\&. The overriding rules for coding style are consistency, clarity, and ease of maintenance\&. We use the C99 standard for syntax including principally:
1110 .sp
1111 .RS 4
1112 .ie n \{\
1113 \h'-04'\(bu\h'+03'\c
1114 .\}
1115 .el \{\
1116 .sp -1
1117 .IP \(bu 2.3
1118 .\}
1119 The // comment style\&.
1120 .RE
1121 .sp
1122 .RS 4
1123 .ie n \{\
1124 \h'-04'\(bu\h'+03'\c
1125 .\}
1126 .el \{\
1127 .sp -1
1128 .IP \(bu 2.3
1129 .\}
1130 Variables definitions placed in or before the code that uses them\&.
1131 .RE
1132 .sp
1133 So while ANSI C code might say:
1134 .sp
1135 .if n \{\
1136 .RS 4
1137 .\}
1138 .nf
1139 zblob_t *file_buffer; /* Buffer for our file */
1140 \&.\&.\&. (100 lines of code)
1141 file_buffer = zblob_new ();
1142 \&.\&.\&.
1143 .fi
1144 .if n \{\
1145 .RE
1146 .\}
1147 .sp
1148 The style in CZMQ would be:
1149 .sp
1150 .if n \{\
1151 .RS 4
1152 .\}
1153 .nf
1154 zblob_t *file_buffer = zblob_new ();
1155 .fi
1156 .if n \{\
1157 .RE
1158 .\}
1159 .SS "Assertions"
1160 .sp
1161 We use assertions heavily to catch bad argument values\&. The CZMQ classes do not attempt to validate arguments and report errors; bad arguments are treated as fatal application programming errors\&.
1162 .sp
1163 We also use assertions heavily on calls to system functions that are never supposed to fail, where failure is to be treated as a fatal non\-recoverable error (e\&.g\&. running out of memory)\&.
1164 .sp
1165 Assertion code should always take this form:
1166 .sp
1167 .if n \{\
1168 .RS 4
1169 .\}
1170 .nf
1171 int rc = some_function (arguments);
1172 assert (rc == 0);
1173 .fi
1174 .if n \{\
1175 .RE
1176 .\}
1177 .sp
1178 Rather than the side\-effect form:
1179 .sp
1180 .if n \{\
1181 .RS 4
1182 .\}
1183 .nf
1184 assert (some_function (arguments) == 0);
1185 .fi
1186 .if n \{\
1187 .RE
1188 .\}
1189 .sp
1190 Since assertions may be removed by an optimizing compiler\&.
1191 .SS "Documentation"
1192 .sp
1193 Man pages are generated from the class header and source files via the doc/mkman tool, and similar functionality in the gitdown tool (\m[blue]\fBhttp://github\&.com/imatix/gitdown\fR\m[])\&. The header file for a class must wrap its interface as follows (example is from include/zclock\&.h):
1194 .sp
1195 .if n \{\
1196 .RS 4
1197 .\}
1198 .nf
1199 // @interface
1200 // Sleep for a number of milliseconds
1201 void
1202 zclock_sleep (int msecs);
1203
1204 // Return current system clock as milliseconds
1205 int64_t
1206 zclock_time (void);
1207
1208 // Self test of this class
1209 int
1210 zclock_test (Bool verbose);
1211 // @end
1212 .fi
1213 .if n \{\
1214 .RE
1215 .\}
1216 .sp
1217 The source file for a class must provide documentation as follows:
1218 .sp
1219 .if n \{\
1220 .RS 4
1221 .\}
1222 .nf
1223 /*
1224 @header
1225 \&.\&.\&.short explanation of class\&.\&.\&.
1226 @discuss
1227 \&.\&.\&.longer discussion of how it works\&.\&.\&.
1228 @end
1229 */
1230 .fi
1231 .if n \{\
1232 .RE
1233 .\}
1234 .sp
1235 The source file for a class then provides the self test example as follows:
1236 .sp
1237 .if n \{\
1238 .RS 4
1239 .\}
1240 .nf
1241 // @selftest
1242 int64_t start = zclock_time ();
1243 zclock_sleep (10);
1244 assert ((zclock_time () \- start) >= 10);
1245 // @end
1246 .fi
1247 .if n \{\
1248 .RE
1249 .\}
1250 .sp
1251 The template for man pages is in doc/mkman\&.
1252 .SS "Development"
1253 .sp
1254 CZMQ is developed through a test\-driven process that guarantees no memory violations or leaks in the code:
1255 .sp
1256 .RS 4
1257 .ie n \{\
1258 \h'-04'\(bu\h'+03'\c
1259 .\}
1260 .el \{\
1261 .sp -1
1262 .IP \(bu 2.3
1263 .\}
1264 Modify a class or method\&.
1265 .RE
1266 .sp
1267 .RS 4
1268 .ie n \{\
1269 \h'-04'\(bu\h'+03'\c
1270 .\}
1271 .el \{\
1272 .sp -1
1273 .IP \(bu 2.3
1274 .\}
1275 Update the test method for that class\&.
1276 .RE
1277 .sp
1278 .RS 4
1279 .ie n \{\
1280 \h'-04'\(bu\h'+03'\c
1281 .\}
1282 .el \{\
1283 .sp -1
1284 .IP \(bu 2.3
1285 .\}
1286 Run the
1287 \fIselftest\fR
1288 script, which uses the Valgrind memcheck tool\&.
1289 .RE
1290 .sp
1291 .RS 4
1292 .ie n \{\
1293 \h'-04'\(bu\h'+03'\c
1294 .\}
1295 .el \{\
1296 .sp -1
1297 .IP \(bu 2.3
1298 .\}
1299 Repeat until perfect\&.
1300 .RE
1301 .SS "Porting CZMQ"
1302 .sp
1303 When you try CZMQ on an OS that it\(cqs 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 quite heavy\&. In any case, the benefit is that once ported, the functionality is available to all applications\&.
1304 .sp
1305 Before attempting to patch code for portability, please read the czmq_prelude\&.h header file\&. There are several typical types of changes you may need to make to get functionality working on a specific operating system:
1306 .sp
1307 .RS 4
1308 .ie n \{\
1309 \h'-04'\(bu\h'+03'\c
1310 .\}
1311 .el \{\
1312 .sp -1
1313 .IP \(bu 2.3
1314 .\}
1315 Defining typedefs which are missing on that specific compiler: do this in czmq_prelude\&.h\&.
1316 .RE
1317 .sp
1318 .RS 4
1319 .ie n \{\
1320 \h'-04'\(bu\h'+03'\c
1321 .\}
1322 .el \{\
1323 .sp -1
1324 .IP \(bu 2.3
1325 .\}
1326 Defining macros that rename exotic library functions to more conventional names: do this in czmq_prelude\&.h\&.
1327 .RE
1328 .sp
1329 .RS 4
1330 .ie n \{\
1331 \h'-04'\(bu\h'+03'\c
1332 .\}
1333 .el \{\
1334 .sp -1
1335 .IP \(bu 2.3
1336 .\}
1337 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\&.
1338 .RE
1339 .sp
1340 The canonical \fIstandard operating system\fR for all CZMQ code is Linux, gcc, POSIX\&.
1341 .SH "AUTHORS"
1342 .sp
1343 The czmq manual was written by the authors in the AUTHORS file\&.
1344 .SH "RESOURCES"
1345 .sp
1346 Main web site: \m[blue]\fB\%\fR\m[]
1347 .sp
1348 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
1349 .SH "COPYRIGHT"
1350 .sp
1351 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
1352 .SH "NOTES"
1353 .IP " 1." 4
1354 zeromq-dev@lists.zeromq.org
1355 .RS 4
1356 \%mailto:zeromq-dev@lists.zeromq.org
1357 .RE
0 #! /usr/bin/perl
1 #
2 # mkman - Generates man pages from C source and header files.
3 #
4 # Syntax: './mkman classname', in doc subdirectory.
5 #
6 # Copyright (c) 1996-2016 iMatix Corporation
7 #
8 # This is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 3 of the License, or (at your option) any later
11 # version.
12 #
13 # This software is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABIL-
15 # ITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 # License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along
19 # with this program. If not, see <http://www.gnu.org/licenses/>.
20 #
21 use File::Basename;
22 use Cwd;
23
24 sub pull {
25 local ($_) = @_;
26 if (/^(.*)(@[a-zA-Z0-9]+)(,(\w*)\s*)?/) {
27 $file = $1;
28 $tag = $2;
29 $opts = $4;
30 $text = "";
31 $ext = (fileparse("$file", qr/[^.]*/))[2];
32 die "Can't read '$file': $!"
33 unless open (SOURCE, $file);
34
35 while (<SOURCE>) {
36 if (/$tag/) {
37 while (<SOURCE>) {
38 last if /\@discuss/ || /\@end/ || /\@ignore/ || /\@header/;
39 $_ = " $_" if ($opts eq "code");
40 s/^ // if ($opts eq "left");
41 $_ = " $_" if ($opts eq "test");
42 s/^ / / if ($opts eq "test");
43 $text .= $_;
44 }
45 }
46 }
47 close (SOURCE);
48 # Add code fences for markdown highlighting
49 $text = "```$ext\n$text```\n" if (length $text) and ($opts eq "code" or $opts eq "test");
50
51 $text = "Please add '$tag' section in '$file'.\n" unless $text;
52 return $text;
53 }
54 else {
55 print "E: bad pull request: $_\n";
56 }
57 }
58
59 sub generate_manpage {
60 local ($name, $outp, $rootsrcdir) = @_;
61 $name = $1 if $name =~ /(\w+)\.\w+/; # Chop off extensions
62 $outp = $1 if $outp =~ /^(.+)\.[^\.\/]+$/;
63 $outp_basename = basename ($outp);
64 $outp_basename = $2 if $outp =~ /^(.*\/)?(\w+)$/;
65
66 if ($ENV{"V"} == "1") {
67 printf "D: generate_manpage() got name='$name' outp='$outp' outp_basename='$outp_basename' rootsrcdir='$rootsrcdir'\n";
68 }
69
70 # Check if we're making the man page for a main program, or a class
71 $cat = 0; # Unknown category
72 die "Can't open '" . cwd() . "/Makefile'"
73 unless open (MAKEFILE, "Makefile");
74 while (<MAKEFILE>) {
75 if (/MAN1.*$outp_basename\.1/) {
76 $source = "$rootsrcdir/src/$name.c";
77 $header = "$rootsrcdir/src/$name.c";
78 $cat = 1;
79 last;
80 }
81 elsif (/MAN3.*$name\.3/) {
82 $source = "$rootsrcdir/src/$name.c";
83 $header = "$rootsrcdir/include/$name.h";
84 $cat = 3;
85 last;
86 }
87 }
88 close MAKEFILE;
89
90 # Look for class title in 2nd line of source
91 # If there's no class file, leave hand-written man page alone
92 die "Can't open '$source'"
93 unless open (SOURCE, $source);
94 $_ = <SOURCE>;
95 $_ = <SOURCE>;
96 $title = "no title found";
97 $title = $1 if (/ \w+ - (.*)/);
98 close (SOURCE);
99
100 # Open output file
101 die "Can't create '$outp.txt': $!"
102 unless open (OUTPUT, ">$outp.txt");
103
104 printf "Generating '$outp.txt' from '$source'...\n";
105 $underline = "=" x (length ($name) + 3);
106
107 $template = <<"END";
108 $name($cat)
109 $underline
110
111 NAME
112 ----
113 $outp_basename - $title
114
115 SYNOPSIS
116 --------
117 ----
118 pull $header\@interface
119 pull $source\@interface,left
120 ----
121
122 DESCRIPTION
123 -----------
124
125 pull $source\@header,left
126
127 pull $source\@discuss,left
128
129 EXAMPLE
130 -------
131 .From $name\_test method
132 ----
133 pull $source\@selftest,left
134 ----
135 END
136
137 # Now process template
138 for (split /^/, $template) {
139 if (/^pull (.*)$/) {
140 print OUTPUT pull ($1);
141 }
142 else {
143 print OUTPUT $_;
144 }
145 }
146
147 # Generate a simple text documentation for README.txt
148 close OUTPUT;
149 printf "Generating '$outp.doc' from '$source'...\n";
150 die "Can't create '$outp.doc': $!"
151 unless open (OUTPUT, ">$outp.doc");
152 print OUTPUT "#### $outp_basename - $title\n\n";
153 print OUTPUT pull ("$source\@header,left");
154 print OUTPUT "\n";
155 print OUTPUT pull ("$source\@discuss,left");
156 print OUTPUT "\nThis is the class interface:\n\n";
157 print OUTPUT pull ("$header\@interface,code");
158 print OUTPUT pull ("$source\@interface,left");
159 print OUTPUT "\nThis is the class self test code:\n\n";
160 print OUTPUT pull ("$source\@selftest,test");
161 print OUTPUT "\n";
162 close OUTPUT;
163 }
164
165 $name = shift (@ARGV);
166 $outp = shift (@ARGV);
167 if (!$outp) {
168 $outp=$name;
169 }
170 $rootsrcdir = shift (@ARGV);
171 if (!$rootsrcdir) {
172 $rootsrcdir="..";
173 }
174
175 printf "D: got name='$name' outp='$outp' rootsrcdir='$rootsrcdir' from the start\n";
176 generate_manpage ($name, $outp, $rootsrcdir);
0 '\" t
1 .\" Title: zactor
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZACTOR" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zactor \- simple actor framework
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // Actors get a pipe and arguments from caller
37 typedef void (zactor_fn) (
38 zsock_t *pipe, void *args);
39
40 // Create a new actor passing arbitrary arguments reference\&.
41 CZMQ_EXPORT zactor_t *
42 zactor_new (zactor_fn task, void *args);
43
44 // Destroy an actor\&.
45 CZMQ_EXPORT void
46 zactor_destroy (zactor_t **self_p);
47
48 // Send a zmsg message to the actor, take ownership of the message
49 // and destroy when it has been sent\&.
50 CZMQ_EXPORT int
51 zactor_send (zactor_t *self, zmsg_t **msg_p);
52
53 // Receive a zmsg message from the actor\&. Returns NULL if the actor
54 // was interrupted before the message could be received, or if there
55 // was a timeout on the actor\&.
56 // Caller owns return value and must destroy it when done\&.
57 CZMQ_EXPORT zmsg_t *
58 zactor_recv (zactor_t *self);
59
60 // Probe the supplied object, and report if it looks like a zactor_t\&.
61 CZMQ_EXPORT bool
62 zactor_is (void *self);
63
64 // Probe the supplied reference\&. If it looks like a zactor_t instance,
65 // return the underlying libzmq actor handle; else if it looks like
66 // a libzmq actor handle, return the supplied value\&.
67 CZMQ_EXPORT void *
68 zactor_resolve (void *self);
69
70 // Return the actor\*(Aqs zsock handle\&. Use this when you absolutely need
71 // to work with the zsock instance rather than the actor\&.
72 CZMQ_EXPORT zsock_t *
73 zactor_sock (zactor_t *self);
74
75 // Self test of this class\&.
76 CZMQ_EXPORT void
77 zactor_test (bool verbose);
78
79 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zactor\&.c\*(Aq\&.
80 .fi
81 .SH "DESCRIPTION"
82 .sp
83 The zactor class provides a simple actor framework\&. It replaces the CZMQ zthread class, which had a complex API that did not fit the CLASS standard\&. A CZMQ actor is implemented as a thread plus a PAIR\-PAIR pipe\&. The constructor and destructor are always synchronized, so the caller can be sure all resources are created, and destroyed, when these calls complete\&. (This solves a major problem with zthread, that a caller could not be sure when a child thread had finished\&.)
84 .sp
85 A zactor_t instance acts like a zsock_t and you can pass it to any CZMQ method that would take a zsock_t argument, including methods in zframe, zmsg, zstr, and zpoller\&. (zloop somehow escaped and needs catching\&.)
86 .sp
87 An actor function MUST call zsock_signal (pipe) when initialized and MUST listen to pipe and exit on $TERM command\&.
88 .sp
89 Please add \fI@discuss\fR section in \fI\&./\&.\&./src/zactor\&.c\fR\&.
90 .SH "EXAMPLE"
91 .PP
92 \fBFrom zactor_test method\fR.
93 .sp
94 .if n \{\
95 .RS 4
96 .\}
97 .nf
98 zactor_t *actor = zactor_new (echo_actor, "Hello, World");
99 assert (actor);
100 zstr_sendx (actor, "ECHO", "This is a string", NULL);
101 char *string = zstr_recv (actor);
102 assert (streq (string, "This is a string"));
103 free (string);
104 zactor_destroy (&actor);
105 .fi
106 .if n \{\
107 .RE
108 .\}
109 .sp
110 .SH "AUTHORS"
111 .sp
112 The czmq manual was written by the authors in the AUTHORS file\&.
113 .SH "RESOURCES"
114 .sp
115 Main web site: \m[blue]\fB\%\fR\m[]
116 .sp
117 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
118 .SH "COPYRIGHT"
119 .sp
120 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
121 .SH "NOTES"
122 .IP " 1." 4
123 zeromq-dev@lists.zeromq.org
124 .RS 4
125 \%mailto:zeromq-dev@lists.zeromq.org
126 .RE
5252 CZMQ_EXPORT void
5353 zactor_test (bool verbose);
5454
55 Please add '@interface' section in './../src/zactor.c'.
5556 ----
5657
5758 DESCRIPTION
7273 An actor function MUST call zsock_signal (pipe) when initialized
7374 and MUST listen to pipe and exit on $TERM command.
7475
75 Please add @discuss section in ../src/zactor.c.
76 Please add '@discuss' section in './../src/zactor.c'.
7677
7778 EXAMPLE
7879 -------
0 '\" t
1 .\" Title: zarmour
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZARMOUR" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zarmour \- armoured text encoding and decoding
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 #define ZARMOUR_MODE_BASE64_STD 0 // Standard base 64
37 #define ZARMOUR_MODE_BASE64_URL 1 // URL and filename friendly base 64
38 #define ZARMOUR_MODE_BASE32_STD 2 // Standard base 32
39 #define ZARMOUR_MODE_BASE32_HEX 3 // Extended hex base 32
40 #define ZARMOUR_MODE_BASE16 4 // Standard base 16
41 #define ZARMOUR_MODE_Z85 5 // Z85 from ZeroMQ RFC 32
42
43 // Create a new zarmour
44 CZMQ_EXPORT zarmour_t *
45 zarmour_new (void);
46
47 // Destroy the zarmour
48 CZMQ_EXPORT void
49 zarmour_destroy (zarmour_t **self_p);
50
51 // Encode a stream of bytes into an armoured string\&. Returns the armoured
52 // string, or NULL if there was insufficient memory available to allocate
53 // a new string\&.
54 // Caller owns return value and must destroy it when done\&.
55 CZMQ_EXPORT char *
56 zarmour_encode (zarmour_t *self, const byte *data, size_t size);
57
58 // Decode an armoured string into a chunk\&. The decoded output is
59 // null\-terminated, so it may be treated as a string, if that\*(Aqs what
60 // it was prior to encoding\&.
61 // Caller owns return value and must destroy it when done\&.
62 CZMQ_EXPORT zchunk_t *
63 zarmour_decode (zarmour_t *self, const char *data);
64
65 // Get the mode property\&.
66 CZMQ_EXPORT int
67 zarmour_mode (zarmour_t *self);
68
69 // Get printable string for mode\&.
70 CZMQ_EXPORT const char *
71 zarmour_mode_str (zarmour_t *self);
72
73 // Set the mode property\&.
74 CZMQ_EXPORT void
75 zarmour_set_mode (zarmour_t *self, int mode);
76
77 // Return true if padding is turned on\&.
78 CZMQ_EXPORT bool
79 zarmour_pad (zarmour_t *self);
80
81 // Turn padding on or off\&. Default is on\&.
82 CZMQ_EXPORT void
83 zarmour_set_pad (zarmour_t *self, bool pad);
84
85 // Get the padding character\&.
86 CZMQ_EXPORT char
87 zarmour_pad_char (zarmour_t *self);
88
89 // Set the padding character\&.
90 CZMQ_EXPORT void
91 zarmour_set_pad_char (zarmour_t *self, char pad_char);
92
93 // Return if splitting output into lines is turned on\&. Default is off\&.
94 CZMQ_EXPORT bool
95 zarmour_line_breaks (zarmour_t *self);
96
97 // Turn splitting output into lines on or off\&.
98 CZMQ_EXPORT void
99 zarmour_set_line_breaks (zarmour_t *self, bool line_breaks);
100
101 // Get the line length used for splitting lines\&.
102 CZMQ_EXPORT size_t
103 zarmour_line_length (zarmour_t *self);
104
105 // Set the line length used for splitting lines\&.
106 CZMQ_EXPORT void
107 zarmour_set_line_length (zarmour_t *self, size_t line_length);
108
109 // Print properties of object
110 CZMQ_EXPORT void
111 zarmour_print (zarmour_t *self);
112
113 // Self test of this class\&.
114 CZMQ_EXPORT void
115 zarmour_test (bool verbose);
116
117 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zarmour\&.c\*(Aq\&.
118 .fi
119 .SH "DESCRIPTION"
120 .sp
121 zarmour \- armoured text encoding and decoding
122 .sp
123 The zarmour class implements encoding and decoding of armoured text data\&. The following codecs are implemented: * RFC 4648 (\m[blue]\fBhttp://www\&.ietf\&.org/rfc/rfc4648\&.txt\fR\m[]) \- base64 \- base64url \- base32 \- base32hex \- base16 * Z85 (\m[blue]\fBhttp://rfc\&.zeromq\&.org/spec:32\fR\m[]) All RFC4648 base64 and base32 variants support padding the output\&. The pad character is configurable\&. Default is padding on, with character \fI=\fR\&. Additionally, in some cases (e\&.g\&. MIME), splitting the output into lines of a specific length is required\&. This feature is also supported, though turned off by default\&. The z85 mode does neither padding nor line breaks; it is merely a wrapping of the corresponding libzmq methods\&. Encoding will assert if input length is not divisible by 4 and decoding will assert if input length is not divisible by 5\&.
124 .SH "EXAMPLE"
125 .PP
126 \fBFrom zarmour_test method\fR.
127 .sp
128 .if n \{\
129 .RS 4
130 .\}
131 .nf
132 zarmour_t *self = zarmour_new ();
133 assert (self);
134
135 int mode = zarmour_mode (self);
136 assert (mode == ZARMOUR_MODE_BASE64_STD);
137
138 zarmour_set_mode (self, ZARMOUR_MODE_BASE64_URL);
139 mode = zarmour_mode (self);
140 assert (mode == ZARMOUR_MODE_BASE64_URL);
141
142 assert (zarmour_pad (self));
143 zarmour_set_pad (self, false);
144 assert (!zarmour_pad (self));
145
146 assert (zarmour_pad_char (self) == \*(Aq=\*(Aq);
147 zarmour_set_pad_char (self, \*(Aq!\*(Aq);
148 assert (zarmour_pad_char (self) == \*(Aq!\*(Aq);
149 zarmour_set_pad_char (self, \*(Aq=\*(Aq);
150 assert (zarmour_pad_char (self) == \*(Aq=\*(Aq);
151
152 assert (!zarmour_line_breaks (self));
153 zarmour_set_line_breaks (self, true);
154 assert (zarmour_line_breaks (self));
155
156 assert (zarmour_line_length (self) == 72);
157 zarmour_set_line_length (self, 64);
158 assert (zarmour_line_length (self) == 64);
159
160 // Test against test vectors from RFC4648\&.
161 zarmour_set_mode (self, ZARMOUR_MODE_BASE64_STD);
162 if (verbose)
163 zarmour_print (self);
164
165 s_armour_test (self, "", "", verbose);
166 s_armour_test (self, "f", "Zg", verbose);
167 s_armour_test (self, "fo", "Zm8", verbose);
168 s_armour_test (self, "foo", "Zm9v", verbose);
169 s_armour_test (self, "foob", "Zm9vYg", verbose);
170 s_armour_test (self, "fooba", "Zm9vYmE", verbose);
171 s_armour_test (self, "foobar", "Zm9vYmFy", verbose);
172 zarmour_set_pad (self, true);
173 if (verbose)
174 zarmour_print (self);
175
176 s_armour_test (self, "", "", verbose);
177 s_armour_test (self, "f", "Zg==", verbose);
178 s_armour_test (self, "fo", "Zm8=", verbose);
179 s_armour_test (self, "foo", "Zm9v", verbose);
180 s_armour_test (self, "foob", "Zm9vYg==", verbose);
181 s_armour_test (self, "fooba", "Zm9vYmE=", verbose);
182 s_armour_test (self, "foobar", "Zm9vYmFy", verbose);
183
184 zarmour_set_pad (self, false);
185 zarmour_set_mode (self, ZARMOUR_MODE_BASE64_URL);
186 if (verbose)
187 zarmour_print (self);
188
189 s_armour_test (self, "", "", verbose);
190 s_armour_test (self, "f", "Zg", verbose);
191 s_armour_test (self, "fo", "Zm8", verbose);
192 s_armour_test (self, "foo", "Zm9v", verbose);
193 s_armour_test (self, "foob", "Zm9vYg", verbose);
194 s_armour_test (self, "fooba", "Zm9vYmE", verbose);
195 s_armour_test (self, "foobar", "Zm9vYmFy", verbose);
196 zarmour_set_pad (self, true);
197 if (verbose)
198 zarmour_print (self);
199
200 s_armour_test (self, "", "", verbose);
201 s_armour_test (self, "f", "Zg==", verbose);
202 s_armour_test (self, "fo", "Zm8=", verbose);
203 s_armour_test (self, "foo", "Zm9v", verbose);
204 s_armour_test (self, "foob", "Zm9vYg==", verbose);
205 s_armour_test (self, "fooba", "Zm9vYmE=", verbose);
206 s_armour_test (self, "foobar", "Zm9vYmFy", verbose);
207
208 zarmour_set_pad (self, false);
209 zarmour_set_mode (self, ZARMOUR_MODE_BASE32_STD);
210 if (verbose)
211 zarmour_print (self);
212
213 s_armour_test (self, "", "", verbose);
214 s_armour_test (self, "f", "MY", verbose);
215 s_armour_test (self, "fo", "MZXQ", verbose);
216 s_armour_test (self, "foo", "MZXW6", verbose);
217 s_armour_test (self, "foob", "MZXW6YQ", verbose);
218 s_armour_test (self, "fooba", "MZXW6YTB", verbose);
219 s_armour_test (self, "foobar", "MZXW6YTBOI", verbose);
220 s_armour_decode (self, "my", "f", verbose);
221 s_armour_decode (self, "mzxq", "fo", verbose);
222 s_armour_decode (self, "mzxw6", "foo", verbose);
223 s_armour_decode (self, "mzxw6yq", "foob", verbose);
224 s_armour_decode (self, "mzxw6ytb", "fooba", verbose);
225 s_armour_decode (self, "mzxw6ytboi", "foobar", verbose);
226 zarmour_set_pad (self, true);
227 if (verbose)
228 zarmour_print (self);
229
230 s_armour_test (self, "", "", verbose);
231 s_armour_test (self, "f", "MY======", verbose);
232 s_armour_test (self, "fo", "MZXQ====", verbose);
233 s_armour_test (self, "foo", "MZXW6===", verbose);
234 s_armour_test (self, "foob", "MZXW6YQ=", verbose);
235 s_armour_test (self, "fooba", "MZXW6YTB", verbose);
236 s_armour_test (self, "foobar", "MZXW6YTBOI======", verbose);
237 s_armour_decode (self, "my======", "f", verbose);
238 s_armour_decode (self, "mzxq====", "fo", verbose);
239 s_armour_decode (self, "mzxw6===", "foo", verbose);
240 s_armour_decode (self, "mzxw6yq=", "foob", verbose);
241 s_armour_decode (self, "mzxw6ytb", "fooba", verbose);
242 s_armour_decode (self, "mzxw6ytboi======", "foobar", verbose);
243
244 zarmour_set_pad (self, false);
245 zarmour_set_mode (self, ZARMOUR_MODE_BASE32_HEX);
246 if (verbose)
247 zarmour_print (self);
248
249 s_armour_test (self, "", "", verbose);
250 s_armour_test (self, "f", "CO", verbose);
251 s_armour_test (self, "fo", "CPNG", verbose);
252 s_armour_test (self, "foo", "CPNMU", verbose);
253 s_armour_test (self, "foob", "CPNMUOG", verbose);
254 s_armour_test (self, "fooba", "CPNMUOJ1", verbose);
255 s_armour_test (self, "foobar", "CPNMUOJ1E8", verbose);
256 s_armour_decode (self, "co", "f", verbose);
257 s_armour_decode (self, "cpng", "fo", verbose);
258 s_armour_decode (self, "cpnmu", "foo", verbose);
259 s_armour_decode (self, "cpnmuog", "foob", verbose);
260 s_armour_decode (self, "cpnmuoj1", "fooba", verbose);
261 s_armour_decode (self, "cpnmuoj1e8", "foobar", verbose);
262 zarmour_set_pad (self, true);
263 if (verbose)
264 zarmour_print (self);
265
266 s_armour_test (self, "", "", verbose);
267 s_armour_test (self, "f", "CO======", verbose);
268 s_armour_test (self, "fo", "CPNG====", verbose);
269 s_armour_test (self, "foo", "CPNMU===", verbose);
270 s_armour_test (self, "foob", "CPNMUOG=", verbose);
271 s_armour_test (self, "fooba", "CPNMUOJ1", verbose);
272 s_armour_test (self, "foobar", "CPNMUOJ1E8======", verbose);
273 s_armour_decode (self, "co======", "f", verbose);
274 s_armour_decode (self, "cpng====", "fo", verbose);
275 s_armour_decode (self, "cpnmu===", "foo", verbose);
276 s_armour_decode (self, "cpnmuog=", "foob", verbose);
277 s_armour_decode (self, "cpnmuoj1", "fooba", verbose);
278 s_armour_decode (self, "cpnmuoj1e8======", "foobar", verbose);
279 zarmour_set_pad (self, true);
280
281 zarmour_set_mode (self, ZARMOUR_MODE_BASE16);
282 if (verbose)
283 zarmour_print (self);
284
285 s_armour_test (self, "", "", verbose);
286 s_armour_test (self, "f", "66", verbose);
287 s_armour_test (self, "fo", "666F", verbose);
288 s_armour_test (self, "foo", "666F6F", verbose);
289 s_armour_test (self, "foob", "666F6F62", verbose);
290 s_armour_test (self, "fooba", "666F6F6261", verbose);
291 s_armour_test (self, "foobar", "666F6F626172", verbose);
292 s_armour_decode (self, "666f", "fo", verbose);
293 s_armour_decode (self, "666f6f", "foo", verbose);
294 s_armour_decode (self, "666f6f62", "foob", verbose);
295 s_armour_decode (self, "666f6f6261", "fooba", verbose);
296 s_armour_decode (self, "666f6f626172", "foobar", verbose);
297
298 #ifdef _INCLUDE_Z85
299 // Z85 test is homemade; using 0, 4 and 8 bytes, with precalculated
300 // test vectors created with a libzmq test\&.
301 // \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
302
303 // Make a fake curve key from hex (base16) string, making sure
304 // there are no null bytes inside, so we can use our test utility
305 zarmour_set_mode (self, ZARMOUR_MODE_BASE16);
306 zarmour_set_line_breaks (self, false);
307
308 zchunk_t *chunk = zarmour_decode (self,
309 "4E6F87E2FB6EB22A1EF5E257B75D79124949565F0B8B36A878A4F03111C96E0B");
310 assert (chunk);
311
312 zarmour_set_mode (self, ZARMOUR_MODE_Z85); // Z85 mode does not support padding or line breaks
313 zarmour_set_pad (self, false); // so these two are superfluous;
314 zarmour_set_line_breaks (self, false); // just for consistency
315 if (verbose)
316 zarmour_print (self);
317
318 s_armour_test (self, "", "", verbose);
319 s_armour_test (self, "foob", "w]zP%", verbose);
320 s_armour_test (self, "foobar!!", "w]zP%vr9Im", verbose);
321 s_armour_test (self, (char *) zchunk_data (chunk),
322 "ph+{E}!&X?9}!I]W{sm(nL8@&3Yu{wC+<*\-5Y[[#", verbose);
323 zchunk_destroy (&chunk);
324 #endif
325
326 // Armouring longer byte array to test line breaks
327 zarmour_set_pad (self, true);
328 zarmour_set_line_breaks (self, true);
329 byte test_data [256];
330 int index;
331 for (index = 0; index < 256; index++)
332 test_data [index] = index;
333
334 zarmour_set_mode (self, ZARMOUR_MODE_BASE64_STD);
335 s_armour_test_long (self, test_data, 256, verbose);
336 zarmour_set_mode (self, ZARMOUR_MODE_BASE64_URL);
337 s_armour_test_long (self, test_data, 256, verbose);
338 zarmour_set_mode (self, ZARMOUR_MODE_BASE32_STD);
339 s_armour_test_long (self, test_data, 256, verbose);
340 zarmour_set_mode (self, ZARMOUR_MODE_BASE32_HEX);
341 s_armour_test_long (self, test_data, 256, verbose);
342 zarmour_set_mode (self, ZARMOUR_MODE_BASE16);
343 s_armour_test_long (self, test_data, 256, verbose);
344 #ifdef _INCLUDE_Z85
345 zarmour_set_mode (self, ZARMOUR_MODE_Z85);
346 s_armour_test_long (self, test_data, 256, verbose);
347 #endif
348
349 zarmour_destroy (&self);
350 .fi
351 .if n \{\
352 .RE
353 .\}
354 .sp
355 .SH "AUTHORS"
356 .sp
357 The czmq manual was written by the authors in the AUTHORS file\&.
358 .SH "RESOURCES"
359 .sp
360 Main web site: \m[blue]\fB\%\fR\m[]
361 .sp
362 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
363 .SH "COPYRIGHT"
364 .sp
365 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
366 .SH "NOTES"
367 .IP " 1." 4
368 zeromq-dev@lists.zeromq.org
369 .RS 4
370 \%mailto:zeromq-dev@lists.zeromq.org
371 .RE
9090 CZMQ_EXPORT void
9191 zarmour_test (bool verbose);
9292
93 Please add '@interface' section in './../src/zarmour.c'.
9394 ----
9495
9596 DESCRIPTION
0 '\" t
1 .\" Title: zauth
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZAUTH" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zauth \- authentication for ZeroMQ security mechanisms
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 #define CURVE_ALLOW_ANY "*"
35
36 // CZMQ v3 API (for use with zsock, not zsocket, which is deprecated)\&.
37 //
38 // Create new zauth actor instance\&. This installs authentication on all
39 // zsock sockets\&. Until you add policies, all incoming NULL connections are
40 // allowed (classic ZeroMQ behaviour), and all PLAIN and CURVE connections
41 // are denied:
42 //
43 // zactor_t *auth = zactor_new (zauth, NULL);
44 //
45 // Destroy zauth instance\&. This removes authentication and allows all
46 // connections to pass, without authentication:
47 //
48 // zactor_destroy (&auth);
49 //
50 // Note that all zauth commands are synchronous, so your application always
51 // waits for a signal from the actor after each command\&.
52 //
53 // Enable verbose logging of commands and activity\&. Verbose logging can help
54 // debug non\-trivial authentication policies:
55 //
56 // zstr_send (auth, "VERBOSE");
57 // zsock_wait (auth);
58 //
59 // Allow (whitelist) a list of IP addresses\&. For NULL, all clients from
60 // these addresses will be accepted\&. For PLAIN and CURVE, they will be
61 // allowed to continue with authentication\&. You can call this method
62 // multiple times to whitelist more IP addresses\&. If you whitelist one
63 // or more addresses, any non\-whitelisted addresses are treated as
64 // blacklisted:
65 //
66 // zstr_sendx (auth, "ALLOW", "127\&.0\&.0\&.1", "127\&.0\&.0\&.2", NULL);
67 // zsock_wait (auth);
68 //
69 // Deny (blacklist) a list of IP addresses\&. For all security mechanisms,
70 // this rejects the connection without any further authentication\&. Use
71 // either a whitelist, or a blacklist, not not both\&. If you define both
72 // a whitelist and a blacklist, only the whitelist takes effect:
73 //
74 // zstr_sendx (auth, "DENY", "192\&.168\&.0\&.1", "192\&.168\&.0\&.2", NULL);
75 // zsock_wait (auth);
76 //
77 // Configure PLAIN authentication using a plain\-text password file\&. You can
78 // modify the password file at any time; zauth will reload it automatically
79 // if modified externally:
80 //
81 // zstr_sendx (auth, "PLAIN", filename, NULL);
82 // zsock_wait (auth);
83 //
84 // Configure CURVE authentication, using a directory that holds all public
85 // client certificates, i\&.e\&. their public keys\&. The certificates must be in
86 // zcert_save format\&. You can add and remove certificates in that directory
87 // at any time\&. To allow all client keys without checking, specify
88 // CURVE_ALLOW_ANY for the directory name:
89 //
90 // zstr_sendx (auth, "CURVE", directory, NULL);
91 // zsock_wait (auth);
92 //
93 // Configure GSSAPI authentication, using an underlying mechanism (usually
94 // Kerberos) to establish a secure context and perform mutual authentication:
95 //
96 // zstr_sendx (auth, "GSSAPI", NULL);
97 // zsock_wait (auth);
98 //
99 // This is the zauth constructor as a zactor_fn:
100 CZMQ_EXPORT void
101 zauth (zsock_t *pipe, void *certstore);
102
103 // Selftest
104 CZMQ_EXPORT void
105 zauth_test (bool verbose);
106 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zauth\&.c\*(Aq\&.
107 .fi
108 .SH "DESCRIPTION"
109 .sp
110 A zauth actor takes over authentication for all incoming connections in its context\&. You can whitelist or blacklist peers based on IP address, and define policies for securing PLAIN, CURVE, and GSSAPI connections\&.
111 .sp
112 This class replaces zauth_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock)\&.
113 .SH "EXAMPLE"
114 .PP
115 \fBFrom zauth_test method\fR.
116 .sp
117 .if n \{\
118 .RS 4
119 .\}
120 .nf
121 // Create temporary directory for test files
122 # define TESTDIR "\&.test_zauth"
123 zsys_dir_create (TESTDIR);
124
125 // Check there\*(Aqs no authentication
126 zsock_t *server = zsock_new (ZMQ_PULL);
127 assert (server);
128 zsock_t *client = zsock_new (ZMQ_PUSH);
129 assert (client);
130 bool success = s_can_connect (&server, &client, true);
131 assert (success);
132
133 // Install the authenticator
134 zactor_t *auth = zactor_new (zauth, NULL);
135 assert (auth);
136 if (verbose) {
137 zstr_sendx (auth, "VERBOSE", NULL);
138 zsock_wait (auth);
139 }
140 // Check there\*(Aqs no authentication on a default NULL server
141 success = s_can_connect (&server, &client, true);
142 assert (success);
143
144 // When we set a domain on the server, we switch on authentication
145 // for NULL sockets, but with no policies, the client connection
146 // will be allowed\&.
147 zsock_set_zap_domain (server, "global");
148 success = s_can_connect (&server, &client, true);
149 assert (success);
150
151 // Blacklist 127\&.0\&.0\&.1, connection should fail
152 zsock_set_zap_domain (server, "global");
153 zstr_sendx (auth, "DENY", "127\&.0\&.0\&.1", NULL);
154 zsock_wait (auth);
155 success = s_can_connect (&server, &client, true);
156 assert (!success);
157
158 // Whitelist our address, which overrides the blacklist
159 zsock_set_zap_domain (server, "global");
160 zstr_sendx (auth, "ALLOW", "127\&.0\&.0\&.1", NULL);
161 zsock_wait (auth);
162 success = s_can_connect (&server, &client, true);
163 assert (success);
164
165 // Try PLAIN authentication
166 zsock_set_plain_server (server, 1);
167 zsock_set_plain_username (client, "admin");
168 zsock_set_plain_password (client, "Password");
169 success = s_can_connect (&server, &client, true);
170 assert (!success);
171
172 FILE *password = fopen (TESTDIR "/password\-file", "w");
173 assert (password);
174 fprintf (password, "admin=Password\en");
175 fclose (password);
176 zsock_set_plain_server (server, 1);
177 zsock_set_plain_username (client, "admin");
178 zsock_set_plain_password (client, "Password");
179 zstr_sendx (auth, "PLAIN", TESTDIR "/password\-file", NULL);
180 zsock_wait (auth);
181 success = s_can_connect (&server, &client, true);
182 assert (success);
183
184 zsock_set_plain_server (server, 1);
185 zsock_set_plain_username (client, "admin");
186 zsock_set_plain_password (client, "Bogus");
187 success = s_can_connect (&server, &client, true);
188 assert (!success);
189
190 if (zsys_has_curve ()) {
191 // Try CURVE authentication
192 // We\*(Aqll create two new certificates and save the client public
193 // certificate on disk; in a real case we\*(Aqd transfer this securely
194 // from the client machine to the server machine\&.
195 zcert_t *server_cert = zcert_new ();
196 assert (server_cert);
197 zcert_t *client_cert = zcert_new ();
198 assert (client_cert);
199 const char *server_key = zcert_public_txt (server_cert);
200
201 // Test without setting\-up any authentication
202 zcert_apply (server_cert, server);
203 zcert_apply (client_cert, client);
204 zsock_set_curve_server (server, 1);
205 zsock_set_curve_serverkey (client, server_key);
206 success = s_can_connect (&server, &client, true);
207 assert (!success);
208
209 // Test CURVE_ALLOW_ANY
210 zcert_apply (server_cert, server);
211 zcert_apply (client_cert, client);
212 zsock_set_curve_server (server, 1);
213 zsock_set_curve_serverkey (client, server_key);
214 zstr_sendx (auth, "CURVE", CURVE_ALLOW_ANY, NULL);
215 zsock_wait (auth);
216 success = s_can_connect (&server, &client, true);
217 assert (success);
218
219 // Test full client authentication using certificates
220 zcert_set_meta (client_cert, "Hello", "%s", "World!");
221 zcert_apply (server_cert, server);
222 zcert_apply (client_cert, client);
223 zsock_set_curve_server (server, 1);
224 zsock_set_curve_serverkey (client, server_key);
225 zcert_save_public (client_cert, TESTDIR "/mycert\&.txt");
226 zstr_sendx (auth, "CURVE", TESTDIR, NULL);
227 zsock_wait (auth);
228 success = s_can_connect (&server, &client, false);
229 assert (success);
230
231 #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (4, 1, 0))
232 // Test send/recv certificate metadata
233 zframe_t *frame = zframe_recv (server);
234 assert (frame != NULL);
235 const char *meta = zframe_meta (frame, "Hello");
236 assert (meta != NULL);
237 assert (streq (meta, "World!"));
238 zframe_destroy (&frame);
239 s_renew_sockets(&server, &client);
240 #endif
241
242 zcert_destroy (&server_cert);
243 zcert_destroy (&client_cert);
244
245 // Test custom zcertstore
246 zcertstore_t *certstore = zcertstore_new (NULL);
247 zcertstore_set_loader (certstore, s_test_loader, NULL, NULL);
248 zactor_destroy(&auth);
249 auth = zactor_new (zauth, certstore);
250 assert (auth);
251 if (verbose) {
252 zstr_sendx (auth, "VERBOSE", NULL);
253 zsock_wait (auth);
254 }
255
256 byte public_key [32] = { 105, 76, 150, 58, 214, 191, 218, 65, 50, 172,
257 131, 188, 247, 211, 136, 170, 227, 26, 57, 170,
258 185, 63, 246, 225, 177, 230, 12, 8, 134, 136,
259 105, 106 };
260 byte secret_key [32] = { 245, 217, 172, 73, 106, 28, 195, 17, 218, 132,
261 135, 209, 99, 240, 98, 232, 7, 137, 244, 100,
262 242, 23, 29, 114, 70, 223, 83, 1, 113, 207,
263 132, 149 };
264 zcert_t *shared_cert = zcert_new_from (public_key, secret_key);
265 assert (shared_cert);
266 zcert_apply (shared_cert, server);
267 zcert_apply (shared_cert, client);
268 zsock_set_curve_server (server, 1);
269 zsock_set_curve_serverkey (client, "x?T*N/1Y{8goubv{Ts}#&#f}TXJ//DVe#D2HkoLU");
270 success = s_can_connect (&server, &client, true);
271 assert (success);
272 zcert_destroy (&shared_cert);
273 }
274 // Remove the authenticator and check a normal connection works
275 zactor_destroy (&auth);
276 success = s_can_connect (&server, &client, true);
277 assert (success);
278
279 zsock_destroy (&client);
280 zsock_destroy (&server);
281
282 // Delete all test files
283 zdir_t *dir = zdir_new (TESTDIR, NULL);
284 assert (dir);
285 zdir_remove (dir, true);
286 zdir_destroy (&dir);
287 .fi
288 .if n \{\
289 .RE
290 .\}
291 .sp
292 .SH "AUTHORS"
293 .sp
294 The czmq manual was written by the authors in the AUTHORS file\&.
295 .SH "RESOURCES"
296 .sp
297 Main web site: \m[blue]\fB\%\fR\m[]
298 .sp
299 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
300 .SH "COPYRIGHT"
301 .sp
302 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
303 .SH "NOTES"
304 .IP " 1." 4
305 zeromq-dev@lists.zeromq.org
306 .RS 4
307 \%mailto:zeromq-dev@lists.zeromq.org
308 .RE
7979 // Selftest
8080 CZMQ_EXPORT void
8181 zauth_test (bool verbose);
82 Please add '@interface' section in './../src/zauth.c'.
8283 ----
8384
8485 DESCRIPTION
0 '\" t
1 .\" Title: zbeacon
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZBEACON" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zbeacon \- LAN discovery and presence
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // Create new zbeacon actor instance:
35 //
36 // zactor_t *beacon = zactor_new (zbeacon, NULL);
37 //
38 // Destroy zbeacon instance:
39 //
40 // zactor_destroy (&beacon);
41 //
42 // Enable verbose logging of commands and activity:
43 //
44 // zstr_send (beacon, "VERBOSE");
45 //
46 // Configure beacon to run on specified UDP port, and return the name of
47 // the host, which can be used as endpoint for incoming connections\&. To
48 // force the beacon to operate on a given interface, set the environment
49 // variable ZSYS_INTERFACE, or call zsys_set_interface() before creating
50 // the beacon\&. If the system does not support UDP broadcasts (lacking a
51 // workable interface), returns an empty hostname:
52 //
53 // // Pictures: \*(Aqs\*(Aq = C string, \*(Aqi\*(Aq = int
54 // zsock_send (beacon, "si", "CONFIGURE", port_number);
55 // char *hostname = zstr_recv (beacon);
56 //
57 // Start broadcasting a beacon at a specified interval in msec\&. The beacon
58 // data can be at most UDP_FRAME_MAX bytes; this constant is defined in
59 // zsys\&.h to be 255:
60 //
61 // // Pictures: \*(Aqb\*(Aq = byte * data + size_t size
62 // zsock_send (beacon, "sbi", "PUBLISH", data, size, interval);
63 //
64 // Stop broadcasting the beacon:
65 //
66 // zstr_sendx (beacon, "SILENCE", NULL);
67 //
68 // Start listening to beacons from peers\&. The filter is used to do a prefix
69 // match on received beacons, to remove junk\&. Note that any received data
70 // that is identical to our broadcast beacon_data is discarded in any case\&.
71 // If the filter size is zero, we get all peer beacons:
72 //
73 // zsock_send (beacon, "sb", "SUBSCRIBE", filter_data, filter_size);
74 //
75 // Stop listening to other peers
76 //
77 // zstr_sendx (beacon, "UNSUBSCRIBE", NULL);
78 //
79 // Receive next beacon from a peer\&. Received beacons are always a 2\-frame
80 // message containing the ipaddress of the sender, and then the binary
81 // beacon data as published by the sender:
82 //
83 // zmsg_t *msg = zmsg_recv (beacon);
84 //
85 // This is the zbeacon constructor as a zactor_fn:
86 CZMQ_EXPORT void
87 zbeacon (zsock_t *pipe, void *unused);
88
89 // Self test of this class
90 CZMQ_EXPORT void
91 zbeacon_test (bool verbose);
92 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zbeacon\&.c\*(Aq\&.
93 .fi
94 .SH "DESCRIPTION"
95 .sp
96 The zbeacon class implements a peer\-to\-peer discovery service for local networks\&. A beacon can broadcast and/or capture service announcements using UDP messages on the local area network\&. This implementation uses IPv4 UDP broadcasts\&. You can define the format of your outgoing beacons, and set a filter that validates incoming beacons\&. Beacons are sent and received asynchronously in the background\&.
97 .sp
98 This class replaces zbeacon_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock)\&.
99 .SH "EXAMPLE"
100 .PP
101 \fBFrom zbeacon_test method\fR.
102 .sp
103 .if n \{\
104 .RS 4
105 .\}
106 .nf
107 // Test 1 \- two beacons, one speaking, one listening
108 // Create speaker beacon to broadcast our service
109 zactor_t *speaker = zactor_new (zbeacon, NULL);
110 assert (speaker);
111 if (verbose)
112 zstr_sendx (speaker, "VERBOSE", NULL);
113
114 zsock_send (speaker, "si", "CONFIGURE", 9999);
115 char *hostname = zstr_recv (speaker);
116 if (!*hostname) {
117 printf ("OK (skipping test, no UDP broadcasting)\en");
118 zactor_destroy (&speaker);
119 free (hostname);
120 return;
121 }
122 free (hostname);
123
124 // Create listener beacon on port 9999 to lookup service
125 zactor_t *listener = zactor_new (zbeacon, NULL);
126 assert (listener);
127 if (verbose)
128 zstr_sendx (listener, "VERBOSE", NULL);
129 zsock_send (listener, "si", "CONFIGURE", 9999);
130 hostname = zstr_recv (listener);
131 assert (*hostname);
132 free (hostname);
133
134 // We will broadcast the magic value 0xCAFE
135 byte announcement [2] = { 0xCA, 0xFE };
136 zsock_send (speaker, "sbi", "PUBLISH", announcement, 2, 100);
137 // We will listen to anything (empty subscription)
138 zsock_send (listener, "sb", "SUBSCRIBE", "", 0);
139
140 // Wait for at most 1/2 second if there\*(Aqs no broadcasting
141 zsock_set_rcvtimeo (listener, 500);
142 char *ipaddress = zstr_recv (listener);
143 if (ipaddress) {
144 zframe_t *content = zframe_recv (listener);
145 assert (zframe_size (content) == 2);
146 assert (zframe_data (content) [0] == 0xCA);
147 assert (zframe_data (content) [1] == 0xFE);
148 zframe_destroy (&content);
149 zstr_free (&ipaddress);
150 zstr_sendx (speaker, "SILENCE", NULL);
151 }
152 zactor_destroy (&listener);
153 zactor_destroy (&speaker);
154
155 // Test subscription filter using a 3\-node setup
156 zactor_t *node1 = zactor_new (zbeacon, NULL);
157 assert (node1);
158 zsock_send (node1, "si", "CONFIGURE", 5670);
159 hostname = zstr_recv (node1);
160 assert (*hostname);
161 free (hostname);
162
163 zactor_t *node2 = zactor_new (zbeacon, NULL);
164 assert (node2);
165 zsock_send (node2, "si", "CONFIGURE", 5670);
166 hostname = zstr_recv (node2);
167 assert (*hostname);
168 free (hostname);
169
170 zactor_t *node3 = zactor_new (zbeacon, NULL);
171 assert (node3);
172 zsock_send (node3, "si", "CONFIGURE", 5670);
173 hostname = zstr_recv (node3);
174 assert (*hostname);
175 free (hostname);
176
177 zsock_send (node1, "sbi", "PUBLISH", "NODE/1", 6, 250);
178 zsock_send (node2, "sbi", "PUBLISH", "NODE/2", 6, 250);
179 zsock_send (node3, "sbi", "PUBLISH", "RANDOM", 6, 250);
180 zsock_send (node1, "sb", "SUBSCRIBE", "NODE", 4);
181
182 // Poll on three API sockets at once
183 zpoller_t *poller = zpoller_new (node1, node2, node3, NULL);
184 assert (poller);
185 int64_t stop_at = zclock_mono () + 1000;
186 while (zclock_mono () < stop_at) {
187 long timeout = (long) (stop_at \- zclock_mono ());
188 if (timeout < 0)
189 timeout = 0;
190 void *which = zpoller_wait (poller, timeout * ZMQ_POLL_MSEC);
191 if (which) {
192 assert (which == node1);
193 char *ipaddress, *received;
194 zstr_recvx (node1, &ipaddress, &received, NULL);
195 assert (streq (received, "NODE/2"));
196 zstr_free (&ipaddress);
197 zstr_free (&received);
198 }
199 }
200 zpoller_destroy (&poller);
201
202 // Stop listening
203 zstr_sendx (node1, "UNSUBSCRIBE", NULL);
204
205 // Stop all node broadcasts
206 zstr_sendx (node1, "SILENCE", NULL);
207 zstr_sendx (node2, "SILENCE", NULL);
208 zstr_sendx (node3, "SILENCE", NULL);
209
210 // Destroy the test nodes
211 zactor_destroy (&node1);
212 zactor_destroy (&node2);
213 zactor_destroy (&node3);
214 .fi
215 .if n \{\
216 .RE
217 .\}
218 .sp
219 .SH "AUTHORS"
220 .sp
221 The czmq manual was written by the authors in the AUTHORS file\&.
222 .SH "RESOURCES"
223 .sp
224 Main web site: \m[blue]\fB\%\fR\m[]
225 .sp
226 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
227 .SH "COPYRIGHT"
228 .sp
229 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
230 .SH "NOTES"
231 .IP " 1." 4
232 zeromq-dev@lists.zeromq.org
233 .RS 4
234 \%mailto:zeromq-dev@lists.zeromq.org
235 .RE
6565 // Self test of this class
6666 CZMQ_EXPORT void
6767 zbeacon_test (bool verbose);
68 Please add '@interface' section in './../src/zbeacon.c'.
6869 ----
6970
7071 DESCRIPTION
0 '\" t
1 .\" Title: zcert
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZCERT" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zcert \- work with CURVE security certificates
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // This class has draft methods, which may change over time\&. They are not
37 // in stable releases, by default\&. Use \-\-enable\-drafts to enable\&.
38 // Create and initialize a new certificate in memory
39 CZMQ_EXPORT zcert_t *
40 zcert_new (void);
41
42 // Accepts public/secret key pair from caller
43 CZMQ_EXPORT zcert_t *
44 zcert_new_from (const byte *public_key, const byte *secret_key);
45
46 // Load certificate from file
47 CZMQ_EXPORT zcert_t *
48 zcert_load (const char *filename);
49
50 // Destroy a certificate in memory
51 CZMQ_EXPORT void
52 zcert_destroy (zcert_t **self_p);
53
54 // Return public part of key pair as 32\-byte binary string
55 CZMQ_EXPORT const byte *
56 zcert_public_key (zcert_t *self);
57
58 // Return secret part of key pair as 32\-byte binary string
59 CZMQ_EXPORT const byte *
60 zcert_secret_key (zcert_t *self);
61
62 // Return public part of key pair as Z85 armored string
63 CZMQ_EXPORT const char *
64 zcert_public_txt (zcert_t *self);
65
66 // Return secret part of key pair as Z85 armored string
67 CZMQ_EXPORT const char *
68 zcert_secret_txt (zcert_t *self);
69
70 // Set certificate metadata from formatted string\&.
71 CZMQ_EXPORT void
72 zcert_set_meta (zcert_t *self, const char *name, const char *format, \&.\&.\&.) CHECK_PRINTF (3);
73
74 // Get metadata value from certificate; if the metadata value doesn\*(Aqt
75 // exist, returns NULL\&.
76 CZMQ_EXPORT const char *
77 zcert_meta (zcert_t *self, const char *name);
78
79 // Get list of metadata fields from certificate\&. Caller is responsible for
80 // destroying list\&. Caller should not modify the values of list items\&.
81 CZMQ_EXPORT zlist_t *
82 zcert_meta_keys (zcert_t *self);
83
84 // Save full certificate (public + secret) to file for persistent storage
85 // This creates one public file and one secret file (filename + "_secret")\&.
86 CZMQ_EXPORT int
87 zcert_save (zcert_t *self, const char *filename);
88
89 // Save public certificate only to file for persistent storage
90 CZMQ_EXPORT int
91 zcert_save_public (zcert_t *self, const char *filename);
92
93 // Save secret certificate only to file for persistent storage
94 CZMQ_EXPORT int
95 zcert_save_secret (zcert_t *self, const char *filename);
96
97 // Apply certificate to socket, i\&.e\&. use for CURVE security on socket\&.
98 // If certificate was loaded from public file, the secret key will be
99 // undefined, and this certificate will not work successfully\&.
100 CZMQ_EXPORT void
101 zcert_apply (zcert_t *self, void *socket);
102
103 // Return copy of certificate; if certificate is NULL or we exhausted
104 // heap memory, returns NULL\&.
105 // Caller owns return value and must destroy it when done\&.
106 CZMQ_EXPORT zcert_t *
107 zcert_dup (zcert_t *self);
108
109 // Return true if two certificates have the same keys
110 CZMQ_EXPORT bool
111 zcert_eq (zcert_t *self, zcert_t *compare);
112
113 // Print certificate contents to stdout
114 CZMQ_EXPORT void
115 zcert_print (zcert_t *self);
116
117 // Self test of this class
118 CZMQ_EXPORT void
119 zcert_test (bool verbose);
120
121 #ifdef CZMQ_BUILD_DRAFT_API
122 // *** Draft method, for development use, may change without warning ***
123 // Unset certificate metadata\&.
124 CZMQ_EXPORT void
125 zcert_unset_meta (zcert_t *self, const char *name);
126
127 #endif // CZMQ_BUILD_DRAFT_API
128 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zcert\&.c\*(Aq\&.
129 .fi
130 .SH "DESCRIPTION"
131 .sp
132 The zcert class provides a way to create and work with security certificates for the ZMQ CURVE mechanism\&. A certificate contains a public + secret key pair, plus metadata\&. It can be used as a temporary object in memory, or persisted to disk\&. On disk, a certificate is stored as two files\&. One is public and contains only the public key\&. The second is secret and contains both keys\&. The two have the same filename, with the secret file adding "_secret"\&. To exchange certificates, send the public file via some secure route\&. Certificates are not signed but are text files that can be verified by eye\&.
133 .sp
134 Certificates are stored in the ZPL (ZMQ RFC 4) format\&. They have two sections, "metadata" and "curve"\&. The first contains a list of \fIname = value\fR pairs, one per line\&. Values may be enclosed in quotes\&. The curve section has a \fIpublic\-key = keyvalue\fR and, for secret certificates, a \fIsecret\-key = keyvalue\fR line\&. The keyvalue is a Z85\-encoded CURVE key\&.
135 .SH "EXAMPLE"
136 .PP
137 \fBFrom zcert_test method\fR.
138 .sp
139 .if n \{\
140 .RS 4
141 .\}
142 .nf
143 // Create temporary directory for test files
144 # define TESTDIR "\&.test_zcert"
145 zsys_dir_create (TESTDIR);
146
147 // Create a simple certificate with metadata
148 zcert_t *cert = zcert_new ();
149 assert (cert);
150 zcert_set_meta (cert, "email", "ph@imatix\&.com");
151 zcert_set_meta (cert, "name", "Pieter Hintjens");
152 zcert_set_meta (cert, "organization", "iMatix Corporation");
153 zcert_set_meta (cert, "version", "%d", 1);
154 zcert_set_meta (cert, "delete_me", "now");
155 zcert_unset_meta (cert, "delete_me");
156 assert (streq (zcert_meta (cert, "email"), "ph@imatix\&.com"));
157 zlist_t *keys = zcert_meta_keys (cert);
158 assert (zlist_size (keys) == 4);
159 zlist_destroy (&keys);
160
161 // Check the dup and eq methods
162 zcert_t *shadow = zcert_dup (cert);
163 assert (zcert_eq (cert, shadow));
164 zcert_destroy (&shadow);
165
166 // Check we can save and load certificate
167 zcert_save (cert, TESTDIR "/mycert\&.txt");
168 assert (zsys_file_exists (TESTDIR "/mycert\&.txt"));
169 assert (zsys_file_exists (TESTDIR "/mycert\&.txt_secret"));
170
171 // Load certificate, will in fact load secret one
172 shadow = zcert_load (TESTDIR "/mycert\&.txt");
173 assert (shadow);
174 assert (zcert_eq (cert, shadow));
175 zcert_destroy (&shadow);
176
177 // Delete secret certificate, load public one
178 int rc = zsys_file_delete (TESTDIR "/mycert\&.txt_secret");
179 assert (rc == 0);
180 shadow = zcert_load (TESTDIR "/mycert\&.txt");
181
182 // 32\-byte null key encodes as 40 \*(Aq0\*(Aq characters
183 assert (streq (zcert_secret_txt (shadow), FORTY_ZEROES));
184
185 zcert_destroy (&shadow);
186 zcert_destroy (&cert);
187
188 // Delete all test files
189 zdir_t *dir = zdir_new (TESTDIR, NULL);
190 assert (dir);
191 zdir_remove (dir, true);
192 zdir_destroy (&dir);
193 .fi
194 .if n \{\
195 .RE
196 .\}
197 .sp
198 .SH "AUTHORS"
199 .sp
200 The czmq manual was written by the authors in the AUTHORS file\&.
201 .SH "RESOURCES"
202 .sp
203 Main web site: \m[blue]\fB\%\fR\m[]
204 .sp
205 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
206 .SH "COPYRIGHT"
207 .sp
208 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
209 .SH "NOTES"
210 .IP " 1." 4
211 zeromq-dev@lists.zeromq.org
212 .RS 4
213 \%mailto:zeromq-dev@lists.zeromq.org
214 .RE
101101 zcert_unset_meta (zcert_t *self, const char *name);
102102
103103 #endif // CZMQ_BUILD_DRAFT_API
104 Please add '@interface' section in './../src/zcert.c'.
104105 ----
105106
106107 DESCRIPTION
0 '\" t
1 .\" Title: zcertstore
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZCERTSTORE" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zcertstore \- work with CURVE security certificate stores
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // This class has draft methods, which may change over time\&. They are not
37 // in stable releases, by default\&. Use \-\-enable\-drafts to enable\&.
38 // Create a new certificate store from a disk directory, loading and
39 // indexing all certificates in that location\&. The directory itself may be
40 // absent, and created later, or modified at any time\&. The certificate store
41 // is automatically refreshed on any zcertstore_lookup() call\&. If the
42 // location is specified as NULL, creates a pure\-memory store, which you
43 // can work with by inserting certificates at runtime\&.
44 CZMQ_EXPORT zcertstore_t *
45 zcertstore_new (const char *location);
46
47 // Destroy a certificate store object in memory\&. Does not affect anything
48 // stored on disk\&.
49 CZMQ_EXPORT void
50 zcertstore_destroy (zcertstore_t **self_p);
51
52 // Look up certificate by public key, returns zcert_t object if found,
53 // else returns NULL\&. The public key is provided in Z85 text format\&.
54 CZMQ_EXPORT zcert_t *
55 zcertstore_lookup (zcertstore_t *self, const char *public_key);
56
57 // Insert certificate into certificate store in memory\&. Note that this
58 // does not save the certificate to disk\&. To do that, use zcert_save()
59 // directly on the certificate\&. Takes ownership of zcert_t object\&.
60 CZMQ_EXPORT void
61 zcertstore_insert (zcertstore_t *self, zcert_t **cert_p);
62
63 // Print list of certificates in store to logging facility
64 CZMQ_EXPORT void
65 zcertstore_print (zcertstore_t *self);
66
67 // Self test of this class
68 CZMQ_EXPORT void
69 zcertstore_test (bool verbose);
70
71 #ifdef CZMQ_BUILD_DRAFT_API
72 // Loaders retrieve certificates from an arbitrary source\&.
73 typedef void (zcertstore_loader) (
74 zcertstore_t *self);
75
76 // Destructor for loader state\&.
77 typedef void (zcertstore_destructor) (
78 void **self_p);
79
80 // *** Draft method, for development use, may change without warning ***
81 // Override the default disk loader with a custom loader fn\&.
82 CZMQ_EXPORT void
83 zcertstore_set_loader (zcertstore_t *self, zcertstore_loader loader, zcertstore_destructor destructor, void *state);
84
85 // *** Draft method, for development use, may change without warning ***
86 // Empty certificate hashtable\&. This wrapper exists to be friendly to bindings,
87 // which don\*(Aqt usually have access to struct internals\&.
88 CZMQ_EXPORT void
89 zcertstore_empty (zcertstore_t *self);
90
91 #endif // CZMQ_BUILD_DRAFT_API
92 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zcertstore\&.c\*(Aq\&.
93 .fi
94 .SH "DESCRIPTION"
95 .sp
96 To authenticate new clients using the ZeroMQ CURVE security mechanism, we have to check that the client\(cqs public key matches a key we know and accept\&. There are numerous ways to store accepted client public keys\&. The mechanism CZMQ implements is "certificates" (plain text files) held in a "certificate store" (a disk directory)\&. This class works with such certificate stores, and lets you easily load them from disk, and check if a given client public key is known or not\&. The zcert class does the work of managing a single certificate\&.
97 .sp
98 The certificate store can be memory\-only, in which case you can load it yourself by inserting certificate objects one by one, or it can be loaded from disk, in which case you can add, modify, or remove certificates on disk at any time, and the store will detect such changes and refresh itself automatically\&. In most applications you won\(cqt use this class directly but through the zauth class, which provides a high\-level API for authentication (and manages certificate stores for you)\&. To actually create certificates on disk, use the zcert class in code, or the tools/zmakecert\&.c command line tool, or any text editor\&. The format of a certificate file is defined in the zcert man page\&.
99 .SH "EXAMPLE"
100 .PP
101 \fBFrom zcertstore_test method\fR.
102 .sp
103 .if n \{\
104 .RS 4
105 .\}
106 .nf
107 // Create temporary directory for test files
108 # define TESTDIR "\&.test_zcertstore"
109 zsys_dir_create (TESTDIR);
110
111 // Load certificate store from disk; it will be empty
112 zcertstore_t *certstore = zcertstore_new (TESTDIR);
113 assert (certstore);
114
115 // Create a single new certificate and save to disk
116 zcert_t *cert = zcert_new ();
117 assert (cert);
118 char *client_key = strdup (zcert_public_txt (cert));
119 assert (client_key);
120 zcert_set_meta (cert, "name", "John Doe");
121 zcert_save (cert, TESTDIR "/mycert\&.txt");
122 zcert_destroy (&cert);
123
124 // Check that certificate store refreshes as expected
125 cert = zcertstore_lookup (certstore, client_key);
126 assert (cert);
127 assert (streq (zcert_meta (cert, "name"), "John Doe"));
128
129 // Test custom loader
130 test_loader_state *state = (test_loader_state *) zmalloc (sizeof (test_loader_state));
131 state\->index = 0;
132 zcertstore_set_loader (certstore, s_test_loader, s_test_destructor, (void *)state);
133 #if (ZMQ_VERSION_MAJOR >= 4)
134 cert = zcertstore_lookup (certstore, client_key);
135 assert (cert == NULL);
136 cert = zcertstore_lookup (certstore, "abcdefghijklmnopqrstuvwxyzabcdefghijklmn");
137 assert (cert);
138 #endif
139
140 free (client_key);
141
142 if (verbose)
143 zcertstore_print (certstore);
144 zcertstore_destroy (&certstore);
145
146 // Delete all test files
147 zdir_t *dir = zdir_new (TESTDIR, NULL);
148 assert (dir);
149 zdir_remove (dir, true);
150 zdir_destroy (&dir);
151 .fi
152 .if n \{\
153 .RE
154 .\}
155 .sp
156 .SH "AUTHORS"
157 .sp
158 The czmq manual was written by the authors in the AUTHORS file\&.
159 .SH "RESOURCES"
160 .sp
161 Main web site: \m[blue]\fB\%\fR\m[]
162 .sp
163 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
164 .SH "COPYRIGHT"
165 .sp
166 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
167 .SH "NOTES"
168 .IP " 1." 4
169 zeromq-dev@lists.zeromq.org
170 .RS 4
171 \%mailto:zeromq-dev@lists.zeromq.org
172 .RE
6565 zcertstore_empty (zcertstore_t *self);
6666
6767 #endif // CZMQ_BUILD_DRAFT_API
68 Please add '@interface' section in './../src/zcertstore.c'.
6869 ----
6970
7071 DESCRIPTION
0 '\" t
1 .\" Title: zchunk
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZCHUNK" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zchunk \- work with memory chunks
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // Create a new chunk of the specified size\&. If you specify the data, it
37 // is copied into the chunk\&. If you do not specify the data, the chunk is
38 // allocated and left empty, and you can then add data using zchunk_append\&.
39 CZMQ_EXPORT zchunk_t *
40 zchunk_new (const void *data, size_t size);
41
42 // Destroy a chunk
43 CZMQ_EXPORT void
44 zchunk_destroy (zchunk_t **self_p);
45
46 // Resizes chunk max_size as requested; chunk_cur size is set to zero
47 CZMQ_EXPORT void
48 zchunk_resize (zchunk_t *self, size_t size);
49
50 // Return chunk cur size
51 CZMQ_EXPORT size_t
52 zchunk_size (zchunk_t *self);
53
54 // Return chunk max size
55 CZMQ_EXPORT size_t
56 zchunk_max_size (zchunk_t *self);
57
58 // Return chunk data
59 CZMQ_EXPORT byte *
60 zchunk_data (zchunk_t *self);
61
62 // Set chunk data from user\-supplied data; truncate if too large\&. Data may
63 // be null\&. Returns actual size of chunk
64 CZMQ_EXPORT size_t
65 zchunk_set (zchunk_t *self, const void *data, size_t size);
66
67 // Fill chunk data from user\-supplied octet
68 CZMQ_EXPORT size_t
69 zchunk_fill (zchunk_t *self, byte filler, size_t size);
70
71 // Append user\-supplied data to chunk, return resulting chunk size\&. If the
72 // data would exceeded the available space, it is truncated\&. If you want to
73 // grow the chunk to accommodate new data, use the zchunk_extend method\&.
74 CZMQ_EXPORT size_t
75 zchunk_append (zchunk_t *self, const void *data, size_t size);
76
77 // Append user\-supplied data to chunk, return resulting chunk size\&. If the
78 // data would exceeded the available space, the chunk grows in size\&.
79 CZMQ_EXPORT size_t
80 zchunk_extend (zchunk_t *self, const void *data, size_t size);
81
82 // Copy as much data from \*(Aqsource\*(Aq into the chunk as possible; returns the
83 // new size of chunk\&. If all data from \*(Aqsource\*(Aq is used, returns exhausted
84 // on the source chunk\&. Source can be consumed as many times as needed until
85 // it is exhausted\&. If source was already exhausted, does not change chunk\&.
86 CZMQ_EXPORT size_t
87 zchunk_consume (zchunk_t *self, zchunk_t *source);
88
89 // Returns true if the chunk was exhausted by consume methods, or if the
90 // chunk has a size of zero\&.
91 CZMQ_EXPORT bool
92 zchunk_exhausted (zchunk_t *self);
93
94 // Read chunk from an open file descriptor
95 // Caller owns return value and must destroy it when done\&.
96 CZMQ_EXPORT zchunk_t *
97 zchunk_read (FILE *handle, size_t bytes);
98
99 // Write chunk to an open file descriptor
100 CZMQ_EXPORT int
101 zchunk_write (zchunk_t *self, FILE *handle);
102
103 // Try to slurp an entire file into a chunk\&. Will read up to maxsize of
104 // the file\&. If maxsize is 0, will attempt to read the entire file and
105 // fail with an assertion if that cannot fit into memory\&. Returns a new
106 // chunk containing the file data, or NULL if the file could not be read\&.
107 // Caller owns return value and must destroy it when done\&.
108 CZMQ_EXPORT zchunk_t *
109 zchunk_slurp (const char *filename, size_t maxsize);
110
111 // Create copy of chunk, as new chunk object\&. Returns a fresh zchunk_t
112 // object, or null if there was not enough heap memory\&. If chunk is null,
113 // returns null\&.
114 // Caller owns return value and must destroy it when done\&.
115 CZMQ_EXPORT zchunk_t *
116 zchunk_dup (zchunk_t *self);
117
118 // Return chunk data encoded as printable hex string\&. Caller must free
119 // string when finished with it\&.
120 // Caller owns return value and must destroy it when done\&.
121 CZMQ_EXPORT char *
122 zchunk_strhex (zchunk_t *self);
123
124 // Return chunk data copied into freshly allocated string
125 // Caller must free string when finished with it\&.
126 // Caller owns return value and must destroy it when done\&.
127 CZMQ_EXPORT char *
128 zchunk_strdup (zchunk_t *self);
129
130 // Return TRUE if chunk body is equal to string, excluding terminator
131 CZMQ_EXPORT bool
132 zchunk_streq (zchunk_t *self, const char *string);
133
134 // Transform zchunk into a zframe that can be sent in a message\&.
135 // Caller owns return value and must destroy it when done\&.
136 CZMQ_EXPORT zframe_t *
137 zchunk_pack (zchunk_t *self);
138
139 // Transform a zframe into a zchunk\&.
140 // Caller owns return value and must destroy it when done\&.
141 CZMQ_EXPORT zchunk_t *
142 zchunk_unpack (zframe_t *frame);
143
144 // Calculate SHA1 digest for chunk, using zdigest class\&.
145 CZMQ_EXPORT const char *
146 zchunk_digest (zchunk_t *self);
147
148 // Dump chunk to FILE stream, for debugging and tracing\&.
149 CZMQ_EXPORT void
150 zchunk_fprint (zchunk_t *self, FILE *file);
151
152 // Dump message to stderr, for debugging and tracing\&.
153 // See zchunk_fprint for details
154 CZMQ_EXPORT void
155 zchunk_print (zchunk_t *self);
156
157 // Probe the supplied object, and report if it looks like a zchunk_t\&.
158 CZMQ_EXPORT bool
159 zchunk_is (void *self);
160
161 // Self test of this class\&.
162 CZMQ_EXPORT void
163 zchunk_test (bool verbose);
164
165 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zchunk\&.c\*(Aq\&.
166 .fi
167 .SH "DESCRIPTION"
168 .sp
169 The zchunk class works with variable sized blobs\&. Not as efficient as ZeroMQ\(cqs messages but they do less weirdness and so are easier to understand\&. The chunk class has methods to read and write chunks from disk\&.
170 .sp
171 Please add \fI@discuss\fR section in \fI\&./\&.\&./src/zchunk\&.c\fR\&.
172 .SH "EXAMPLE"
173 .PP
174 \fBFrom zchunk_test method\fR.
175 .sp
176 .if n \{\
177 .RS 4
178 .\}
179 .nf
180 zchunk_t *chunk = zchunk_new ("1234567890", 10);
181 assert (chunk);
182 assert (zchunk_size (chunk) == 10);
183 assert (memcmp (zchunk_data (chunk), "1234567890", 10) == 0);
184 zchunk_destroy (&chunk);
185
186 chunk = zchunk_new (NULL, 10);
187 assert (chunk);
188 zchunk_append (chunk, "12345678", 8);
189 zchunk_append (chunk, "90ABCDEF", 8);
190 zchunk_append (chunk, "GHIJKLMN", 8);
191 assert (memcmp (zchunk_data (chunk), "1234567890", 10) == 0);
192 assert (zchunk_size (chunk) == 10);
193 assert (zchunk_streq (chunk, "1234567890"));
194 assert (streq (zchunk_digest (chunk), "01B307ACBA4F54F55AAFC33BB06BBBF6CA803E9A"));
195 char *string = zchunk_strdup (chunk);
196 assert (streq (string, "1234567890"));
197 free (string);
198 string = zchunk_strhex (chunk);
199 assert (streq (string, "31323334353637383930"));
200 free (string);
201
202 zframe_t *frame = zchunk_pack (chunk);
203 assert (frame);
204
205 zchunk_t *chunk2 = zchunk_unpack (frame);
206 assert (chunk2);
207 assert (memcmp (zchunk_data (chunk2), "1234567890", 10) == 0);
208 zframe_destroy (&frame);
209 zchunk_destroy (&chunk2);
210
211 zchunk_t *copy = zchunk_dup (chunk);
212 assert (copy);
213 assert (memcmp (zchunk_data (copy), "1234567890", 10) == 0);
214 assert (zchunk_size (copy) == 10);
215 zchunk_destroy (&copy);
216 zchunk_destroy (&chunk);
217
218 chunk = zchunk_new (NULL, 0);
219 zchunk_extend (chunk, "12345678", 8);
220 zchunk_extend (chunk, "90ABCDEF", 8);
221 zchunk_extend (chunk, "GHIJKLMN", 8);
222 assert (zchunk_size (chunk) == 24);
223 assert (zchunk_streq (chunk, "1234567890ABCDEFGHIJKLMN"));
224 zchunk_destroy (&chunk);
225
226 copy = zchunk_new ("1234567890abcdefghij", 20);
227 assert (copy);
228 chunk = zchunk_new (NULL, 8);
229 assert (chunk);
230 zchunk_consume (chunk, copy);
231 assert (!zchunk_exhausted (copy));
232 assert (memcmp (zchunk_data (chunk), "12345678", 8) == 0);
233 zchunk_set (chunk, NULL, 0);
234 zchunk_consume (chunk, copy);
235 assert (!zchunk_exhausted (copy));
236 assert (memcmp (zchunk_data (chunk), "90abcdef", 8) == 0);
237 zchunk_set (chunk, NULL, 0);
238 zchunk_consume (chunk, copy);
239 assert (zchunk_exhausted (copy));
240 assert (zchunk_size (chunk) == 4);
241 assert (memcmp (zchunk_data (chunk), "ghij", 4) == 0);
242 zchunk_destroy (&copy);
243 zchunk_destroy (&chunk);
244 .fi
245 .if n \{\
246 .RE
247 .\}
248 .sp
249 .SH "AUTHORS"
250 .sp
251 The czmq manual was written by the authors in the AUTHORS file\&.
252 .SH "RESOURCES"
253 .sp
254 Main web site: \m[blue]\fB\%\fR\m[]
255 .sp
256 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
257 .SH "COPYRIGHT"
258 .sp
259 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
260 .SH "NOTES"
261 .IP " 1." 4
262 zeromq-dev@lists.zeromq.org
263 .RS 4
264 \%mailto:zeromq-dev@lists.zeromq.org
265 .RE
138138 CZMQ_EXPORT void
139139 zchunk_test (bool verbose);
140140
141 Please add '@interface' section in './../src/zchunk.c'.
141142 ----
142143
143144 DESCRIPTION
147148 ZeroMQ's messages but they do less weirdness and so are easier to understand.
148149 The chunk class has methods to read and write chunks from disk.
149150
150 Please add @discuss section in ../src/zchunk.c.
151 Please add '@discuss' section in './../src/zchunk.c'.
151152
152153 EXAMPLE
153154 -------
0 '\" t
1 .\" Title: zclock
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZCLOCK" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zclock \- millisecond clocks and delays
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // Sleep for a number of milliseconds
37 CZMQ_EXPORT void
38 zclock_sleep (int msecs);
39
40 // Return current system clock as milliseconds\&. Note that this clock can
41 // jump backwards (if the system clock is changed) so is unsafe to use for
42 // timers and time offsets\&. Use zclock_mono for that instead\&.
43 CZMQ_EXPORT int64_t
44 zclock_time (void);
45
46 // Return current monotonic clock in milliseconds\&. Use this when you compute
47 // time offsets\&. The monotonic clock is not affected by system changes and
48 // so will never be reset backwards, unlike a system clock\&.
49 CZMQ_EXPORT int64_t
50 zclock_mono (void);
51
52 // Return current monotonic clock in microseconds\&. Use this when you compute
53 // time offsets\&. The monotonic clock is not affected by system changes and
54 // so will never be reset backwards, unlike a system clock\&.
55 CZMQ_EXPORT int64_t
56 zclock_usecs (void);
57
58 // Return formatted date/time as fresh string\&. Free using zstr_free()\&.
59 // Caller owns return value and must destroy it when done\&.
60 CZMQ_EXPORT char *
61 zclock_timestr (void);
62
63 // Self test of this class\&.
64 CZMQ_EXPORT void
65 zclock_test (bool verbose);
66
67 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zclock\&.c\*(Aq\&.
68 .fi
69 .SH "DESCRIPTION"
70 .sp
71 The zclock class provides essential sleep and system time functions, used to slow down threads for testing, and calculate timers for polling\&. Wraps the non\-portable system calls in a simple portable API\&.
72 .sp
73 The Win32 Sleep() call defaults to 16ms resolution unless the system timer resolution is increased with a call to timeBeginPeriod() permitting 1ms granularity\&.
74 .SH "EXAMPLE"
75 .PP
76 \fBFrom zclock_test method\fR.
77 .sp
78 .if n \{\
79 .RS 4
80 .\}
81 .nf
82 int64_t start = zclock_time ();
83 zclock_sleep (10);
84 assert ((zclock_time () \- start) >= 10);
85 start = zclock_mono ();
86 int64_t usecs = zclock_usecs ();
87 zclock_sleep (10);
88 assert ((zclock_mono () \- start) >= 10);
89 assert ((zclock_usecs () \- usecs) >= 10000);
90 char *timestr = zclock_timestr ();
91 if (verbose)
92 puts (timestr);
93 free (timestr);
94 .fi
95 .if n \{\
96 .RE
97 .\}
98 .sp
99 .SH "AUTHORS"
100 .sp
101 The czmq manual was written by the authors in the AUTHORS file\&.
102 .SH "RESOURCES"
103 .sp
104 Main web site: \m[blue]\fB\%\fR\m[]
105 .sp
106 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
107 .SH "COPYRIGHT"
108 .sp
109 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
110 .SH "NOTES"
111 .IP " 1." 4
112 zeromq-dev@lists.zeromq.org
113 .RS 4
114 \%mailto:zeromq-dev@lists.zeromq.org
115 .RE
4040 CZMQ_EXPORT void
4141 zclock_test (bool verbose);
4242
43 Please add '@interface' section in './../src/zclock.c'.
4344 ----
4445
4546 DESCRIPTION
0 '\" t
1 .\" Title: zconfig
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZCONFIG" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zconfig \- work with config files written in rfc\&.zeromq\&.org/spec:4/ZPL\&.
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 //
37 typedef int (zconfig_fct) (
38 zconfig_t *self, void *arg, int level);
39
40 // Create new config item
41 CZMQ_EXPORT zconfig_t *
42 zconfig_new (const char *name, zconfig_t *parent);
43
44 // Load a config tree from a specified ZPL text file; returns a zconfig_t
45 // reference for the root, if the file exists and is readable\&. Returns NULL
46 // if the file does not exist\&.
47 CZMQ_EXPORT zconfig_t *
48 zconfig_load (const char *filename);
49
50 // Equivalent to zconfig_load, taking a format string instead of a fixed
51 // filename\&.
52 CZMQ_EXPORT zconfig_t *
53 zconfig_loadf (const char *format, \&.\&.\&.) CHECK_PRINTF (1);
54
55 // Destroy a config item and all its children
56 CZMQ_EXPORT void
57 zconfig_destroy (zconfig_t **self_p);
58
59 // Return name of config item
60 CZMQ_EXPORT char *
61 zconfig_name (zconfig_t *self);
62
63 // Return value of config item
64 CZMQ_EXPORT char *
65 zconfig_value (zconfig_t *self);
66
67 // Insert or update configuration key with value
68 CZMQ_EXPORT void
69 zconfig_put (zconfig_t *self, const char *path, const char *value);
70
71 // Equivalent to zconfig_put, accepting a format specifier and variable
72 // argument list, instead of a single string value\&.
73 CZMQ_EXPORT void
74 zconfig_putf (zconfig_t *self, const char *path, const char *format, \&.\&.\&.) CHECK_PRINTF (3);
75
76 // Get value for config item into a string value; leading slash is optional
77 // and ignored\&.
78 CZMQ_EXPORT char *
79 zconfig_get (zconfig_t *self, const char *path, const char *default_value);
80
81 // Set config item name, name may be NULL
82 CZMQ_EXPORT void
83 zconfig_set_name (zconfig_t *self, const char *name);
84
85 // Set new value for config item\&. The new value may be a string, a printf
86 // format, or NULL\&. Note that if string may possibly contain \*(Aq%\*(Aq, or if it
87 // comes from an insecure source, you must use \*(Aq%s\*(Aq as the format, followed
88 // by the string\&.
89 CZMQ_EXPORT void
90 zconfig_set_value (zconfig_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2);
91
92 // Find our first child, if any
93 CZMQ_EXPORT zconfig_t *
94 zconfig_child (zconfig_t *self);
95
96 // Find our first sibling, if any
97 CZMQ_EXPORT zconfig_t *
98 zconfig_next (zconfig_t *self);
99
100 // Find a config item along a path; leading slash is optional and ignored\&.
101 CZMQ_EXPORT zconfig_t *
102 zconfig_locate (zconfig_t *self, const char *path);
103
104 // Locate the last config item at a specified depth
105 CZMQ_EXPORT zconfig_t *
106 zconfig_at_depth (zconfig_t *self, int level);
107
108 // Execute a callback for each config item in the tree; returns zero if
109 // successful, else \-1\&.
110 CZMQ_EXPORT int
111 zconfig_execute (zconfig_t *self, zconfig_fct handler, void *arg);
112
113 // Add comment to config item before saving to disk\&. You can add as many
114 // comment lines as you like\&. If you use a null format, all comments are
115 // deleted\&.
116 CZMQ_EXPORT void
117 zconfig_set_comment (zconfig_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2);
118
119 // Return comments of config item, as zlist\&.
120 CZMQ_EXPORT zlist_t *
121 zconfig_comments (zconfig_t *self);
122
123 // Save a config tree to a specified ZPL text file, where a filename
124 // "\-" means dump to standard output\&.
125 CZMQ_EXPORT int
126 zconfig_save (zconfig_t *self, const char *filename);
127
128 // Equivalent to zconfig_save, taking a format string instead of a fixed
129 // filename\&.
130 CZMQ_EXPORT int
131 zconfig_savef (zconfig_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2);
132
133 // Report filename used during zconfig_load, or NULL if none
134 CZMQ_EXPORT const char *
135 zconfig_filename (zconfig_t *self);
136
137 // Reload config tree from same file that it was previously loaded from\&.
138 // Returns 0 if OK, \-1 if there was an error (and then does not change
139 // existing data)\&.
140 CZMQ_EXPORT int
141 zconfig_reload (zconfig_t **self_p);
142
143 // Load a config tree from a memory chunk
144 CZMQ_EXPORT zconfig_t *
145 zconfig_chunk_load (zchunk_t *chunk);
146
147 // Save a config tree to a new memory chunk
148 CZMQ_EXPORT zchunk_t *
149 zconfig_chunk_save (zconfig_t *self);
150
151 // Load a config tree from a null\-terminated string
152 // Caller owns return value and must destroy it when done\&.
153 CZMQ_EXPORT zconfig_t *
154 zconfig_str_load (const char *string);
155
156 // Save a config tree to a new null terminated string
157 // Caller owns return value and must destroy it when done\&.
158 CZMQ_EXPORT char *
159 zconfig_str_save (zconfig_t *self);
160
161 // Return true if a configuration tree was loaded from a file and that
162 // file has changed in since the tree was loaded\&.
163 CZMQ_EXPORT bool
164 zconfig_has_changed (zconfig_t *self);
165
166 // Print the config file to open stream
167 CZMQ_EXPORT void
168 zconfig_fprint (zconfig_t *self, FILE *file);
169
170 // Print properties of object
171 CZMQ_EXPORT void
172 zconfig_print (zconfig_t *self);
173
174 // Self test of this class
175 CZMQ_EXPORT void
176 zconfig_test (bool verbose);
177
178 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zconfig\&.c\*(Aq\&.
179 .fi
180 .SH "DESCRIPTION"
181 .sp
182 Lets applications load, work with, and save configuration files\&. This implements rfc\&.zeromq\&.org/spec:4/ZPL, which is a simple structured text format for configuration files\&.
183 .sp
184 Here is an example ZPL stream and corresponding config structure:
185 .sp
186 .if n \{\
187 .RS 4
188 .\}
189 .nf
190 context
191 iothreads = 1
192 verbose = 1 # Ask for a trace
193 main
194 type = zqueue # ZMQ_DEVICE type
195 frontend
196 option
197 hwm = 1000
198 swap = 25000000 # 25MB
199 bind = \*(Aqinproc://addr1\*(Aq
200 bind = \*(Aqipc://addr2\*(Aq
201 backend
202 bind = inproc://addr3
203 .fi
204 .if n \{\
205 .RE
206 .\}
207 .sp
208 .if n \{\
209 .RS 4
210 .\}
211 .nf
212 root Down = child
213 | Across = next
214 v
215 context\-\->main
216 | |
217 | v
218 | type=queue\-\->frontend\-\->backend
219 | | |
220 | | v
221 | | bind=inproc://addr3
222 | v
223 | option\-\->bind=inproc://addr1\-\->bind=ipc://addr2
224 | |
225 | v
226 | hwm=1000\-\->swap=25000000
227 v
228 iothreads=1\-\->verbose=false
229 .fi
230 .if n \{\
231 .RE
232 .\}
233 .SH "EXAMPLE"
234 .PP
235 \fBFrom zconfig_test method\fR.
236 .sp
237 .if n \{\
238 .RS 4
239 .\}
240 .nf
241 // Create temporary directory for test files
242 # define TESTDIR "\&.test_zconfig"
243 zsys_dir_create (TESTDIR);
244
245 zconfig_t *root = zconfig_new ("root", NULL);
246 assert (root);
247 zconfig_t *section, *item;
248
249 section = zconfig_new ("headers", root);
250 assert (section);
251 item = zconfig_new ("email", section);
252 assert (item);
253 zconfig_set_value (item, "some@random\&.com");
254 item = zconfig_new ("name", section);
255 assert (item);
256 zconfig_set_value (item, "Justin Kayce");
257 zconfig_putf (root, "/curve/secret\-key", "%s", "Top Secret");
258 zconfig_set_comment (root, " CURVE certificate");
259 zconfig_set_comment (root, " \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-");
260 assert (zconfig_comments (root));
261 zconfig_save (root, TESTDIR "/test\&.cfg");
262 zconfig_destroy (&root);
263 root = zconfig_load (TESTDIR "/test\&.cfg");
264 if (verbose)
265 zconfig_save (root, "\-");
266 assert (streq (zconfig_filename (root), TESTDIR "/test\&.cfg"));
267
268 char *email = zconfig_get (root, "/headers/email", NULL);
269 assert (email);
270 assert (streq (email, "some@random\&.com"));
271 char *passwd = zconfig_get (root, "/curve/secret\-key", NULL);
272 assert (passwd);
273 assert (streq (passwd, "Top Secret"));
274
275 zconfig_savef (root, "%s/%s", TESTDIR, "test\&.cfg");
276 assert (!zconfig_has_changed (root));
277 int rc = zconfig_reload (&root);
278 assert (rc == 0);
279 assert (!zconfig_has_changed (root));
280 zconfig_destroy (&root);
281
282 // Test chunk load/save
283 root = zconfig_new ("root", NULL);
284 assert (root);
285 section = zconfig_new ("section", root);
286 assert (section);
287 item = zconfig_new ("value", section);
288 assert (item);
289 zconfig_set_value (item, "somevalue");
290 zconfig_t *search = zconfig_locate (root, "section/value");
291 assert (search == item);
292 zchunk_t *chunk = zconfig_chunk_save (root);
293 assert (strlen ((char *) zchunk_data (chunk)) == 32);
294 char *string = zconfig_str_save (root);
295 assert (string);
296 assert (streq (string, (char *) zchunk_data (chunk)));
297 free (string);
298 assert (chunk);
299 zconfig_destroy (&root);
300
301 root = zconfig_chunk_load (chunk);
302 assert (root);
303 char *value = zconfig_get (root, "/section/value", NULL);
304 assert (value);
305 assert (streq (value, "somevalue"));
306
307 // Test config can\*(Aqt be saved to a file in a path that doesn\*(Aqt
308 // exist or isn\*(Aqt writable
309 rc = zconfig_savef (root, "%s/path/that/doesnt/exist/%s", TESTDIR, "test\&.cfg");
310 assert (rc == \-1);
311
312 zconfig_destroy (&root);
313 zchunk_destroy (&chunk);
314
315 // Delete all test files
316 zdir_t *dir = zdir_new (TESTDIR, NULL);
317 assert (dir);
318 zdir_remove (dir, true);
319 zdir_destroy (&dir);
320 .fi
321 .if n \{\
322 .RE
323 .\}
324 .sp
325 .SH "AUTHORS"
326 .sp
327 The czmq manual was written by the authors in the AUTHORS file\&.
328 .SH "RESOURCES"
329 .sp
330 Main web site: \m[blue]\fB\%\fR\m[]
331 .sp
332 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
333 .SH "COPYRIGHT"
334 .sp
335 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
336 .SH "NOTES"
337 .IP " 1." 4
338 zeromq-dev@lists.zeromq.org
339 .RS 4
340 \%mailto:zeromq-dev@lists.zeromq.org
341 .RE
151151 CZMQ_EXPORT void
152152 zconfig_test (bool verbose);
153153
154 Please add '@interface' section in './../src/zconfig.c'.
154155 ----
155156
156157 DESCRIPTION
0 '\" t
1 .\" Title: zdigest
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZDIGEST" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zdigest \- provides hashing functions (SHA\-1 at present)
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // Constructor \- creates new digest object, which you use to build up a
37 // digest by repeatedly calling zdigest_update() on chunks of data\&.
38 CZMQ_EXPORT zdigest_t *
39 zdigest_new (void);
40
41 // Destroy a digest object
42 CZMQ_EXPORT void
43 zdigest_destroy (zdigest_t **self_p);
44
45 // Add buffer into digest calculation
46 CZMQ_EXPORT void
47 zdigest_update (zdigest_t *self, const byte *buffer, size_t length);
48
49 // Return final digest hash data\&. If built without crypto support,
50 // returns NULL\&.
51 CZMQ_EXPORT const byte *
52 zdigest_data (zdigest_t *self);
53
54 // Return final digest hash size
55 CZMQ_EXPORT size_t
56 zdigest_size (zdigest_t *self);
57
58 // Return digest as printable hex string; caller should not modify nor
59 // free this string\&. After calling this, you may not use zdigest_update()
60 // on the same digest\&. If built without crypto support, returns NULL\&.
61 CZMQ_EXPORT char *
62 zdigest_string (zdigest_t *self);
63
64 // Self test of this class\&.
65 CZMQ_EXPORT void
66 zdigest_test (bool verbose);
67
68 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zdigest\&.c\*(Aq\&.
69 .fi
70 .SH "DESCRIPTION"
71 .sp
72 The zdigest class generates a hash from zchunks of data\&. The current algorithm is SHA\-1, chosen for speed\&. We are aiming to generate a unique digest for a file, and there are no security issues in this use case\&.
73 .sp
74 The current code depends on OpenSSL, which might be replaced by hard coded SHA\-1 implementation to reduce build dependencies\&.
75 .SH "EXAMPLE"
76 .PP
77 \fBFrom zdigest_test method\fR.
78 .sp
79 .if n \{\
80 .RS 4
81 .\}
82 .nf
83 byte *buffer = (byte *) zmalloc (1024);
84 memset (buffer, 0xAA, 1024);
85
86 zdigest_t *digest = zdigest_new ();
87 assert (digest);
88 zdigest_update (digest, buffer, 1024);
89 const byte *data = zdigest_data (digest);
90 assert (data [0] == 0xDE);
91 assert (data [1] == 0xB2);
92 assert (data [2] == 0x38);
93 assert (data [3] == 0x07);
94 assert (streq (zdigest_string (digest),
95 "DEB23807D4FE025E900FE9A9C7D8410C3DDE9671"));
96 zdigest_destroy (&digest);
97 free (buffer);
98 .fi
99 .if n \{\
100 .RE
101 .\}
102 .sp
103 .SH "AUTHORS"
104 .sp
105 The czmq manual was written by the authors in the AUTHORS file\&.
106 .SH "RESOURCES"
107 .sp
108 Main web site: \m[blue]\fB\%\fR\m[]
109 .sp
110 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
111 .SH "COPYRIGHT"
112 .sp
113 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
114 .SH "NOTES"
115 .IP " 1." 4
116 zeromq-dev@lists.zeromq.org
117 .RS 4
118 \%mailto:zeromq-dev@lists.zeromq.org
119 .RE
4141 CZMQ_EXPORT void
4242 zdigest_test (bool verbose);
4343
44 Please add '@interface' section in './../src/zdigest.c'.
4445 ----
4546
4647 DESCRIPTION
0 '\" t
1 .\" Title: zdir
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZDIR" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zdir \- work with file\-system directories
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // Create a new directory item that loads in the full tree of the specified
37 // path, optionally located under some parent path\&. If parent is "\-", then
38 // loads only the top\-level directory, and does not use parent as a path\&.
39 CZMQ_EXPORT zdir_t *
40 zdir_new (const char *path, const char *parent);
41
42 // Destroy a directory tree and all children it contains\&.
43 CZMQ_EXPORT void
44 zdir_destroy (zdir_t **self_p);
45
46 // Return directory path
47 CZMQ_EXPORT const char *
48 zdir_path (zdir_t *self);
49
50 // Return last modification time for directory\&.
51 CZMQ_EXPORT time_t
52 zdir_modified (zdir_t *self);
53
54 // Return total hierarchy size, in bytes of data contained in all files
55 // in the directory tree\&.
56 CZMQ_EXPORT off_t
57 zdir_cursize (zdir_t *self);
58
59 // Return directory count
60 CZMQ_EXPORT size_t
61 zdir_count (zdir_t *self);
62
63 // Returns a sorted list of zfile objects; Each entry in the list is a pointer
64 // to a zfile_t item already allocated in the zdir tree\&. Do not destroy the
65 // original zdir tree until you are done with this list\&.
66 // Caller owns return value and must destroy it when done\&.
67 CZMQ_EXPORT zlist_t *
68 zdir_list (zdir_t *self);
69
70 // Remove directory, optionally including all files that it contains, at
71 // all levels\&. If force is false, will only remove the directory if empty\&.
72 // If force is true, will remove all files and all subdirectories\&.
73 CZMQ_EXPORT void
74 zdir_remove (zdir_t *self, bool force);
75
76 // Calculate differences between two versions of a directory tree\&.
77 // Returns a list of zdir_patch_t patches\&. Either older or newer may
78 // be null, indicating the directory is empty/absent\&. If alias is set,
79 // generates virtual filename (minus path, plus alias)\&.
80 // Caller owns return value and must destroy it when done\&.
81 CZMQ_EXPORT zlist_t *
82 zdir_diff (zdir_t *older, zdir_t *newer, const char *alias);
83
84 // Return full contents of directory as a zdir_patch list\&.
85 // Caller owns return value and must destroy it when done\&.
86 CZMQ_EXPORT zlist_t *
87 zdir_resync (zdir_t *self, const char *alias);
88
89 // Load directory cache; returns a hash table containing the SHA\-1 digests
90 // of every file in the tree\&. The cache is saved between runs in \&.cache\&.
91 // Caller owns return value and must destroy it when done\&.
92 CZMQ_EXPORT zhash_t *
93 zdir_cache (zdir_t *self);
94
95 // Print contents of directory to open stream
96 CZMQ_EXPORT void
97 zdir_fprint (zdir_t *self, FILE *file, int indent);
98
99 // Print contents of directory to stdout
100 CZMQ_EXPORT void
101 zdir_print (zdir_t *self, int indent);
102
103 // Create a new zdir_watch actor instance:
104 //
105 // zactor_t *watch = zactor_new (zdir_watch, NULL);
106 //
107 // Destroy zdir_watch instance:
108 //
109 // zactor_destroy (&watch);
110 //
111 // Enable verbose logging of commands and activity:
112 //
113 // zstr_send (watch, "VERBOSE");
114 //
115 // Subscribe to changes to a directory path:
116 //
117 // zsock_send (watch, "ss", "SUBSCRIBE", "directory_path");
118 //
119 // Unsubscribe from changes to a directory path:
120 //
121 // zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path");
122 //
123 // Receive directory changes:
124 // zsock_recv (watch, "sp", &path, &patches);
125 //
126 // // Delete the received data\&.
127 // free (path);
128 // zlist_destroy (&patches);
129 CZMQ_EXPORT void
130 zdir_watch (zsock_t *pipe, void *unused);
131
132 // Self test of this class\&.
133 CZMQ_EXPORT void
134 zdir_test (bool verbose);
135
136 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zdir\&.c\*(Aq\&.
137 .fi
138 .SH "DESCRIPTION"
139 .sp
140 The zdir class gives access to the file system index\&. It will load a directory tree (a directory plus all child directories) into a zdir structure and then let you navigate that structure\&. It exists mainly to wrap non\-portable OS functions to do this\&.
141 .sp
142 Please add \fI@discuss\fR section in \fI\&./\&.\&./src/zdir\&.c\fR\&.
143 .SH "EXAMPLE"
144 .PP
145 \fBFrom zdir_test method\fR.
146 .sp
147 .if n \{\
148 .RS 4
149 .\}
150 .nf
151 // need to create a file in the test directory we\*(Aqre watching
152 // in order to ensure the directory exists
153 zfile_t *initfile = zfile_new ("\&./zdir\-test\-dir", "initial_file");
154 assert (initfile);
155 zfile_output (initfile);
156 fprintf (zfile_handle (initfile), "initial file\en");
157 zfile_close (initfile);
158 zfile_destroy (&initfile);
159
160 zdir_t *older = zdir_new ("zdir\-test\-dir", NULL);
161 assert (older);
162 if (verbose) {
163 printf ("\en");
164 zdir_dump (older, 0);
165 }
166 zdir_t *newer = zdir_new ("\&.", NULL);
167 assert (newer);
168 zlist_t *patches = zdir_diff (older, newer, "/");
169 assert (patches);
170 while (zlist_size (patches)) {
171 zdir_patch_t *patch = (zdir_patch_t *) zlist_pop (patches);
172 zdir_patch_destroy (&patch);
173 }
174 zlist_destroy (&patches);
175 zdir_destroy (&older);
176 zdir_destroy (&newer);
177
178 zdir_t *nosuch = zdir_new ("does\-not\-exist", NULL);
179 assert (nosuch == NULL);
180
181 // zdir_watch test:
182 zactor_t *watch = zactor_new (zdir_watch, NULL);
183 assert (watch);
184
185 if (verbose) {
186 zsock_send (watch, "s", "VERBOSE");
187 assert (zsock_wait (watch) == 0);
188 }
189
190 zclock_sleep (1001); // wait for initial file to become \*(Aqstable\*(Aq
191
192 zsock_send (watch, "si", "TIMEOUT", 100);
193 assert (zsock_wait (watch) == 0);
194
195 zsock_send (watch, "ss", "SUBSCRIBE", "zdir\-test\-dir");
196 assert (zsock_wait (watch) == 0);
197
198 zsock_send (watch, "ss", "UNSUBSCRIBE", "zdir\-test\-dir");
199 assert (zsock_wait (watch) == 0);
200
201 zsock_send (watch, "ss", "SUBSCRIBE", "zdir\-test\-dir");
202 assert (zsock_wait (watch) == 0);
203
204 zfile_t *newfile = zfile_new ("zdir\-test\-dir", "test_abc");
205 zfile_output (newfile);
206 fprintf (zfile_handle (newfile), "test file\en");
207 zfile_close (newfile);
208
209 zpoller_t *watch_poll = zpoller_new (watch, NULL);
210
211 // poll for a certain timeout before giving up and failing the test\&.
212 assert (zpoller_wait (watch_poll, 1001) == watch);
213
214 // wait for notification of the file being added
215 char *path;
216 int rc = zsock_recv (watch, "sp", &path, &patches);
217 assert (rc == 0);
218
219 assert (streq (path, "zdir\-test\-dir"));
220 free (path);
221
222 assert (zlist_size (patches) == 1);
223
224 zdir_patch_t *patch = (zdir_patch_t *) zlist_pop (patches);
225 assert (streq (zdir_patch_path (patch), "zdir\-test\-dir"));
226
227 zfile_t *patch_file = zdir_patch_file (patch);
228 assert (streq (zfile_filename (patch_file, ""), "zdir\-test\-dir/test_abc"));
229
230 zdir_patch_destroy (&patch);
231 zlist_destroy (&patches);
232
233 // remove the file
234 zfile_remove (newfile);
235 zfile_destroy (&newfile);
236
237 // poll for a certain timeout before giving up and failing the test\&.
238 assert (zpoller_wait (watch_poll, 1001) == watch);
239
240 // wait for notification of the file being removed
241 rc = zsock_recv (watch, "sp", &path, &patches);
242 assert (rc == 0);
243
244 assert (streq (path, "zdir\-test\-dir"));
245 free (path);
246
247 assert (zlist_size (patches) == 1);
248
249 patch = (zdir_patch_t *) zlist_pop (patches);
250 assert (streq (zdir_patch_path (patch), "zdir\-test\-dir"));
251
252 patch_file = zdir_patch_file (patch);
253 assert (streq (zfile_filename (patch_file, ""), "zdir\-test\-dir/test_abc"));
254
255 zdir_patch_destroy (&patch);
256 zlist_destroy (&patches);
257
258 zpoller_destroy (&watch_poll);
259 zactor_destroy (&watch);
260
261 // clean up by removing the test directory\&.
262 zdir_t *testdir = zdir_new ("zdir\-test\-dir", NULL);
263 zdir_remove (testdir, true);
264 zdir_destroy (&testdir);
265 .fi
266 .if n \{\
267 .RE
268 .\}
269 .sp
270 .SH "AUTHORS"
271 .sp
272 The czmq manual was written by the authors in the AUTHORS file\&.
273 .SH "RESOURCES"
274 .sp
275 Main web site: \m[blue]\fB\%\fR\m[]
276 .sp
277 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
278 .SH "COPYRIGHT"
279 .sp
280 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
281 .SH "NOTES"
282 .IP " 1." 4
283 zeromq-dev@lists.zeromq.org
284 .RS 4
285 \%mailto:zeromq-dev@lists.zeromq.org
286 .RE
109109 CZMQ_EXPORT void
110110 zdir_test (bool verbose);
111111
112 Please add '@interface' section in './../src/zdir.c'.
112113 ----
113114
114115 DESCRIPTION
119120 zdir structure and then let you navigate that structure. It exists
120121 mainly to wrap non-portable OS functions to do this.
121122
122 Please add @discuss section in ../src/zdir.c.
123 Please add '@discuss' section in './../src/zdir.c'.
123124
124125 EXAMPLE
125126 -------
0 '\" t
1 .\" Title: zdir_patch
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZDIR_PATCH" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zdir_patch \- work with directory patches
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 #define ZDIR_PATCH_CREATE 1 // Creates a new file
37 #define ZDIR_PATCH_DELETE 2 // Delete a file
38
39 // Create new patch
40 CZMQ_EXPORT zdir_patch_t *
41 zdir_patch_new (const char *path, zfile_t *file, int op, const char *alias);
42
43 // Destroy a patch
44 CZMQ_EXPORT void
45 zdir_patch_destroy (zdir_patch_t **self_p);
46
47 // Create copy of a patch\&. If the patch is null, or memory was exhausted,
48 // returns null\&.
49 // Caller owns return value and must destroy it when done\&.
50 CZMQ_EXPORT zdir_patch_t *
51 zdir_patch_dup (zdir_patch_t *self);
52
53 // Return patch file directory path
54 CZMQ_EXPORT const char *
55 zdir_patch_path (zdir_patch_t *self);
56
57 // Return patch file item
58 CZMQ_EXPORT zfile_t *
59 zdir_patch_file (zdir_patch_t *self);
60
61 // Return operation
62 CZMQ_EXPORT int
63 zdir_patch_op (zdir_patch_t *self);
64
65 // Return patch virtual file path
66 CZMQ_EXPORT const char *
67 zdir_patch_vpath (zdir_patch_t *self);
68
69 // Calculate hash digest for file (create only)
70 CZMQ_EXPORT void
71 zdir_patch_digest_set (zdir_patch_t *self);
72
73 // Return hash digest for patch file
74 CZMQ_EXPORT const char *
75 zdir_patch_digest (zdir_patch_t *self);
76
77 // Self test of this class\&.
78 CZMQ_EXPORT void
79 zdir_patch_test (bool verbose);
80
81 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zdir_patch\&.c\*(Aq\&.
82 .fi
83 .SH "DESCRIPTION"
84 .sp
85 The zdir_patch class works with one patch, which says "create this file" or "delete this file" (referring to a zfile item each time)\&.
86 .sp
87 Please add \fI@discuss\fR section in \fI\&./\&.\&./src/zdir_patch\&.c\fR\&.
88 .SH "EXAMPLE"
89 .PP
90 \fBFrom zdir_patch_test method\fR.
91 .sp
92 .if n \{\
93 .RS 4
94 .\}
95 .nf
96 zfile_t *file = zfile_new ("\&.", "bilbo");
97 assert (file);
98 zdir_patch_t *patch = zdir_patch_new ("\&.", file, patch_create, "/");
99 assert (patch);
100 zfile_destroy (&file);
101
102 file = zdir_patch_file (patch);
103 assert (file);
104 assert (streq (zfile_filename (file, "\&."), "bilbo"));
105 assert (streq (zdir_patch_vpath (patch), "/bilbo"));
106 zdir_patch_destroy (&patch);
107 .fi
108 .if n \{\
109 .RE
110 .\}
111 .sp
112 .SH "AUTHORS"
113 .sp
114 The czmq manual was written by the authors in the AUTHORS file\&.
115 .SH "RESOURCES"
116 .sp
117 Main web site: \m[blue]\fB\%\fR\m[]
118 .sp
119 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
120 .SH "COPYRIGHT"
121 .sp
122 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
123 .SH "NOTES"
124 .IP " 1." 4
125 zeromq-dev@lists.zeromq.org
126 .RS 4
127 \%mailto:zeromq-dev@lists.zeromq.org
128 .RE
5454 CZMQ_EXPORT void
5555 zdir_patch_test (bool verbose);
5656
57 Please add '@interface' section in './../src/zdir_patch.c'.
5758 ----
5859
5960 DESCRIPTION
6263 The zdir_patch class works with one patch, which says "create this
6364 file" or "delete this file" (referring to a zfile item each time).
6465
65 Please add @discuss section in ../src/zdir_patch.c.
66 Please add '@discuss' section in './../src/zdir_patch.c'.
6667
6768 EXAMPLE
6869 -------
0 '\" t
1 .\" Title: zfile
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZFILE" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zfile \- provides methods to work with files in a portable fashion\&.
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // If file exists, populates properties\&. CZMQ supports portable symbolic
37 // links, which are files with the extension "\&.ln"\&. A symbolic link is a
38 // text file containing one line, the filename of a target file\&. Reading
39 // data from the symbolic link actually reads from the target file\&. Path
40 // may be NULL, in which case it is not used\&.
41 CZMQ_EXPORT zfile_t *
42 zfile_new (const char *path, const char *name);
43
44 // Destroy a file item
45 CZMQ_EXPORT void
46 zfile_destroy (zfile_t **self_p);
47
48 // Duplicate a file item, returns a newly constructed item\&. If the file
49 // is null, or memory was exhausted, returns null\&.
50 // Caller owns return value and must destroy it when done\&.
51 CZMQ_EXPORT zfile_t *
52 zfile_dup (zfile_t *self);
53
54 // Return file name, remove path if provided
55 CZMQ_EXPORT const char *
56 zfile_filename (zfile_t *self, const char *path);
57
58 // Refresh file properties from disk; this is not done automatically
59 // on access methods, otherwise it is not possible to compare directory
60 // snapshots\&.
61 CZMQ_EXPORT void
62 zfile_restat (zfile_t *self);
63
64 // Return when the file was last modified\&. If you want this to reflect the
65 // current situation, call zfile_restat before checking this property\&.
66 CZMQ_EXPORT time_t
67 zfile_modified (zfile_t *self);
68
69 // Return the last\-known size of the file\&. If you want this to reflect the
70 // current situation, call zfile_restat before checking this property\&.
71 CZMQ_EXPORT off_t
72 zfile_cursize (zfile_t *self);
73
74 // Return true if the file is a directory\&. If you want this to reflect
75 // any external changes, call zfile_restat before checking this property\&.
76 CZMQ_EXPORT bool
77 zfile_is_directory (zfile_t *self);
78
79 // Return true if the file is a regular file\&. If you want this to reflect
80 // any external changes, call zfile_restat before checking this property\&.
81 CZMQ_EXPORT bool
82 zfile_is_regular (zfile_t *self);
83
84 // Return true if the file is readable by this process\&. If you want this to
85 // reflect any external changes, call zfile_restat before checking this
86 // property\&.
87 CZMQ_EXPORT bool
88 zfile_is_readable (zfile_t *self);
89
90 // Return true if the file is writeable by this process\&. If you want this
91 // to reflect any external changes, call zfile_restat before checking this
92 // property\&.
93 CZMQ_EXPORT bool
94 zfile_is_writeable (zfile_t *self);
95
96 // Check if file has stopped changing and can be safely processed\&.
97 // Updates the file statistics from disk at every call\&.
98 CZMQ_EXPORT bool
99 zfile_is_stable (zfile_t *self);
100
101 // Return true if the file was changed on disk since the zfile_t object
102 // was created, or the last zfile_restat() call made on it\&.
103 CZMQ_EXPORT bool
104 zfile_has_changed (zfile_t *self);
105
106 // Remove the file from disk
107 CZMQ_EXPORT void
108 zfile_remove (zfile_t *self);
109
110 // Open file for reading
111 // Returns 0 if OK, \-1 if not found or not accessible
112 CZMQ_EXPORT int
113 zfile_input (zfile_t *self);
114
115 // Open file for writing, creating directory if needed
116 // File is created if necessary; chunks can be written to file at any
117 // location\&. Returns 0 if OK, \-1 if error\&.
118 CZMQ_EXPORT int
119 zfile_output (zfile_t *self);
120
121 // Read chunk from file at specified position\&. If this was the last chunk,
122 // sets the eof property\&. Returns a null chunk in case of error\&.
123 // Caller owns return value and must destroy it when done\&.
124 CZMQ_EXPORT zchunk_t *
125 zfile_read (zfile_t *self, size_t bytes, off_t offset);
126
127 // Returns true if zfile_read() just read the last chunk in the file\&.
128 CZMQ_EXPORT bool
129 zfile_eof (zfile_t *self);
130
131 // Write chunk to file at specified position
132 // Return 0 if OK, else \-1
133 CZMQ_EXPORT int
134 zfile_write (zfile_t *self, zchunk_t *chunk, off_t offset);
135
136 // Read next line of text from file\&. Returns a pointer to the text line,
137 // or NULL if there was nothing more to read from the file\&.
138 CZMQ_EXPORT const char *
139 zfile_readln (zfile_t *self);
140
141 // Close file, if open
142 CZMQ_EXPORT void
143 zfile_close (zfile_t *self);
144
145 // Return file handle, if opened
146 CZMQ_EXPORT FILE *
147 zfile_handle (zfile_t *self);
148
149 // Calculate SHA1 digest for file, using zdigest class\&.
150 CZMQ_EXPORT const char *
151 zfile_digest (zfile_t *self);
152
153 // Self test of this class\&.
154 CZMQ_EXPORT void
155 zfile_test (bool verbose);
156
157 // These methods are deprecated, and now moved to zsys class\&.
158 CZMQ_EXPORT bool
159 zfile_exists (const char *filename);
160 CZMQ_EXPORT ssize_t
161 zfile_size (const char *filename);
162 CZMQ_EXPORT mode_t
163 zfile_mode (const char *filename);
164 CZMQ_EXPORT int
165 zfile_delete (const char *filename);
166 CZMQ_EXPORT bool
167 zfile_stable (const char *filename);
168 CZMQ_EXPORT int
169 zfile_mkdir (const char *pathname);
170 CZMQ_EXPORT int
171 zfile_rmdir (const char *pathname);
172 CZMQ_EXPORT void
173 zfile_mode_private (void);
174 CZMQ_EXPORT void
175 zfile_mode_default (void);
176 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zfile\&.c\*(Aq\&.
177 .fi
178 .SH "DESCRIPTION"
179 .sp
180 The zfile class provides methods to work with disk files\&. A file object provides the modified date, current size, and type of the file\&. You can create a file object for a filename that does not yet exist\&. To read or write data from the file, use the input and output methods, and then read and write chunks\&. The output method lets you both read and write chunks, at any offset\&. Finally, this class provides portable symbolic links\&. If a filename ends in "\&.ln", the first line of text in the file is read, and used as the underlying file for read/write operations\&. This lets you manipulate (e\&.g\&.) copy symbolic links without copying the perhaps very large files they point to\&.
181 .sp
182 This class is a new API, deprecating the old zfile class (which still exists but is implemented in zsys now)\&.
183 .SH "EXAMPLE"
184 .PP
185 \fBFrom zfile_test method\fR.
186 .sp
187 .if n \{\
188 .RS 4
189 .\}
190 .nf
191 zfile_t *file = zfile_new (NULL, "bilbo");
192 assert (file);
193 assert (streq (zfile_filename (file, "\&."), "bilbo"));
194 assert (zfile_is_readable (file) == false);
195 zfile_destroy (&file);
196
197 // Create a test file in some random subdirectory
198 file = zfile_new ("\&./this/is/a/test", "bilbo");
199 assert (file);
200 int rc = zfile_output (file);
201 assert (rc == 0);
202 zchunk_t *chunk = zchunk_new (NULL, 100);
203 assert (chunk);
204 zchunk_fill (chunk, 0, 100);
205
206 // Write 100 bytes at position 1,000,000 in the file
207 rc = zfile_write (file, chunk, 1000000);
208 assert (rc == 0);
209 zchunk_destroy (&chunk);
210 zfile_close (file);
211 assert (zfile_is_readable (file));
212 assert (zfile_cursize (file) == 1000100);
213 assert (!zfile_is_stable (file));
214 assert (zfile_digest (file));
215
216 // Now truncate file from outside
217 int handle = open ("\&./this/is/a/test/bilbo", O_WRONLY | O_TRUNC | O_BINARY, 0);
218 assert (handle >= 0);
219 rc = write (handle, "Hello, World\en", 13);
220 assert (rc == 13);
221 close (handle);
222 assert (zfile_has_changed (file));
223 zclock_sleep (1001);
224 assert (zfile_has_changed (file));
225
226 assert (!zfile_is_stable (file));
227 zfile_restat (file);
228 assert (zfile_is_stable (file));
229 assert (streq (zfile_digest (file), "4AB299C8AD6ED14F31923DD94F8B5F5CB89DFB54"));
230
231 // Check we can read from file
232 rc = zfile_input (file);
233 assert (rc == 0);
234 chunk = zfile_read (file, 1000100, 0);
235 assert (chunk);
236 assert (zchunk_size (chunk) == 13);
237 zchunk_destroy (&chunk);
238 zfile_close (file);
239
240 // Check we can read lines from file
241 rc = zfile_input (file);
242 assert (rc == 0);
243 const char *line = zfile_readln (file);
244 assert (streq (line, "Hello, World"));
245 line = zfile_readln (file);
246 assert (line == NULL);
247 zfile_close (file);
248
249 // Try some fun with symbolic links
250 zfile_t *link = zfile_new ("\&./this/is/a/test", "bilbo\&.ln");
251 assert (link);
252 rc = zfile_output (link);
253 assert (rc == 0);
254 fprintf (zfile_handle (link), "\&./this/is/a/test/bilbo\en");
255 zfile_destroy (&link);
256
257 link = zfile_new ("\&./this/is/a/test", "bilbo\&.ln");
258 assert (link);
259 rc = zfile_input (link);
260 assert (rc == 0);
261 chunk = zfile_read (link, 1000100, 0);
262 assert (chunk);
263 assert (zchunk_size (chunk) == 13);
264 zchunk_destroy (&chunk);
265 zfile_destroy (&link);
266
267 // Remove file and directory
268 zdir_t *dir = zdir_new ("\&./this", NULL);
269 assert (dir);
270 assert (zdir_cursize (dir) == 26);
271 zdir_remove (dir, true);
272 assert (zdir_cursize (dir) == 0);
273 zdir_destroy (&dir);
274
275 // Check we can no longer read from file
276 assert (zfile_is_readable (file));
277 zfile_restat (file);
278 assert (!zfile_is_readable (file));
279 rc = zfile_input (file);
280 assert (rc == \-1);
281 zfile_destroy (&file);
282
283 file = zfile_new ("\&./", "eof_checkfile");
284 assert (file);
285 // 1\&. Write something first
286 rc = zfile_output (file);
287 assert (rc == 0);
288 chunk = zchunk_new ("123456789", 9);
289 assert (chunk);
290
291 rc = zfile_write (file, chunk, 0);
292 assert (rc == 0);
293 zchunk_destroy (&chunk);
294 zfile_close (file);
295 assert (zfile_cursize (file) == 9);
296
297 // 2\&. Read the written something
298 rc = zfile_input (file);
299 assert (rc != \-1);
300 // try to read more bytes than there is in the file
301 chunk = zfile_read (file, 1000, 0);
302 assert (zfile_eof(file));
303 assert (zchunk_streq (chunk, "123456789"));
304 zchunk_destroy (&chunk);
305
306 // reading is ok
307 chunk = zfile_read (file, 5, 0);
308 assert (!zfile_eof(file));
309 assert (zchunk_streq (chunk, "12345"));
310 zchunk_destroy (&chunk);
311
312 // read from non zero offset until the end
313 chunk = zfile_read (file, 5, 5);
314 assert (zfile_eof(file));
315 assert (zchunk_streq (chunk, "6789"));
316 zchunk_destroy (&chunk);
317 zfile_remove (file);
318 .fi
319 .if n \{\
320 .RE
321 .\}
322 .sp
323 .SH "AUTHORS"
324 .sp
325 The czmq manual was written by the authors in the AUTHORS file\&.
326 .SH "RESOURCES"
327 .sp
328 Main web site: \m[blue]\fB\%\fR\m[]
329 .sp
330 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
331 .SH "COPYRIGHT"
332 .sp
333 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
334 .SH "NOTES"
335 .IP " 1." 4
336 zeromq-dev@lists.zeromq.org
337 .RS 4
338 \%mailto:zeromq-dev@lists.zeromq.org
339 .RE
149149 zfile_mode_private (void);
150150 CZMQ_EXPORT void
151151 zfile_mode_default (void);
152 Please add '@interface' section in './../src/zfile.c'.
152153 ----
153154
154155 DESCRIPTION
0 '\" t
1 .\" Title: zframe
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZFRAME" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zframe \- working with single message frames
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // This class has draft methods, which may change over time\&. They are not
37 // in stable releases, by default\&. Use \-\-enable\-drafts to enable\&.
38 #define ZFRAME_MORE 1 //
39 #define ZFRAME_REUSE 2 //
40 #define ZFRAME_DONTWAIT 4 //
41
42 // Create a new frame\&. If size is not null, allocates the frame data
43 // to the specified size\&. If additionally, data is not null, copies
44 // size octets from the specified data into the frame body\&.
45 CZMQ_EXPORT zframe_t *
46 zframe_new (const void *data, size_t size);
47
48 // Create an empty (zero\-sized) frame
49 CZMQ_EXPORT zframe_t *
50 zframe_new_empty (void);
51
52 // Create a frame with a specified string content\&.
53 CZMQ_EXPORT zframe_t *
54 zframe_from (const char *string);
55
56 // Receive frame from socket, returns zframe_t object or NULL if the recv
57 // was interrupted\&. Does a blocking recv, if you want to not block then use
58 // zpoller or zloop\&.
59 CZMQ_EXPORT zframe_t *
60 zframe_recv (void *source);
61
62 // Destroy a frame
63 CZMQ_EXPORT void
64 zframe_destroy (zframe_t **self_p);
65
66 // Send a frame to a socket, destroy frame after sending\&.
67 // Return \-1 on error, 0 on success\&.
68 CZMQ_EXPORT int
69 zframe_send (zframe_t **self_p, void *dest, int flags);
70
71 // Return number of bytes in frame data
72 CZMQ_EXPORT size_t
73 zframe_size (zframe_t *self);
74
75 // Return address of frame data
76 CZMQ_EXPORT byte *
77 zframe_data (zframe_t *self);
78
79 // Return meta data property for frame
80 // Caller must free string when finished with it\&.
81 CZMQ_EXPORT const char *
82 zframe_meta (zframe_t *self, const char *property);
83
84 // Create a new frame that duplicates an existing frame\&. If frame is null,
85 // or memory was exhausted, returns null\&.
86 // Caller owns return value and must destroy it when done\&.
87 CZMQ_EXPORT zframe_t *
88 zframe_dup (zframe_t *self);
89
90 // Return frame data encoded as printable hex string, useful for 0MQ UUIDs\&.
91 // Caller must free string when finished with it\&.
92 // Caller owns return value and must destroy it when done\&.
93 CZMQ_EXPORT char *
94 zframe_strhex (zframe_t *self);
95
96 // Return frame data copied into freshly allocated string
97 // Caller must free string when finished with it\&.
98 // Caller owns return value and must destroy it when done\&.
99 CZMQ_EXPORT char *
100 zframe_strdup (zframe_t *self);
101
102 // Return TRUE if frame body is equal to string, excluding terminator
103 CZMQ_EXPORT bool
104 zframe_streq (zframe_t *self, const char *string);
105
106 // Return frame MORE indicator (1 or 0), set when reading frame from socket
107 // or by the zframe_set_more() method
108 CZMQ_EXPORT int
109 zframe_more (zframe_t *self);
110
111 // Set frame MORE indicator (1 or 0)\&. Note this is NOT used when sending
112 // frame to socket, you have to specify flag explicitly\&.
113 CZMQ_EXPORT void
114 zframe_set_more (zframe_t *self, int more);
115
116 // Return TRUE if two frames have identical size and data
117 // If either frame is NULL, equality is always false\&.
118 CZMQ_EXPORT bool
119 zframe_eq (zframe_t *self, zframe_t *other);
120
121 // Set new contents for frame
122 CZMQ_EXPORT void
123 zframe_reset (zframe_t *self, const void *data, size_t size);
124
125 // Send message to zsys log sink (may be stdout, or system facility as
126 // configured by zsys_set_logstream)\&. Prefix shows before frame, if not null\&.
127 CZMQ_EXPORT void
128 zframe_print (zframe_t *self, const char *prefix);
129
130 // Probe the supplied object, and report if it looks like a zframe_t\&.
131 CZMQ_EXPORT bool
132 zframe_is (void *self);
133
134 // Self test of this class\&.
135 CZMQ_EXPORT void
136 zframe_test (bool verbose);
137
138 #ifdef CZMQ_BUILD_DRAFT_API
139 // *** Draft method, for development use, may change without warning ***
140 // Return frame routing ID, if the frame came from a ZMQ_SERVER socket\&.
141 // Else returns zero\&.
142 CZMQ_EXPORT uint32_t
143 zframe_routing_id (zframe_t *self);
144
145 // *** Draft method, for development use, may change without warning ***
146 // Set routing ID on frame\&. This is used if/when the frame is sent to a
147 // ZMQ_SERVER socket\&.
148 CZMQ_EXPORT void
149 zframe_set_routing_id (zframe_t *self, uint32_t routing_id);
150
151 // *** Draft method, for development use, may change without warning ***
152 // Return frame group of radio\-dish pattern\&.
153 CZMQ_EXPORT const char *
154 zframe_group (zframe_t *self);
155
156 // *** Draft method, for development use, may change without warning ***
157 // Set group on frame\&. This is used if/when the frame is sent to a
158 // ZMQ_RADIO socket\&.
159 // Return \-1 on error, 0 on success\&.
160 CZMQ_EXPORT int
161 zframe_set_group (zframe_t *self, const char *group);
162
163 #endif // CZMQ_BUILD_DRAFT_API
164 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zframe\&.c\*(Aq\&.
165 .fi
166 .SH "DESCRIPTION"
167 .sp
168 The zframe class provides methods to send and receive single message frames across 0MQ sockets\&. A \fIframe\fR corresponds to one zmq_msg_t\&. When you read a frame from a socket, the zframe_more() method indicates if the frame is part of an unfinished multipart message\&. The zframe_send method normally destroys the frame, but with the ZFRAME_REUSE flag, you can send the same frame many times\&. Frames are binary, and this class has no special support for text data\&.
169 .sp
170 Please add \fI@discuss\fR section in \fI\&./\&.\&./src/zframe\&.c\fR\&.
171 .SH "EXAMPLE"
172 .PP
173 \fBFrom zframe_test method\fR.
174 .sp
175 .if n \{\
176 .RS 4
177 .\}
178 .nf
179 // Create two PAIR sockets and connect over inproc
180 zsock_t *output = zsock_new_pair ("@tcp://127\&.0\&.0\&.1:9001");
181 assert (output);
182 zsock_t *input = zsock_new_pair (">tcp://127\&.0\&.0\&.1:9001");
183 assert (input);
184
185 // Send five different frames, test ZFRAME_MORE
186 int frame_nbr;
187 for (frame_nbr = 0; frame_nbr < 5; frame_nbr++) {
188 frame = zframe_new ("Hello", 5);
189 assert (frame);
190 rc = zframe_send (&frame, output, ZFRAME_MORE);
191 assert (rc == 0);
192 }
193 // Send same frame five times, test ZFRAME_REUSE
194 frame = zframe_new ("Hello", 5);
195 assert (frame);
196 for (frame_nbr = 0; frame_nbr < 5; frame_nbr++) {
197 rc = zframe_send (&frame, output, ZFRAME_MORE + ZFRAME_REUSE);
198 assert (rc == 0);
199 }
200 assert (frame);
201 zframe_t *copy = zframe_dup (frame);
202 assert (zframe_eq (frame, copy));
203 zframe_destroy (&frame);
204 assert (!zframe_eq (frame, copy));
205 assert (zframe_size (copy) == 5);
206 zframe_destroy (&copy);
207 assert (!zframe_eq (frame, copy));
208
209 // Test zframe_new_empty
210 frame = zframe_new_empty ();
211 assert (frame);
212 assert (zframe_size (frame) == 0);
213 zframe_destroy (&frame);
214
215 // Send END frame
216 frame = zframe_new ("NOT", 3);
217 assert (frame);
218 zframe_reset (frame, "END", 3);
219 char *string = zframe_strhex (frame);
220 assert (streq (string, "454E44"));
221 free (string);
222 string = zframe_strdup (frame);
223 assert (streq (string, "END"));
224 free (string);
225 rc = zframe_send (&frame, output, 0);
226 assert (rc == 0);
227
228 // Read and count until we receive END
229 frame_nbr = 0;
230 for (frame_nbr = 0;; frame_nbr++) {
231 zframe_t *frame = zframe_recv (input);
232 if (zframe_streq (frame, "END")) {
233 zframe_destroy (&frame);
234 break;
235 }
236 assert (zframe_more (frame));
237 zframe_set_more (frame, 0);
238 assert (zframe_more (frame) == 0);
239 zframe_destroy (&frame);
240 }
241 assert (frame_nbr == 10);
242
243 #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (4, 1, 0))
244 // Test zframe_meta
245 frame = zframe_new ("Hello", 5);
246 assert (frame);
247 rc = zframe_send (&frame, output, 0);
248 assert (rc == 0);
249 frame = zframe_recv (input);
250 const char *meta = zframe_meta (frame, "Socket\-Type");
251 assert (meta != NULL);
252 assert (streq (meta, "PAIR"));
253 assert (zframe_meta (frame, "nonexistent") == NULL);
254 zframe_destroy (&frame);
255 #endif
256
257 zsock_destroy (&input);
258 zsock_destroy (&output);
259
260 #if defined (ZMQ_SERVER)
261 // Create server and client sockets and connect over inproc
262 zsock_t *server = zsock_new_server ("inproc://zframe\-test\-routing");
263 assert (server);
264 zsock_t *client = zsock_new_client ("inproc://zframe\-test\-routing");
265 assert (client);
266
267 // Send request from client to server
268 zframe_t *request = zframe_new ("Hello", 5);
269 assert (request);
270 rc = zframe_send (&request, client, 0);
271 assert (rc == 0);
272 assert (!request);
273
274 // Read request and send reply
275 request = zframe_recv (server);
276 assert (request);
277 assert (zframe_streq (request, "Hello"));
278 assert (zframe_routing_id (request));
279
280 zframe_t *reply = zframe_new ("World", 5);
281 assert (reply);
282 zframe_set_routing_id (reply, zframe_routing_id (request));
283 rc = zframe_send (&reply, server, 0);
284 assert (rc == 0);
285 zframe_destroy (&request);
286
287 // Read reply
288 reply = zframe_recv (client);
289 assert (zframe_streq (reply, "World"));
290 assert (zframe_routing_id (reply) == 0);
291 zframe_destroy (&reply);
292
293 // Client and server disallow multipart
294 frame = zframe_new ("Hello", 5);
295 rc = zframe_send (&frame, client, ZFRAME_MORE);
296 assert (rc == \-1);
297 rc = zframe_send (&frame, server, ZFRAME_MORE);
298 assert (rc == \-1);
299 zframe_destroy (&frame);
300
301 zsock_destroy (&client);
302 zsock_destroy (&server);
303 #endif
304
305 #ifdef ZMQ_RADIO
306 // Create radio and dish sockets and connect over inproc
307 zsock_t *radio = zsock_new_radio ("inproc://zframe\-test\-radio");
308 assert (radio);
309 zsock_t *dish = zsock_new_dish ("inproc://zframe\-test\-radio");
310 assert (dish);
311
312 // Join the group
313 rc = zsock_join (dish, "World");
314 assert (rc == 0);
315
316 // Publish message from radio
317 zframe_t *message = zframe_new ("Hello", 5);
318 assert (message);
319 rc = zframe_set_group (message, "World");
320 assert (rc == 0);
321 rc = zframe_send (&message, radio, 0);
322 assert (rc == 0);
323 assert (!message);
324
325 // Receive the message from dish
326 message = zframe_recv (dish);
327 assert (message);
328 assert (zframe_streq (message, "Hello"));
329 assert (strcmp("World", zframe_group (message)) == 0);
330 zframe_destroy (&message);
331
332 zsock_destroy (&dish);
333 zsock_destroy (&radio);
334 #endif
335 .fi
336 .if n \{\
337 .RE
338 .\}
339 .sp
340 .SH "AUTHORS"
341 .sp
342 The czmq manual was written by the authors in the AUTHORS file\&.
343 .SH "RESOURCES"
344 .sp
345 Main web site: \m[blue]\fB\%\fR\m[]
346 .sp
347 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
348 .SH "COPYRIGHT"
349 .sp
350 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
351 .SH "NOTES"
352 .IP " 1." 4
353 zeromq-dev@lists.zeromq.org
354 .RS 4
355 \%mailto:zeromq-dev@lists.zeromq.org
356 .RE
137137 zframe_set_group (zframe_t *self, const char *group);
138138
139139 #endif // CZMQ_BUILD_DRAFT_API
140 Please add '@interface' section in './../src/zframe.c'.
140141 ----
141142
142143 DESCRIPTION
150151 the same frame many times. Frames are binary, and this class has no
151152 special support for text data.
152153
153 Please add @discuss section in ../src/zframe.c.
154 Please add '@discuss' section in './../src/zframe.c'.
154155
155156 EXAMPLE
156157 -------
0 '\" t
1 .\" Title: zgossip
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZGOSSIP" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zgossip \- decentralized configuration management
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // To work with zgossip, use the CZMQ zactor API:
35 //
36 // Create new zgossip instance, passing logging prefix:
37 //
38 // zactor_t *zgossip = zactor_new (zgossip, "myname");
39 //
40 // Destroy zgossip instance
41 //
42 // zactor_destroy (&zgossip);
43 //
44 // Enable verbose logging of commands and activity:
45 //
46 // zstr_send (zgossip, "VERBOSE");
47 //
48 // Bind zgossip to specified endpoint\&. TCP endpoints may specify
49 // the port number as "*" to aquire an ephemeral port:
50 //
51 // zstr_sendx (zgossip, "BIND", endpoint, NULL);
52 //
53 // Return assigned port number, specifically when BIND was done using an
54 // an ephemeral port:
55 //
56 // zstr_sendx (zgossip, "PORT", NULL);
57 // char *command, *port_str;
58 // zstr_recvx (zgossip, &command, &port_str, NULL);
59 // assert (streq (command, "PORT"));
60 //
61 // Specify configuration file to load, overwriting any previous loaded
62 // configuration file or options:
63 //
64 // zstr_sendx (zgossip, "LOAD", filename, NULL);
65 //
66 // Set configuration path value:
67 //
68 // zstr_sendx (zgossip, "SET", path, value, NULL);
69 //
70 // Save configuration data to config file on disk:
71 //
72 // zstr_sendx (zgossip, "SAVE", filename, NULL);
73 //
74 // Send zmsg_t instance to zgossip:
75 //
76 // zactor_send (zgossip, &msg);
77 //
78 // Receive zmsg_t instance from zgossip:
79 //
80 // zmsg_t *msg = zactor_recv (zgossip);
81 //
82 // This is the zgossip constructor as a zactor_fn:
83 //
84 CZMQ_EXPORT void
85 zgossip (zsock_t *pipe, void *args);
86
87 // Self test of this class
88 CZMQ_EXPORT void
89 zgossip_test (bool verbose);
90 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zgossip\&.c\*(Aq\&.
91 .fi
92 .SH "DESCRIPTION"
93 .sp
94 Implements a gossip protocol for decentralized configuration management\&. Your applications nodes form a loosely connected network (which can have cycles), and publish name/value tuples\&. Each node re\-distributes the new tuples it receives, so that the entire network eventually achieves a consistent state\&. The current design does not expire tuples\&.
95 .sp
96 Provides these commands (sent as multipart strings to the actor):
97 .sp
98 .RS 4
99 .ie n \{\
100 \h'-04'\(bu\h'+03'\c
101 .\}
102 .el \{\
103 .sp -1
104 .IP \(bu 2.3
105 .\}
106 BIND endpoint \(em binds the gossip service to specified endpoint
107 .RE
108 .sp
109 .RS 4
110 .ie n \{\
111 \h'-04'\(bu\h'+03'\c
112 .\}
113 .el \{\
114 .sp -1
115 .IP \(bu 2.3
116 .\}
117 PORT \(em returns the last TCP port, if any, used for binding
118 .RE
119 .sp
120 .RS 4
121 .ie n \{\
122 \h'-04'\(bu\h'+03'\c
123 .\}
124 .el \{\
125 .sp -1
126 .IP \(bu 2.3
127 .\}
128 LOAD configfile \(em load configuration from specified file
129 .RE
130 .sp
131 .RS 4
132 .ie n \{\
133 \h'-04'\(bu\h'+03'\c
134 .\}
135 .el \{\
136 .sp -1
137 .IP \(bu 2.3
138 .\}
139 SET configpath value \(em set configuration path = value
140 .RE
141 .sp
142 .RS 4
143 .ie n \{\
144 \h'-04'\(bu\h'+03'\c
145 .\}
146 .el \{\
147 .sp -1
148 .IP \(bu 2.3
149 .\}
150 SAVE configfile \(em save configuration to specified file
151 .RE
152 .sp
153 .RS 4
154 .ie n \{\
155 \h'-04'\(bu\h'+03'\c
156 .\}
157 .el \{\
158 .sp -1
159 .IP \(bu 2.3
160 .\}
161 CONNECT endpoint \(em connect the gossip service to the specified peer
162 .RE
163 .sp
164 .RS 4
165 .ie n \{\
166 \h'-04'\(bu\h'+03'\c
167 .\}
168 .el \{\
169 .sp -1
170 .IP \(bu 2.3
171 .\}
172 PUBLISH key value \(em publish a key/value pair to the gossip cluster
173 .RE
174 .sp
175 .RS 4
176 .ie n \{\
177 \h'-04'\(bu\h'+03'\c
178 .\}
179 .el \{\
180 .sp -1
181 .IP \(bu 2.3
182 .\}
183 STATUS \(em return number of key/value pairs held by gossip service
184 .RE
185 .sp
186 Returns these messages:
187 .sp
188 .RS 4
189 .ie n \{\
190 \h'-04'\(bu\h'+03'\c
191 .\}
192 .el \{\
193 .sp -1
194 .IP \(bu 2.3
195 .\}
196 PORT number \(em reply to PORT command
197 .RE
198 .sp
199 .RS 4
200 .ie n \{\
201 \h'-04'\(bu\h'+03'\c
202 .\}
203 .el \{\
204 .sp -1
205 .IP \(bu 2.3
206 .\}
207 STATUS number \(em reply to STATUS command
208 .RE
209 .sp
210 .RS 4
211 .ie n \{\
212 \h'-04'\(bu\h'+03'\c
213 .\}
214 .el \{\
215 .sp -1
216 .IP \(bu 2.3
217 .\}
218 DELIVER key value \(em new tuple delivered from network
219 .RE
220 .sp
221 The gossip protocol distributes information around a loosely\-connected network of gossip services\&. The information consists of name/value pairs published by applications at any point in the network\&. The goal of the gossip protocol is to create eventual consistency between all the using applications\&.
222 .sp
223 The name/value pairs (tuples) can be used for configuration data, for status updates, for presence, or for discovery\&. When used for discovery, the gossip protocol works as an alternative to e\&.g\&. UDP beaconing\&.
224 .sp
225 The gossip network consists of a set of loosely\-coupled nodes that exchange tuples\&. Nodes can be connected across arbitrary transports, so the gossip network can have nodes that communicate over inproc, over IPC, and/or over TCP, at the same time\&.
226 .sp
227 Each node runs the same stack, which is a server\-client hybrid using a modified Harmony pattern (from Chapter 8 of the Guide): \m[blue]\fBhttp://zguide\&.zeromq\&.org/page:all#True\-Peer\-Connectivity\-Harmony\-Pattern\fR\m[]
228 .sp
229 Each node provides a ROUTER socket that accepts client connections on an key defined by the application via a BIND command\&. The state machine for these connections is in zgossip\&.xml, and the generated code is in zgossip_engine\&.inc\&.
230 .sp
231 Each node additionally creates outbound connections via DEALER sockets to a set of servers ("remotes"), and under control of the calling app, which sends CONNECT commands for each configured remote\&.
232 .sp
233 The messages between client and server are defined in zgossip_msg\&.xml\&. We built this stack using the zeromq/zproto toolkit\&.
234 .sp
235 To join the gossip network, a node connects to one or more peers\&. Each peer acts as a forwarder\&. This loosely\-coupled network can scale to thousands of nodes\&. However the gossip protocol is NOT designed to be efficient, and should not be used for application data, as the same tuples may be sent many times across the network\&.
236 .sp
237 The basic logic of the gossip service is to accept PUBLISH messages from its owning application, and to forward these to every remote, and every client it talks to\&. When a node gets a duplicate tuple, it throws it away\&. When a node gets a new tuple, it stores it, and fowards it as just described\&. At any point the application can access the node\(cqs set of tuples\&.
238 .sp
239 At present there is no way to expire tuples from the network\&.
240 .sp
241 The assumptions in this design are:
242 .sp
243 .RS 4
244 .ie n \{\
245 \h'-04'\(bu\h'+03'\c
246 .\}
247 .el \{\
248 .sp -1
249 .IP \(bu 2.3
250 .\}
251 The data set is slow\-changing\&. Thus, the cost of the gossip protocol is irrelevant with respect to other traffic\&.
252 .RE
253 .SH "EXAMPLE"
254 .PP
255 \fBFrom zgossip_test method\fR.
256 .sp
257 .if n \{\
258 .RS 4
259 .\}
260 .nf
261 // Test basic client\-to\-server operation of the protocol
262 zactor_t *server = zactor_new (zgossip, "server");
263 assert (server);
264 if (verbose)
265 zstr_send (server, "VERBOSE");
266 zstr_sendx (server, "BIND", "inproc://zgossip", NULL);
267
268 zsock_t *client = zsock_new (ZMQ_DEALER);
269 assert (client);
270 zsock_set_rcvtimeo (client, 2000);
271 int rc = zsock_connect (client, "inproc://zgossip");
272 assert (rc == 0);
273
274 // Send HELLO, which gets no message
275 zgossip_msg_t *message = zgossip_msg_new ();
276 zgossip_msg_set_id (message, ZGOSSIP_MSG_HELLO);
277 zgossip_msg_send (message, client);
278
279 // Send PING, expect PONG back
280 zgossip_msg_set_id (message, ZGOSSIP_MSG_PING);
281 zgossip_msg_send (message, client);
282 zgossip_msg_recv (message, client);
283 assert (zgossip_msg_id (message) == ZGOSSIP_MSG_PONG);
284 zgossip_msg_destroy (&message);
285
286 zactor_destroy (&server);
287 zsock_destroy (&client);
288
289 // Test peer\-to\-peer operations
290 zactor_t *base = zactor_new (zgossip, "base");
291 assert (base);
292 if (verbose)
293 zstr_send (base, "VERBOSE");
294 // Set a 100msec timeout on clients so we can test expiry
295 zstr_sendx (base, "SET", "server/timeout", "100", NULL);
296 zstr_sendx (base, "BIND", "inproc://base", NULL);
297
298 zactor_t *alpha = zactor_new (zgossip, "alpha");
299 assert (alpha);
300 zstr_sendx (alpha, "CONNECT", "inproc://base", NULL);
301 zstr_sendx (alpha, "PUBLISH", "inproc://alpha\-1", "service1", NULL);
302 zstr_sendx (alpha, "PUBLISH", "inproc://alpha\-2", "service2", NULL);
303
304 zactor_t *beta = zactor_new (zgossip, "beta");
305 assert (beta);
306 zstr_sendx (beta, "CONNECT", "inproc://base", NULL);
307 zstr_sendx (beta, "PUBLISH", "inproc://beta\-1", "service1", NULL);
308 zstr_sendx (beta, "PUBLISH", "inproc://beta\-2", "service2", NULL);
309
310 // got nothing
311 zclock_sleep (200);
312
313 zactor_destroy (&base);
314 zactor_destroy (&alpha);
315 zactor_destroy (&beta);
316 .fi
317 .if n \{\
318 .RE
319 .\}
320 .sp
321 .SH "AUTHORS"
322 .sp
323 The czmq manual was written by the authors in the AUTHORS file\&.
324 .SH "RESOURCES"
325 .sp
326 Main web site: \m[blue]\fB\%\fR\m[]
327 .sp
328 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
329 .SH "COPYRIGHT"
330 .sp
331 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
332 .SH "NOTES"
333 .IP " 1." 4
334 zeromq-dev@lists.zeromq.org
335 .RS 4
336 \%mailto:zeromq-dev@lists.zeromq.org
337 .RE
6363 // Self test of this class
6464 CZMQ_EXPORT void
6565 zgossip_test (bool verbose);
66 Please add '@interface' section in './../src/zgossip.c'.
6667 ----
6768
6869 DESCRIPTION
0 '\" t
1 .\" Title: zhash
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZHASH" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zhash \- simple generic hash container
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // Callback function for zhash_freefn method
37 typedef void (zhash_free_fn) (
38 void *data);
39
40 // Create a new, empty hash container
41 CZMQ_EXPORT zhash_t *
42 zhash_new (void);
43
44 // Unpack binary frame into a new hash table\&. Packed data must follow format
45 // defined by zhash_pack\&. Hash table is set to autofree\&. An empty frame
46 // unpacks to an empty hash table\&.
47 CZMQ_EXPORT zhash_t *
48 zhash_unpack (zframe_t *frame);
49
50 // Destroy a hash container and all items in it
51 CZMQ_EXPORT void
52 zhash_destroy (zhash_t **self_p);
53
54 // Insert item into hash table with specified key and item\&.
55 // If key is already present returns \-1 and leaves existing item unchanged
56 // Returns 0 on success\&.
57 CZMQ_EXPORT int
58 zhash_insert (zhash_t *self, const char *key, void *item);
59
60 // Update item into hash table with specified key and item\&.
61 // If key is already present, destroys old item and inserts new one\&.
62 // Use free_fn method to ensure deallocator is properly called on item\&.
63 CZMQ_EXPORT void
64 zhash_update (zhash_t *self, const char *key, void *item);
65
66 // Remove an item specified by key from the hash table\&. If there was no such
67 // item, this function does nothing\&.
68 CZMQ_EXPORT void
69 zhash_delete (zhash_t *self, const char *key);
70
71 // Return the item at the specified key, or null
72 CZMQ_EXPORT void *
73 zhash_lookup (zhash_t *self, const char *key);
74
75 // Reindexes an item from an old key to a new key\&. If there was no such
76 // item, does nothing\&. Returns 0 if successful, else \-1\&.
77 CZMQ_EXPORT int
78 zhash_rename (zhash_t *self, const char *old_key, const char *new_key);
79
80 // Set a free function for the specified hash table item\&. When the item is
81 // destroyed, the free function, if any, is called on that item\&.
82 // Use this when hash items are dynamically allocated, to ensure that
83 // you don\*(Aqt have memory leaks\&. You can pass \*(Aqfree\*(Aq or NULL as a free_fn\&.
84 // Returns the item, or NULL if there is no such item\&.
85 CZMQ_EXPORT void *
86 zhash_freefn (zhash_t *self, const char *key, zhash_free_fn free_fn);
87
88 // Return the number of keys/items in the hash table
89 CZMQ_EXPORT size_t
90 zhash_size (zhash_t *self);
91
92 // Make copy of hash table; if supplied table is null, returns null\&.
93 // Does not copy items themselves\&. Rebuilds new table so may be slow on
94 // very large tables\&. NOTE: only works with item values that are strings
95 // since there\*(Aqs no other way to know how to duplicate the item value\&.
96 // Caller owns return value and must destroy it when done\&.
97 CZMQ_EXPORT zhash_t *
98 zhash_dup (zhash_t *self);
99
100 // Return keys for items in table
101 // Caller owns return value and must destroy it when done\&.
102 CZMQ_EXPORT zlist_t *
103 zhash_keys (zhash_t *self);
104
105 // Simple iterator; returns first item in hash table, in no given order,
106 // or NULL if the table is empty\&. This method is simpler to use than the
107 // foreach() method, which is deprecated\&. To access the key for this item
108 // use zhash_cursor()\&. NOTE: do NOT modify the table while iterating\&.
109 CZMQ_EXPORT void *
110 zhash_first (zhash_t *self);
111
112 // Simple iterator; returns next item in hash table, in no given order,
113 // or NULL if the last item was already returned\&. Use this together with
114 // zhash_first() to process all items in a hash table\&. If you need the
115 // items in sorted order, use zhash_keys() and then zlist_sort()\&. To
116 // access the key for this item use zhash_cursor()\&. NOTE: do NOT modify
117 // the table while iterating\&.
118 CZMQ_EXPORT void *
119 zhash_next (zhash_t *self);
120
121 // After a successful first/next method, returns the key for the item that
122 // was returned\&. This is a constant string that you may not modify or
123 // deallocate, and which lasts as long as the item in the hash\&. After an
124 // unsuccessful first/next, returns NULL\&.
125 CZMQ_EXPORT const char *
126 zhash_cursor (zhash_t *self);
127
128 // Add a comment to hash table before saving to disk\&. You can add as many
129 // comment lines as you like\&. These comment lines are discarded when loading
130 // the file\&. If you use a null format, all comments are deleted\&.
131 CZMQ_EXPORT void
132 zhash_comment (zhash_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2);
133
134 // Serialize hash table to a binary frame that can be sent in a message\&.
135 // The packed format is compatible with the \*(Aqdictionary\*(Aq type defined in
136 // http://rfc\&.zeromq\&.org/spec:35/FILEMQ, and implemented by zproto:
137 //
138 // ; A list of name/value pairs
139 // dictionary = dict\-count *( dict\-name dict\-value )
140 // dict\-count = number\-4
141 // dict\-value = longstr
142 // dict\-name = string
143 //
144 // ; Strings are always length + text contents
145 // longstr = number\-4 *VCHAR
146 // string = number\-1 *VCHAR
147 //
148 // ; Numbers are unsigned integers in network byte order
149 // number\-1 = 1OCTET
150 // number\-4 = 4OCTET
151 //
152 // Comments are not included in the packed data\&. Item values MUST be
153 // strings\&.
154 // Caller owns return value and must destroy it when done\&.
155 CZMQ_EXPORT zframe_t *
156 zhash_pack (zhash_t *self);
157
158 // Save hash table to a text file in name=value format\&. Hash values must be
159 // printable strings; keys may not contain \*(Aq=\*(Aq character\&. Returns 0 if OK,
160 // else \-1 if a file error occurred\&.
161 CZMQ_EXPORT int
162 zhash_save (zhash_t *self, const char *filename);
163
164 // Load hash table from a text file in name=value format; hash table must
165 // already exist\&. Hash values must printable strings; keys may not contain
166 // \*(Aq=\*(Aq character\&. Returns 0 if OK, else \-1 if a file was not readable\&.
167 CZMQ_EXPORT int
168 zhash_load (zhash_t *self, const char *filename);
169
170 // When a hash table was loaded from a file by zhash_load, this method will
171 // reload the file if it has been modified since, and is "stable", i\&.e\&. not
172 // still changing\&. Returns 0 if OK, \-1 if there was an error reloading the
173 // file\&.
174 CZMQ_EXPORT int
175 zhash_refresh (zhash_t *self);
176
177 // Set hash for automatic value destruction
178 CZMQ_EXPORT void
179 zhash_autofree (zhash_t *self);
180
181 // Self test of this class\&.
182 CZMQ_EXPORT void
183 zhash_test (bool verbose);
184
185 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zhash\&.c\*(Aq\&.
186 .fi
187 .SH "DESCRIPTION"
188 .sp
189 zhash is an expandable hash table container\&. This is a simple container\&. For heavy\-duty applications we recommend using zhashx\&.
190 .sp
191 Note that it\(cqs relatively slow (50K insertions/deletes per second), so don\(cqt do inserts/updates on the critical path for message I/O\&. It can do 2\&.5M lookups per second for 16\-char keys\&. Timed on a 1\&.6GHz CPU\&.
192 .SH "EXAMPLE"
193 .PP
194 \fBFrom zhash_test method\fR.
195 .sp
196 .if n \{\
197 .RS 4
198 .\}
199 .nf
200 zhash_t *hash = zhash_new ();
201 assert (hash);
202 assert (zhash_size (hash) == 0);
203 assert (zhash_first (hash) == NULL);
204 assert (zhash_cursor (hash) == NULL);
205
206 // Insert some items
207 int rc;
208 rc = zhash_insert (hash, "DEADBEEF", "dead beef");
209 char *item = (char *) zhash_first (hash);
210 assert (streq (zhash_cursor (hash), "DEADBEEF"));
211 assert (streq (item, "dead beef"));
212 assert (rc == 0);
213 rc = zhash_insert (hash, "ABADCAFE", "a bad cafe");
214 assert (rc == 0);
215 rc = zhash_insert (hash, "C0DEDBAD", "coded bad");
216 assert (rc == 0);
217 rc = zhash_insert (hash, "DEADF00D", "dead food");
218 assert (rc == 0);
219 assert (zhash_size (hash) == 4);
220
221 // Look for existing items
222 item = (char *) zhash_lookup (hash, "DEADBEEF");
223 assert (streq (item, "dead beef"));
224 item = (char *) zhash_lookup (hash, "ABADCAFE");
225 assert (streq (item, "a bad cafe"));
226 item = (char *) zhash_lookup (hash, "C0DEDBAD");
227 assert (streq (item, "coded bad"));
228 item = (char *) zhash_lookup (hash, "DEADF00D");
229 assert (streq (item, "dead food"));
230
231 // Look for non\-existent items
232 item = (char *) zhash_lookup (hash, "foo");
233 assert (item == NULL);
234
235 // Try to insert duplicate items
236 rc = zhash_insert (hash, "DEADBEEF", "foo");
237 assert (rc == \-1);
238 item = (char *) zhash_lookup (hash, "DEADBEEF");
239 assert (streq (item, "dead beef"));
240
241 // Some rename tests
242
243 // Valid rename, key is now LIVEBEEF
244 rc = zhash_rename (hash, "DEADBEEF", "LIVEBEEF");
245 assert (rc == 0);
246 item = (char *) zhash_lookup (hash, "LIVEBEEF");
247 assert (streq (item, "dead beef"));
248
249 // Trying to rename an unknown item to a non\-existent key
250 rc = zhash_rename (hash, "WHATBEEF", "NONESUCH");
251 assert (rc == \-1);
252
253 // Trying to rename an unknown item to an existing key
254 rc = zhash_rename (hash, "WHATBEEF", "LIVEBEEF");
255 assert (rc == \-1);
256 item = (char *) zhash_lookup (hash, "LIVEBEEF");
257 assert (streq (item, "dead beef"));
258
259 // Trying to rename an existing item to another existing item
260 rc = zhash_rename (hash, "LIVEBEEF", "ABADCAFE");
261 assert (rc == \-1);
262 item = (char *) zhash_lookup (hash, "LIVEBEEF");
263 assert (streq (item, "dead beef"));
264 item = (char *) zhash_lookup (hash, "ABADCAFE");
265 assert (streq (item, "a bad cafe"));
266
267 // Test keys method
268 zlist_t *keys = zhash_keys (hash);
269 assert (zlist_size (keys) == 4);
270 zlist_destroy (&keys);
271
272 // Test dup method
273 zhash_t *copy = zhash_dup (hash);
274 assert (zhash_size (copy) == 4);
275 item = (char *) zhash_lookup (copy, "LIVEBEEF");
276 assert (item);
277 assert (streq (item, "dead beef"));
278 zhash_destroy (&copy);
279
280 // Test pack/unpack methods
281 zframe_t *frame = zhash_pack (hash);
282 copy = zhash_unpack (frame);
283 zframe_destroy (&frame);
284 assert (zhash_size (copy) == 4);
285 item = (char *) zhash_lookup (copy, "LIVEBEEF");
286 assert (item);
287 assert (streq (item, "dead beef"));
288 zhash_destroy (&copy);
289
290 // Test save and load
291 zhash_comment (hash, "This is a test file");
292 zhash_comment (hash, "Created by %s", "czmq_selftest");
293 zhash_save (hash, "\&.cache");
294 copy = zhash_new ();
295 assert (copy);
296 zhash_load (copy, "\&.cache");
297 item = (char *) zhash_lookup (copy, "LIVEBEEF");
298 assert (item);
299 assert (streq (item, "dead beef"));
300 zhash_destroy (&copy);
301 zsys_file_delete ("\&.cache");
302
303 // Delete a item
304 zhash_delete (hash, "LIVEBEEF");
305 item = (char *) zhash_lookup (hash, "LIVEBEEF");
306 assert (item == NULL);
307 assert (zhash_size (hash) == 3);
308
309 // Check that the queue is robust against random usage
310 struct {
311 char name [100];
312 bool exists;
313 } testset [200];
314 memset (testset, 0, sizeof (testset));
315 int testmax = 200, testnbr, iteration;
316
317 srandom ((unsigned) time (NULL));
318 for (iteration = 0; iteration < 25000; iteration++) {
319 testnbr = randof (testmax);
320 assert (testnbr != testmax);
321 assert (testnbr < testmax);
322 if (testset [testnbr]\&.exists) {
323 item = (char *) zhash_lookup (hash, testset [testnbr]\&.name);
324 assert (item);
325 zhash_delete (hash, testset [testnbr]\&.name);
326 testset [testnbr]\&.exists = false;
327 }
328 else {
329 sprintf (testset [testnbr]\&.name, "%x\-%x", rand (), rand ());
330 if (zhash_insert (hash, testset [testnbr]\&.name, "") == 0)
331 testset [testnbr]\&.exists = true;
332 }
333 }
334 // Test 10K lookups
335 for (iteration = 0; iteration < 10000; iteration++)
336 item = (char *) zhash_lookup (hash, "DEADBEEFABADCAFE");
337
338 // Destructor should be safe to call twice
339 zhash_destroy (&hash);
340 zhash_destroy (&hash);
341 assert (hash == NULL);
342
343 // Test autofree; automatically copies and frees string values
344 hash = zhash_new ();
345 assert (hash);
346 zhash_autofree (hash);
347 char value [255];
348 strcpy (value, "This is a string");
349 rc = zhash_insert (hash, "key1", value);
350 assert (rc == 0);
351 strcpy (value, "Inserting with the same key will fail");
352 rc = zhash_insert (hash, "key1", value);
353 assert (rc == \-1);
354 strcpy (value, "Ring a ding ding");
355 rc = zhash_insert (hash, "key2", value);
356 assert (rc == 0);
357 assert (streq ((char *) zhash_lookup (hash, "key1"), "This is a string"));
358 assert (streq ((char *) zhash_lookup (hash, "key2"), "Ring a ding ding"));
359 zhash_destroy (&hash);
360 .fi
361 .if n \{\
362 .RE
363 .\}
364 .sp
365 .SH "AUTHORS"
366 .sp
367 The czmq manual was written by the authors in the AUTHORS file\&.
368 .SH "RESOURCES"
369 .sp
370 Main web site: \m[blue]\fB\%\fR\m[]
371 .sp
372 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
373 .SH "COPYRIGHT"
374 .sp
375 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
376 .SH "NOTES"
377 .IP " 1." 4
378 zeromq-dev@lists.zeromq.org
379 .RS 4
380 \%mailto:zeromq-dev@lists.zeromq.org
381 .RE
158158 CZMQ_EXPORT void
159159 zhash_test (bool verbose);
160160
161 Please add '@interface' section in './../src/zhash.c'.
161162 ----
162163
163164 DESCRIPTION
294295 srandom ((unsigned) time (NULL));
295296 for (iteration = 0; iteration < 25000; iteration++) {
296297 testnbr = randof (testmax);
298 assert (testnbr != testmax);
299 assert (testnbr < testmax);
297300 if (testset [testnbr].exists) {
298301 item = (char *) zhash_lookup (hash, testset [testnbr].name);
299302 assert (item);
0 '\" t
1 .\" Title: zhashx
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZHASHX" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zhashx \- extended generic hash container
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // This class has draft methods, which may change over time\&. They are not
37 // in stable releases, by default\&. Use \-\-enable\-drafts to enable\&.
38 // Destroy an item
39 typedef void (zhashx_destructor_fn) (
40 void **item);
41
42 // Duplicate an item
43 typedef void * (zhashx_duplicator_fn) (
44 const void *item);
45
46 // Compare two items, for sorting
47 typedef int (zhashx_comparator_fn) (
48 const void *item1, const void *item2);
49
50 // compare two items, for sorting
51 typedef void (zhashx_free_fn) (
52 void *data);
53
54 // compare two items, for sorting
55 typedef size_t (zhashx_hash_fn) (
56 const void *key);
57
58 // Serializes an item to a longstr\&.
59 // The caller takes ownership of the newly created object\&.
60 typedef char * (zhashx_serializer_fn) (
61 const void *item);
62
63 // Deserializes a longstr into an item\&.
64 // The caller takes ownership of the newly created object\&.
65 typedef void * (zhashx_deserializer_fn) (
66 const char *item_str);
67
68 // Create a new, empty hash container
69 CZMQ_EXPORT zhashx_t *
70 zhashx_new (void);
71
72 // Unpack binary frame into a new hash table\&. Packed data must follow format
73 // defined by zhashx_pack\&. Hash table is set to autofree\&. An empty frame
74 // unpacks to an empty hash table\&.
75 CZMQ_EXPORT zhashx_t *
76 zhashx_unpack (zframe_t *frame);
77
78 // Destroy a hash container and all items in it
79 CZMQ_EXPORT void
80 zhashx_destroy (zhashx_t **self_p);
81
82 // Insert item into hash table with specified key and item\&.
83 // If key is already present returns \-1 and leaves existing item unchanged
84 // Returns 0 on success\&.
85 CZMQ_EXPORT int
86 zhashx_insert (zhashx_t *self, const void *key, void *item);
87
88 // Update or insert item into hash table with specified key and item\&. If the
89 // key is already present, destroys old item and inserts new one\&. If you set
90 // a container item destructor, this is called on the old value\&. If the key
91 // was not already present, inserts a new item\&. Sets the hash cursor to the
92 // new item\&.
93 CZMQ_EXPORT void
94 zhashx_update (zhashx_t *self, const void *key, void *item);
95
96 // Remove an item specified by key from the hash table\&. If there was no such
97 // item, this function does nothing\&.
98 CZMQ_EXPORT void
99 zhashx_delete (zhashx_t *self, const void *key);
100
101 // Delete all items from the hash table\&. If the key destructor is
102 // set, calls it on every key\&. If the item destructor is set, calls
103 // it on every item\&.
104 CZMQ_EXPORT void
105 zhashx_purge (zhashx_t *self);
106
107 // Return the item at the specified key, or null
108 CZMQ_EXPORT void *
109 zhashx_lookup (zhashx_t *self, const void *key);
110
111 // Reindexes an item from an old key to a new key\&. If there was no such
112 // item, does nothing\&. Returns 0 if successful, else \-1\&.
113 CZMQ_EXPORT int
114 zhashx_rename (zhashx_t *self, const void *old_key, const void *new_key);
115
116 // Set a free function for the specified hash table item\&. When the item is
117 // destroyed, the free function, if any, is called on that item\&.
118 // Use this when hash items are dynamically allocated, to ensure that
119 // you don\*(Aqt have memory leaks\&. You can pass \*(Aqfree\*(Aq or NULL as a free_fn\&.
120 // Returns the item, or NULL if there is no such item\&.
121 CZMQ_EXPORT void *
122 zhashx_freefn (zhashx_t *self, const void *key, zhashx_free_fn free_fn);
123
124 // Return the number of keys/items in the hash table
125 CZMQ_EXPORT size_t
126 zhashx_size (zhashx_t *self);
127
128 // Return a zlistx_t containing the keys for the items in the
129 // table\&. Uses the key_duplicator to duplicate all keys and sets the
130 // key_destructor as destructor for the list\&.
131 // Caller owns return value and must destroy it when done\&.
132 CZMQ_EXPORT zlistx_t *
133 zhashx_keys (zhashx_t *self);
134
135 // Return a zlistx_t containing the values for the items in the
136 // table\&. Uses the duplicator to duplicate all items and sets the
137 // destructor as destructor for the list\&.
138 // Caller owns return value and must destroy it when done\&.
139 CZMQ_EXPORT zlistx_t *
140 zhashx_values (zhashx_t *self);
141
142 // Simple iterator; returns first item in hash table, in no given order,
143 // or NULL if the table is empty\&. This method is simpler to use than the
144 // foreach() method, which is deprecated\&. To access the key for this item
145 // use zhashx_cursor()\&. NOTE: do NOT modify the table while iterating\&.
146 CZMQ_EXPORT void *
147 zhashx_first (zhashx_t *self);
148
149 // Simple iterator; returns next item in hash table, in no given order,
150 // or NULL if the last item was already returned\&. Use this together with
151 // zhashx_first() to process all items in a hash table\&. If you need the
152 // items in sorted order, use zhashx_keys() and then zlistx_sort()\&. To
153 // access the key for this item use zhashx_cursor()\&. NOTE: do NOT modify
154 // the table while iterating\&.
155 CZMQ_EXPORT void *
156 zhashx_next (zhashx_t *self);
157
158 // After a successful first/next method, returns the key for the item that
159 // was returned\&. This is a constant string that you may not modify or
160 // deallocate, and which lasts as long as the item in the hash\&. After an
161 // unsuccessful first/next, returns NULL\&.
162 CZMQ_EXPORT const void *
163 zhashx_cursor (zhashx_t *self);
164
165 // Add a comment to hash table before saving to disk\&. You can add as many
166 // comment lines as you like\&. These comment lines are discarded when loading
167 // the file\&. If you use a null format, all comments are deleted\&.
168 CZMQ_EXPORT void
169 zhashx_comment (zhashx_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2);
170
171 // Save hash table to a text file in name=value format\&. Hash values must be
172 // printable strings; keys may not contain \*(Aq=\*(Aq character\&. Returns 0 if OK,
173 // else \-1 if a file error occurred\&.
174 CZMQ_EXPORT int
175 zhashx_save (zhashx_t *self, const char *filename);
176
177 // Load hash table from a text file in name=value format; hash table must
178 // already exist\&. Hash values must printable strings; keys may not contain
179 // \*(Aq=\*(Aq character\&. Returns 0 if OK, else \-1 if a file was not readable\&.
180 CZMQ_EXPORT int
181 zhashx_load (zhashx_t *self, const char *filename);
182
183 // When a hash table was loaded from a file by zhashx_load, this method will
184 // reload the file if it has been modified since, and is "stable", i\&.e\&. not
185 // still changing\&. Returns 0 if OK, \-1 if there was an error reloading the
186 // file\&.
187 CZMQ_EXPORT int
188 zhashx_refresh (zhashx_t *self);
189
190 // Serialize hash table to a binary frame that can be sent in a message\&.
191 // The packed format is compatible with the \*(Aqdictionary\*(Aq type defined in
192 // http://rfc\&.zeromq\&.org/spec:35/FILEMQ, and implemented by zproto:
193 //
194 // ; A list of name/value pairs
195 // dictionary = dict\-count *( dict\-name dict\-value )
196 // dict\-count = number\-4
197 // dict\-value = longstr
198 // dict\-name = string
199 //
200 // ; Strings are always length + text contents
201 // longstr = number\-4 *VCHAR
202 // string = number\-1 *VCHAR
203 //
204 // ; Numbers are unsigned integers in network byte order
205 // number\-1 = 1OCTET
206 // number\-4 = 4OCTET
207 //
208 // Comments are not included in the packed data\&. Item values MUST be
209 // strings\&.
210 // Caller owns return value and must destroy it when done\&.
211 CZMQ_EXPORT zframe_t *
212 zhashx_pack (zhashx_t *self);
213
214 // Make a copy of the list; items are duplicated if you set a duplicator
215 // for the list, otherwise not\&. Copying a null reference returns a null
216 // reference\&. Note that this method\*(Aqs behavior changed slightly for CZMQ
217 // v3\&.x, as it does not set nor respect autofree\&. It does however let you
218 // duplicate any hash table safely\&. The old behavior is in zhashx_dup_v2\&.
219 // Caller owns return value and must destroy it when done\&.
220 CZMQ_EXPORT zhashx_t *
221 zhashx_dup (zhashx_t *self);
222
223 // Set a user\-defined deallocator for hash items; by default items are not
224 // freed when the hash is destroyed\&.
225 CZMQ_EXPORT void
226 zhashx_set_destructor (zhashx_t *self, zhashx_destructor_fn destructor);
227
228 // Set a user\-defined duplicator for hash items; by default items are not
229 // copied when the hash is duplicated\&.
230 CZMQ_EXPORT void
231 zhashx_set_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator);
232
233 // Set a user\-defined deallocator for keys; by default keys are freed
234 // when the hash is destroyed using free()\&.
235 CZMQ_EXPORT void
236 zhashx_set_key_destructor (zhashx_t *self, zhashx_destructor_fn destructor);
237
238 // Set a user\-defined duplicator for keys; by default keys are duplicated
239 // using strdup\&.
240 CZMQ_EXPORT void
241 zhashx_set_key_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator);
242
243 // Set a user\-defined comparator for keys; by default keys are
244 // compared using strcmp\&.
245 CZMQ_EXPORT void
246 zhashx_set_key_comparator (zhashx_t *self, zhashx_comparator_fn comparator);
247
248 // Set a user\-defined comparator for keys; by default keys are
249 // compared using strcmp\&.
250 CZMQ_EXPORT void
251 zhashx_set_key_hasher (zhashx_t *self, zhashx_hash_fn hasher);
252
253 // Make copy of hash table; if supplied table is null, returns null\&.
254 // Does not copy items themselves\&. Rebuilds new table so may be slow on
255 // very large tables\&. NOTE: only works with item values that are strings
256 // since there\*(Aqs no other way to know how to duplicate the item value\&.
257 CZMQ_EXPORT zhashx_t *
258 zhashx_dup_v2 (zhashx_t *self);
259
260 // Self test of this class\&.
261 CZMQ_EXPORT void
262 zhashx_test (bool verbose);
263
264 #ifdef CZMQ_BUILD_DRAFT_API
265 // *** Draft method, for development use, may change without warning ***
266 // Same as unpack but uses a user\-defined deserializer function to convert
267 // a longstr back into item format\&.
268 CZMQ_EXPORT zhashx_t *
269 zhashx_unpack_own (zframe_t *frame, zhashx_deserializer_fn deserializer);
270
271 // *** Draft method, for development use, may change without warning ***
272 // Same as pack but uses a user\-defined serializer function to convert items
273 // into longstr\&.
274 // Caller owns return value and must destroy it when done\&.
275 CZMQ_EXPORT zframe_t *
276 zhashx_pack_own (zhashx_t *self, zhashx_serializer_fn serializer);
277
278 #endif // CZMQ_BUILD_DRAFT_API
279 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zhashx\&.c\*(Aq\&.
280 .fi
281 .SH "DESCRIPTION"
282 .sp
283 zhashx is an extended hash table container with more functionality than zhash, its simpler cousin\&.
284 .sp
285 The hash table always has a size that is prime and roughly doubles its size when 75% full\&. In case of hash collisions items are chained in a linked list\&. The hash table size is increased slightly (up to 5 times before roughly doubling the size) when an overly long chain (between 1 and 63 items depending on table size) is detected\&.
286 .SH "EXAMPLE"
287 .PP
288 \fBFrom zhashx_test method\fR.
289 .sp
290 .if n \{\
291 .RS 4
292 .\}
293 .nf
294 zhashx_t *hash = zhashx_new ();
295 assert (hash);
296 assert (zhashx_size (hash) == 0);
297 assert (zhashx_first (hash) == NULL);
298 assert (zhashx_cursor (hash) == NULL);
299
300 // Insert some items
301 int rc;
302 rc = zhashx_insert (hash, "DEADBEEF", "dead beef");
303 char *item = (char *) zhashx_first (hash);
304 assert (streq ((char *) zhashx_cursor (hash), "DEADBEEF"));
305 assert (streq (item, "dead beef"));
306 assert (rc == 0);
307 rc = zhashx_insert (hash, "ABADCAFE", "a bad cafe");
308 assert (rc == 0);
309 rc = zhashx_insert (hash, "C0DEDBAD", "coded bad");
310 assert (rc == 0);
311 rc = zhashx_insert (hash, "DEADF00D", "dead food");
312 assert (rc == 0);
313 assert (zhashx_size (hash) == 4);
314
315 // Look for existing items
316 item = (char *) zhashx_lookup (hash, "DEADBEEF");
317 assert (streq (item, "dead beef"));
318 item = (char *) zhashx_lookup (hash, "ABADCAFE");
319 assert (streq (item, "a bad cafe"));
320 item = (char *) zhashx_lookup (hash, "C0DEDBAD");
321 assert (streq (item, "coded bad"));
322 item = (char *) zhashx_lookup (hash, "DEADF00D");
323 assert (streq (item, "dead food"));
324
325 // Look for non\-existent items
326 item = (char *) zhashx_lookup (hash, "foo");
327 assert (item == NULL);
328
329 // Try to insert duplicate items
330 rc = zhashx_insert (hash, "DEADBEEF", "foo");
331 assert (rc == \-1);
332 item = (char *) zhashx_lookup (hash, "DEADBEEF");
333 assert (streq (item, "dead beef"));
334
335 // Some rename tests
336
337 // Valid rename, key is now LIVEBEEF
338 rc = zhashx_rename (hash, "DEADBEEF", "LIVEBEEF");
339 assert (rc == 0);
340 item = (char *) zhashx_lookup (hash, "LIVEBEEF");
341 assert (streq (item, "dead beef"));
342
343 // Trying to rename an unknown item to a non\-existent key
344 rc = zhashx_rename (hash, "WHATBEEF", "NONESUCH");
345 assert (rc == \-1);
346
347 // Trying to rename an unknown item to an existing key
348 rc = zhashx_rename (hash, "WHATBEEF", "LIVEBEEF");
349 assert (rc == \-1);
350 item = (char *) zhashx_lookup (hash, "LIVEBEEF");
351 assert (streq (item, "dead beef"));
352
353 // Trying to rename an existing item to another existing item
354 rc = zhashx_rename (hash, "LIVEBEEF", "ABADCAFE");
355 assert (rc == \-1);
356 item = (char *) zhashx_lookup (hash, "LIVEBEEF");
357 assert (streq (item, "dead beef"));
358 item = (char *) zhashx_lookup (hash, "ABADCAFE");
359 assert (streq (item, "a bad cafe"));
360
361 // Test keys method
362 zlistx_t *keys = zhashx_keys (hash);
363 assert (zlistx_size (keys) == 4);
364 zlistx_destroy (&keys);
365
366 zlistx_t *values = zhashx_values(hash);
367 assert (zlistx_size (values) == 4);
368 zlistx_destroy (&values);
369
370 // Test dup method
371 zhashx_t *copy = zhashx_dup (hash);
372 assert (zhashx_size (copy) == 4);
373 item = (char *) zhashx_lookup (copy, "LIVEBEEF");
374 assert (item);
375 assert (streq (item, "dead beef"));
376 zhashx_destroy (&copy);
377
378 // Test pack/unpack methods
379 zframe_t *frame = zhashx_pack (hash);
380 copy = zhashx_unpack (frame);
381 zframe_destroy (&frame);
382 assert (zhashx_size (copy) == 4);
383 item = (char *) zhashx_lookup (copy, "LIVEBEEF");
384 assert (item);
385 assert (streq (item, "dead beef"));
386 zhashx_destroy (&copy);
387
388 #ifdef CZMQ_BUILD_DRAFT_API
389 // Test own pack/unpack methods
390 zhashx_t *own_hash = zhashx_new ();
391 zhashx_set_destructor (own_hash, s_test_destroy_int);
392 assert (own_hash);
393 int *val1 = (int *) zmalloc (sizeof (int));
394 int *val2 = (int *) zmalloc (sizeof (int));
395 *val1 = 25;
396 *val2 = 100;
397 zhashx_insert (own_hash, "val1", val1);
398 zhashx_insert (own_hash, "val2", val2);
399 frame = zhashx_pack_own (own_hash, s_test_serialize_int);
400 copy = zhashx_unpack_own (frame, s_test_deserialze_int);
401 zhashx_set_destructor (copy, s_test_destroy_int);
402 zframe_destroy (&frame);
403 assert (zhashx_size (copy) == 2);
404 assert (*((int *) zhashx_lookup (copy, "val1")) == 25);
405 assert (*((int *) zhashx_lookup (copy, "val2")) == 100);
406 zhashx_destroy (&copy);
407 zhashx_destroy (&own_hash);
408 #endif // CZMQ_BUILD_DRAFT_API
409
410 // Test save and load
411 zhashx_comment (hash, "This is a test file");
412 zhashx_comment (hash, "Created by %s", "czmq_selftest");
413 zhashx_save (hash, "\&.cache");
414 copy = zhashx_new ();
415 assert (copy);
416 zhashx_load (copy, "\&.cache");
417 item = (char *) zhashx_lookup (copy, "LIVEBEEF");
418 assert (item);
419 assert (streq (item, "dead beef"));
420 zhashx_destroy (&copy);
421 zsys_file_delete ("\&.cache");
422
423 // Delete a item
424 zhashx_delete (hash, "LIVEBEEF");
425 item = (char *) zhashx_lookup (hash, "LIVEBEEF");
426 assert (item == NULL);
427 assert (zhashx_size (hash) == 3);
428
429 // Check that the queue is robust against random usage
430 struct {
431 char name [100];
432 bool exists;
433 } testset [200];
434 memset (testset, 0, sizeof (testset));
435 int testmax = 200, testnbr, iteration;
436
437 srandom ((unsigned) time (NULL));
438 for (iteration = 0; iteration < 25000; iteration++) {
439 testnbr = randof (testmax);
440 if (testset [testnbr]\&.exists) {
441 item = (char *) zhashx_lookup (hash, testset [testnbr]\&.name);
442 assert (item);
443 zhashx_delete (hash, testset [testnbr]\&.name);
444 testset [testnbr]\&.exists = false;
445 }
446 else {
447 sprintf (testset [testnbr]\&.name, "%x\-%x", rand (), rand ());
448 if (zhashx_insert (hash, testset [testnbr]\&.name, "") == 0)
449 testset [testnbr]\&.exists = true;
450 }
451 }
452 // Test 10K lookups
453 for (iteration = 0; iteration < 10000; iteration++)
454 item = (char *) zhashx_lookup (hash, "DEADBEEFABADCAFE");
455
456 // Destructor should be safe to call twice
457 zhashx_destroy (&hash);
458 zhashx_destroy (&hash);
459 assert (hash == NULL);
460
461 // Test destructor; automatically copies and frees string values
462 hash = zhashx_new ();
463 assert (hash);
464 zhashx_set_destructor (hash, (zhashx_destructor_fn *) zstr_free);
465 zhashx_set_duplicator (hash, (zhashx_duplicator_fn *) strdup);
466 char value [255];
467 strcpy (value, "This is a string");
468 rc = zhashx_insert (hash, "key1", value);
469 assert (rc == 0);
470 strcpy (value, "Ring a ding ding");
471 rc = zhashx_insert (hash, "key2", value);
472 assert (rc == 0);
473 assert (streq ((char *) zhashx_lookup (hash, "key1"), "This is a string"));
474 assert (streq ((char *) zhashx_lookup (hash, "key2"), "Ring a ding ding"));
475 zhashx_destroy (&hash);
476 .fi
477 .if n \{\
478 .RE
479 .\}
480 .sp
481 .SH "AUTHORS"
482 .sp
483 The czmq manual was written by the authors in the AUTHORS file\&.
484 .SH "RESOURCES"
485 .sp
486 Main web site: \m[blue]\fB\%\fR\m[]
487 .sp
488 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
489 .SH "COPYRIGHT"
490 .sp
491 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
492 .SH "NOTES"
493 .IP " 1." 4
494 zeromq-dev@lists.zeromq.org
495 .RS 4
496 \%mailto:zeromq-dev@lists.zeromq.org
497 .RE
252252 zhashx_pack_own (zhashx_t *self, zhashx_serializer_fn serializer);
253253
254254 #endif // CZMQ_BUILD_DRAFT_API
255 Please add '@interface' section in './../src/zhashx.c'.
255256 ----
256257
257258 DESCRIPTION
0 '\" t
1 .\" Title: ziflist
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZIFLIST" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 ziflist \- list of network interfaces available on system
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // Get a list of network interfaces currently defined on the system
37 CZMQ_EXPORT ziflist_t *
38 ziflist_new (void);
39
40 // Destroy a ziflist instance
41 CZMQ_EXPORT void
42 ziflist_destroy (ziflist_t **self_p);
43
44 // Reload network interfaces from system
45 CZMQ_EXPORT void
46 ziflist_reload (ziflist_t *self);
47
48 // Return the number of network interfaces on system
49 CZMQ_EXPORT size_t
50 ziflist_size (ziflist_t *self);
51
52 // Get first network interface, return NULL if there are none
53 CZMQ_EXPORT const char *
54 ziflist_first (ziflist_t *self);
55
56 // Get next network interface, return NULL if we hit the last one
57 CZMQ_EXPORT const char *
58 ziflist_next (ziflist_t *self);
59
60 // Return the current interface IP address as a printable string
61 CZMQ_EXPORT const char *
62 ziflist_address (ziflist_t *self);
63
64 // Return the current interface broadcast address as a printable string
65 CZMQ_EXPORT const char *
66 ziflist_broadcast (ziflist_t *self);
67
68 // Return the current interface network mask as a printable string
69 CZMQ_EXPORT const char *
70 ziflist_netmask (ziflist_t *self);
71
72 // Return the list of interfaces\&.
73 CZMQ_EXPORT void
74 ziflist_print (ziflist_t *self);
75
76 // Self test of this class\&.
77 CZMQ_EXPORT void
78 ziflist_test (bool verbose);
79
80 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/ziflist\&.c\*(Aq\&.
81 .fi
82 .SH "DESCRIPTION"
83 .sp
84 The ziflist class takes a snapshot of the network interfaces that the system currently supports (this can change arbitrarily, especially on mobile devices)\&. The caller can then access the network interface information using an iterator that works like zlistx\&. Only stores those interfaces with broadcast capability, and ignores the loopback interface\&.
85 .sp
86 Please add \fI@discuss\fR section in \fI\&./\&.\&./src/ziflist\&.c\fR\&.
87 .SH "EXAMPLE"
88 .PP
89 \fBFrom ziflist_test method\fR.
90 .sp
91 .if n \{\
92 .RS 4
93 .\}
94 .nf
95 ziflist_t *iflist = ziflist_new ();
96 assert (iflist);
97
98 size_t items = ziflist_size (iflist);
99
100 if (verbose) {
101 printf ("ziflist: interfaces=%zu\en", ziflist_size (iflist));
102 const char *name = ziflist_first (iflist);
103 while (name) {
104 printf (" \- name=%s address=%s netmask=%s broadcast=%s\en",
105 name, ziflist_address (iflist), ziflist_netmask (iflist), ziflist_broadcast (iflist));
106 name = ziflist_next (iflist);
107 }
108 }
109 ziflist_reload (iflist);
110 assert (items == ziflist_size (iflist));
111 ziflist_destroy (&iflist);
112 .fi
113 .if n \{\
114 .RE
115 .\}
116 .sp
117 .SH "AUTHORS"
118 .sp
119 The czmq manual was written by the authors in the AUTHORS file\&.
120 .SH "RESOURCES"
121 .sp
122 Main web site: \m[blue]\fB\%\fR\m[]
123 .sp
124 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
125 .SH "COPYRIGHT"
126 .sp
127 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
128 .SH "NOTES"
129 .IP " 1." 4
130 zeromq-dev@lists.zeromq.org
131 .RS 4
132 \%mailto:zeromq-dev@lists.zeromq.org
133 .RE
5353 CZMQ_EXPORT void
5454 ziflist_test (bool verbose);
5555
56 Please add '@interface' section in './../src/ziflist.c'.
5657 ----
5758
5859 DESCRIPTION
6465 information using an iterator that works like zlistx. Only stores those
6566 interfaces with broadcast capability, and ignores the loopback interface.
6667
67 Please add @discuss section in ../src/ziflist.c.
68 Please add '@discuss' section in './../src/ziflist.c'.
6869
6970 EXAMPLE
7071 -------
0 '\" t
1 .\" Title: zlist
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZLIST" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zlist \- simple generic list container
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // Comparison function e\&.g\&. for sorting and removing\&.
37 typedef int (zlist_compare_fn) (
38 void *item1, void *item2);
39
40 // Callback function for zlist_freefn method
41 typedef void (zlist_free_fn) (
42 void *data);
43
44 // Create a new list container
45 CZMQ_EXPORT zlist_t *
46 zlist_new (void);
47
48 // Destroy a list container
49 CZMQ_EXPORT void
50 zlist_destroy (zlist_t **self_p);
51
52 // Return the item at the head of list\&. If the list is empty, returns NULL\&.
53 // Leaves cursor pointing at the head item, or NULL if the list is empty\&.
54 CZMQ_EXPORT void *
55 zlist_first (zlist_t *self);
56
57 // Return the next item\&. If the list is empty, returns NULL\&. To move to
58 // the start of the list call zlist_first ()\&. Advances the cursor\&.
59 CZMQ_EXPORT void *
60 zlist_next (zlist_t *self);
61
62 // Return the item at the tail of list\&. If the list is empty, returns NULL\&.
63 // Leaves cursor pointing at the tail item, or NULL if the list is empty\&.
64 CZMQ_EXPORT void *
65 zlist_last (zlist_t *self);
66
67 // Return first item in the list, or null, leaves the cursor
68 CZMQ_EXPORT void *
69 zlist_head (zlist_t *self);
70
71 // Return last item in the list, or null, leaves the cursor
72 CZMQ_EXPORT void *
73 zlist_tail (zlist_t *self);
74
75 // Return the current item of list\&. If the list is empty, returns NULL\&.
76 // Leaves cursor pointing at the current item, or NULL if the list is empty\&.
77 CZMQ_EXPORT void *
78 zlist_item (zlist_t *self);
79
80 // Append an item to the end of the list, return 0 if OK or \-1 if this
81 // failed for some reason (out of memory)\&. Note that if a duplicator has
82 // been set, this method will also duplicate the item\&.
83 CZMQ_EXPORT int
84 zlist_append (zlist_t *self, void *item);
85
86 // Push an item to the start of the list, return 0 if OK or \-1 if this
87 // failed for some reason (out of memory)\&. Note that if a duplicator has
88 // been set, this method will also duplicate the item\&.
89 CZMQ_EXPORT int
90 zlist_push (zlist_t *self, void *item);
91
92 // Pop the item off the start of the list, if any
93 CZMQ_EXPORT void *
94 zlist_pop (zlist_t *self);
95
96 // Checks if an item already is present\&. Uses compare method to determine if
97 // items are equal\&. If the compare method is NULL the check will only compare
98 // pointers\&. Returns true if item is present else false\&.
99 CZMQ_EXPORT bool
100 zlist_exists (zlist_t *self, void *item);
101
102 // Remove the specified item from the list if present
103 CZMQ_EXPORT void
104 zlist_remove (zlist_t *self, void *item);
105
106 // Make a copy of list\&. If the list has autofree set, the copied list will
107 // duplicate all items, which must be strings\&. Otherwise, the list will hold
108 // pointers back to the items in the original list\&. If list is null, returns
109 // NULL\&.
110 // Caller owns return value and must destroy it when done\&.
111 CZMQ_EXPORT zlist_t *
112 zlist_dup (zlist_t *self);
113
114 // Purge all items from list
115 CZMQ_EXPORT void
116 zlist_purge (zlist_t *self);
117
118 // Return number of items in the list
119 CZMQ_EXPORT size_t
120 zlist_size (zlist_t *self);
121
122 // Sort the list\&. If the compare function is null, sorts the list by
123 // ascending key value using a straight ASCII comparison\&. If you specify
124 // a compare function, this decides how items are sorted\&. The sort is not
125 // stable, so may reorder items with the same keys\&. The algorithm used is
126 // combsort, a compromise between performance and simplicity\&.
127 CZMQ_EXPORT void
128 zlist_sort (zlist_t *self, zlist_compare_fn compare);
129
130 // Set list for automatic item destruction; item values MUST be strings\&.
131 // By default a list item refers to a value held elsewhere\&. When you set
132 // this, each time you append or push a list item, zlist will take a copy
133 // of the string value\&. Then, when you destroy the list, it will free all
134 // item values automatically\&. If you use any other technique to allocate
135 // list values, you must free them explicitly before destroying the list\&.
136 // The usual technique is to pop list items and destroy them, until the
137 // list is empty\&.
138 CZMQ_EXPORT void
139 zlist_autofree (zlist_t *self);
140
141 // Sets a compare function for this list\&. The function compares two items\&.
142 // It returns an integer less than, equal to, or greater than zero if the
143 // first item is found, respectively, to be less than, to match, or be
144 // greater than the second item\&.
145 // This function is used for sorting, removal and exists checking\&.
146 CZMQ_EXPORT void
147 zlist_comparefn (zlist_t *self, zlist_compare_fn fn);
148
149 // Set a free function for the specified list item\&. When the item is
150 // destroyed, the free function, if any, is called on that item\&.
151 // Use this when list items are dynamically allocated, to ensure that
152 // you don\*(Aqt have memory leaks\&. You can pass \*(Aqfree\*(Aq or NULL as a free_fn\&.
153 // Returns the item, or NULL if there is no such item\&.
154 CZMQ_EXPORT void *
155 zlist_freefn (zlist_t *self, void *item, zlist_free_fn fn, bool at_tail);
156
157 // Self test of this class\&.
158 CZMQ_EXPORT void
159 zlist_test (bool verbose);
160
161 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zlist\&.c\*(Aq\&.
162 .fi
163 .SH "DESCRIPTION"
164 .sp
165 Provides a generic container implementing a fast singly\-linked list\&. You can use this to construct multi\-dimensional lists, and other structures together with other generic containers like zhash\&. This is a simple class\&. For demanding applications we recommend using zlistx\&.
166 .sp
167 To iterate through a list, use zlist_first to get the first item, then loop while not null, and do zlist_next at the end of each iteration\&.
168 .SH "EXAMPLE"
169 .PP
170 \fBFrom zlist_test method\fR.
171 .sp
172 .if n \{\
173 .RS 4
174 .\}
175 .nf
176 zlist_t *list = zlist_new ();
177 assert (list);
178 assert (zlist_size (list) == 0);
179
180 // Three items we\*(Aqll use as test data
181 // List items are void *, not particularly strings
182 char *cheese = "boursin";
183 char *bread = "baguette";
184 char *wine = "bordeaux";
185
186 zlist_append (list, cheese);
187 assert (zlist_size (list) == 1);
188 assert ( zlist_exists (list, cheese));
189 assert (!zlist_exists (list, bread));
190 assert (!zlist_exists (list, wine));
191 zlist_append (list, bread);
192 assert (zlist_size (list) == 2);
193 assert ( zlist_exists (list, cheese));
194 assert ( zlist_exists (list, bread));
195 assert (!zlist_exists (list, wine));
196 zlist_append (list, wine);
197 assert (zlist_size (list) == 3);
198 assert ( zlist_exists (list, cheese));
199 assert ( zlist_exists (list, bread));
200 assert ( zlist_exists (list, wine));
201
202 assert (zlist_head (list) == cheese);
203 assert (zlist_next (list) == cheese);
204
205 assert (zlist_first (list) == cheese);
206 assert (zlist_tail (list) == wine);
207 assert (zlist_next (list) == bread);
208
209 assert (zlist_first (list) == cheese);
210 assert (zlist_next (list) == bread);
211 assert (zlist_next (list) == wine);
212 assert (zlist_next (list) == NULL);
213 // After we reach end of list, next wraps around
214 assert (zlist_next (list) == cheese);
215 assert (zlist_size (list) == 3);
216
217 zlist_remove (list, wine);
218 assert (zlist_size (list) == 2);
219
220 assert (zlist_first (list) == cheese);
221 zlist_remove (list, cheese);
222 assert (zlist_size (list) == 1);
223 assert (zlist_first (list) == bread);
224
225 zlist_remove (list, bread);
226 assert (zlist_size (list) == 0);
227
228 zlist_append (list, cheese);
229 zlist_append (list, bread);
230 assert (zlist_last (list) == bread);
231 zlist_remove (list, bread);
232 assert (zlist_last (list) == cheese);
233 zlist_remove (list, cheese);
234 assert (zlist_last (list) == NULL);
235
236 zlist_push (list, cheese);
237 assert (zlist_size (list) == 1);
238 assert (zlist_first (list) == cheese);
239
240 zlist_push (list, bread);
241 assert (zlist_size (list) == 2);
242 assert (zlist_first (list) == bread);
243 assert (zlist_item (list) == bread);
244
245 zlist_append (list, wine);
246 assert (zlist_size (list) == 3);
247 assert (zlist_first (list) == bread);
248
249 zlist_t *sub_list = zlist_dup (list);
250 assert (sub_list);
251 assert (zlist_size (sub_list) == 3);
252
253 zlist_sort (list, NULL);
254 char *item;
255 item = (char *) zlist_pop (list);
256 assert (item == bread);
257 item = (char *) zlist_pop (list);
258 assert (item == wine);
259 item = (char *) zlist_pop (list);
260 assert (item == cheese);
261 assert (zlist_size (list) == 0);
262
263 assert (zlist_size (sub_list) == 3);
264 zlist_push (list, sub_list);
265 zlist_t *sub_list_2 = zlist_dup (sub_list);
266 zlist_append (list, sub_list_2);
267 assert (zlist_freefn (list, sub_list, &s_zlist_free, false) == sub_list);
268 assert (zlist_freefn (list, sub_list_2, &s_zlist_free, true) == sub_list_2);
269 zlist_destroy (&list);
270
271 // Test autofree functionality
272 list = zlist_new ();
273 assert (list);
274 zlist_autofree (list);
275 // Set equals function otherwise equals will not work as autofree copies strings
276 zlist_comparefn (list, (zlist_compare_fn *) strcmp);
277 zlist_push (list, bread);
278 zlist_append (list, cheese);
279 assert (zlist_size (list) == 2);
280 zlist_append (list, wine);
281 assert (zlist_exists (list, wine));
282 zlist_remove (list, wine);
283 assert (!zlist_exists (list, wine));
284 assert (streq ((const char *) zlist_first (list), bread));
285 item = (char *) zlist_pop (list);
286 assert (streq (item, bread));
287 free (item);
288 item = (char *) zlist_pop (list);
289 assert (streq (item, cheese));
290 free (item);
291
292 zlist_destroy (&list);
293 assert (list == NULL);
294 .fi
295 .if n \{\
296 .RE
297 .\}
298 .sp
299 .SH "AUTHORS"
300 .sp
301 The czmq manual was written by the authors in the AUTHORS file\&.
302 .SH "RESOURCES"
303 .sp
304 Main web site: \m[blue]\fB\%\fR\m[]
305 .sp
306 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
307 .SH "COPYRIGHT"
308 .sp
309 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
310 .SH "NOTES"
311 .IP " 1." 4
312 zeromq-dev@lists.zeromq.org
313 .RS 4
314 \%mailto:zeromq-dev@lists.zeromq.org
315 .RE
134134 CZMQ_EXPORT void
135135 zlist_test (bool verbose);
136136
137 Please add '@interface' section in './../src/zlist.c'.
137138 ----
138139
139140 DESCRIPTION
0 '\" t
1 .\" Title: zlistx
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZLISTX" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zlistx \- extended generic list container
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // Destroy an item
37 typedef void (zlistx_destructor_fn) (
38 void **item);
39
40 // Duplicate an item
41 typedef void * (zlistx_duplicator_fn) (
42 const void *item);
43
44 // Compare two items, for sorting
45 typedef int (zlistx_comparator_fn) (
46 const void *item1, const void *item2);
47
48 // Create a new, empty list\&.
49 CZMQ_EXPORT zlistx_t *
50 zlistx_new (void);
51
52 // Destroy a list\&. If an item destructor was specified, all items in the
53 // list are automatically destroyed as well\&.
54 CZMQ_EXPORT void
55 zlistx_destroy (zlistx_t **self_p);
56
57 // Add an item to the head of the list\&. Calls the item duplicator, if any,
58 // on the item\&. Resets cursor to list head\&. Returns an item handle on
59 // success, NULL if memory was exhausted\&.
60 CZMQ_EXPORT void *
61 zlistx_add_start (zlistx_t *self, void *item);
62
63 // Add an item to the tail of the list\&. Calls the item duplicator, if any,
64 // on the item\&. Resets cursor to list head\&. Returns an item handle on
65 // success, NULL if memory was exhausted\&.
66 CZMQ_EXPORT void *
67 zlistx_add_end (zlistx_t *self, void *item);
68
69 // Return the number of items in the list
70 CZMQ_EXPORT size_t
71 zlistx_size (zlistx_t *self);
72
73 // Return first item in the list, or null, leaves the cursor
74 CZMQ_EXPORT void *
75 zlistx_head (zlistx_t *self);
76
77 // Return last item in the list, or null, leaves the cursor
78 CZMQ_EXPORT void *
79 zlistx_tail (zlistx_t *self);
80
81 // Return the item at the head of list\&. If the list is empty, returns NULL\&.
82 // Leaves cursor pointing at the head item, or NULL if the list is empty\&.
83 CZMQ_EXPORT void *
84 zlistx_first (zlistx_t *self);
85
86 // Return the next item\&. At the end of the list (or in an empty list),
87 // returns NULL\&. Use repeated zlistx_next () calls to work through the list
88 // from zlistx_first ()\&. First time, acts as zlistx_first()\&.
89 CZMQ_EXPORT void *
90 zlistx_next (zlistx_t *self);
91
92 // Return the previous item\&. At the start of the list (or in an empty list),
93 // returns NULL\&. Use repeated zlistx_prev () calls to work through the list
94 // backwards from zlistx_last ()\&. First time, acts as zlistx_last()\&.
95 CZMQ_EXPORT void *
96 zlistx_prev (zlistx_t *self);
97
98 // Return the item at the tail of list\&. If the list is empty, returns NULL\&.
99 // Leaves cursor pointing at the tail item, or NULL if the list is empty\&.
100 CZMQ_EXPORT void *
101 zlistx_last (zlistx_t *self);
102
103 // Returns the value of the item at the cursor, or NULL if the cursor is
104 // not pointing to an item\&.
105 CZMQ_EXPORT void *
106 zlistx_item (zlistx_t *self);
107
108 // Returns the handle of the item at the cursor, or NULL if the cursor is
109 // not pointing to an item\&.
110 CZMQ_EXPORT void *
111 zlistx_cursor (zlistx_t *self);
112
113 // Returns the item associated with the given list handle, or NULL if passed
114 // in handle is NULL\&. Asserts that the passed in handle points to a list element\&.
115 CZMQ_EXPORT void *
116 zlistx_handle_item (void *handle);
117
118 // Find an item in the list, searching from the start\&. Uses the item
119 // comparator, if any, else compares item values directly\&. Returns the
120 // item handle found, or NULL\&. Sets the cursor to the found item, if any\&.
121 CZMQ_EXPORT void *
122 zlistx_find (zlistx_t *self, void *item);
123
124 // Detach an item from the list, using its handle\&. The item is not modified,
125 // and the caller is responsible for destroying it if necessary\&. If handle is
126 // null, detaches the first item on the list\&. Returns item that was detached,
127 // or null if none was\&. If cursor was at item, moves cursor to previous item,
128 // so you can detach items while iterating forwards through a list\&.
129 CZMQ_EXPORT void *
130 zlistx_detach (zlistx_t *self, void *handle);
131
132 // Detach item at the cursor, if any, from the list\&. The item is not modified,
133 // and the caller is responsible for destroying it as necessary\&. Returns item
134 // that was detached, or null if none was\&. Moves cursor to previous item, so
135 // you can detach items while iterating forwards through a list\&.
136 CZMQ_EXPORT void *
137 zlistx_detach_cur (zlistx_t *self);
138
139 // Delete an item, using its handle\&. Calls the item destructor is any is
140 // set\&. If handle is null, deletes the first item on the list\&. Returns 0
141 // if an item was deleted, \-1 if not\&. If cursor was at item, moves cursor
142 // to previous item, so you can delete items while iterating forwards
143 // through a list\&.
144 CZMQ_EXPORT int
145 zlistx_delete (zlistx_t *self, void *handle);
146
147 // Move an item to the start of the list, via its handle\&.
148 CZMQ_EXPORT void
149 zlistx_move_start (zlistx_t *self, void *handle);
150
151 // Move an item to the end of the list, via its handle\&.
152 CZMQ_EXPORT void
153 zlistx_move_end (zlistx_t *self, void *handle);
154
155 // Remove all items from the list, and destroy them if the item destructor
156 // is set\&.
157 CZMQ_EXPORT void
158 zlistx_purge (zlistx_t *self);
159
160 // Sort the list\&. If an item comparator was set, calls that to compare
161 // items, otherwise compares on item value\&. The sort is not stable, so may
162 // reorder equal items\&.
163 CZMQ_EXPORT void
164 zlistx_sort (zlistx_t *self);
165
166 // Create a new node and insert it into a sorted list\&. Calls the item
167 // duplicator, if any, on the item\&. If low_value is true, starts searching
168 // from the start of the list, otherwise searches from the end\&. Use the item
169 // comparator, if any, to find where to place the new node\&. Returns a handle
170 // to the new node, or NULL if memory was exhausted\&. Resets the cursor to the
171 // list head\&.
172 CZMQ_EXPORT void *
173 zlistx_insert (zlistx_t *self, void *item, bool low_value);
174
175 // Move an item, specified by handle, into position in a sorted list\&. Uses
176 // the item comparator, if any, to determine the new location\&. If low_value
177 // is true, starts searching from the start of the list, otherwise searches
178 // from the end\&.
179 CZMQ_EXPORT void
180 zlistx_reorder (zlistx_t *self, void *handle, bool low_value);
181
182 // Make a copy of the list; items are duplicated if you set a duplicator
183 // for the list, otherwise not\&. Copying a null reference returns a null
184 // reference\&.
185 CZMQ_EXPORT zlistx_t *
186 zlistx_dup (zlistx_t *self);
187
188 // Set a user\-defined deallocator for list items; by default items are not
189 // freed when the list is destroyed\&.
190 CZMQ_EXPORT void
191 zlistx_set_destructor (zlistx_t *self, zlistx_destructor_fn destructor);
192
193 // Set a user\-defined duplicator for list items; by default items are not
194 // copied when the list is duplicated\&.
195 CZMQ_EXPORT void
196 zlistx_set_duplicator (zlistx_t *self, zlistx_duplicator_fn duplicator);
197
198 // Set a user\-defined comparator for zlistx_find and zlistx_sort; the method
199 // must return \-1, 0, or 1 depending on whether item1 is less than, equal to,
200 // or greater than, item2\&.
201 CZMQ_EXPORT void
202 zlistx_set_comparator (zlistx_t *self, zlistx_comparator_fn comparator);
203
204 // Self test of this class\&.
205 CZMQ_EXPORT void
206 zlistx_test (bool verbose);
207
208 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zlistx\&.c\*(Aq\&.
209 .fi
210 .SH "DESCRIPTION"
211 .sp
212 Provides a generic doubly\-linked list container\&. This container provides hooks for duplicator, comparator, and destructor functions\&. These tie into CZMQ and standard C semantics, so e\&.g\&. for string items you can use strdup, strcmp, and zstr_free\&. To store custom objects, define your own duplicator and comparator, and use the standard object destructor\&.
213 .sp
214 This is a reworking of the simpler zlist container\&. It is faster to insert and delete items anywhere in the list, and to keep ordered lists\&.
215 .SH "EXAMPLE"
216 .PP
217 \fBFrom zlistx_test method\fR.
218 .sp
219 .if n \{\
220 .RS 4
221 .\}
222 .nf
223 zlistx_t *list = zlistx_new ();
224 assert (list);
225 assert (zlistx_size (list) == 0);
226
227 // Test operations on an empty list
228 assert (zlistx_first (list) == NULL);
229 assert (zlistx_last (list) == NULL);
230 assert (zlistx_next (list) == NULL);
231 assert (zlistx_prev (list) == NULL);
232 assert (zlistx_find (list, "hello") == NULL);
233 assert (zlistx_delete (list, NULL) == \-1);
234 assert (zlistx_detach (list, NULL) == NULL);
235 assert (zlistx_delete (list, NULL) == \-1);
236 assert (zlistx_detach (list, NULL) == NULL);
237 zlistx_purge (list);
238 zlistx_sort (list);
239
240 // Use item handlers
241 zlistx_set_destructor (list, (zlistx_destructor_fn *) zstr_free);
242 zlistx_set_duplicator (list, (zlistx_duplicator_fn *) strdup);
243 zlistx_set_comparator (list, (zlistx_comparator_fn *) strcmp);
244
245 // Try simple insert/sort/delete/next
246 assert (zlistx_next (list) == NULL);
247 zlistx_add_end (list, "world");
248 assert (streq ((char *) zlistx_next (list), "world"));
249 zlistx_add_end (list, "hello");
250 assert (streq ((char *) zlistx_prev (list), "hello"));
251 zlistx_sort (list);
252 assert (zlistx_size (list) == 2);
253 void *handle = zlistx_find (list, "hello");
254 char *item1 = (char *) zlistx_item (list);
255 char *item2 = (char *) zlistx_handle_item (handle);
256 assert (item1 == item2);
257 assert (streq (item1, "hello"));
258 zlistx_delete (list, handle);
259 assert (zlistx_size (list) == 1);
260 char *string = (char *) zlistx_detach (list, NULL);
261 assert (streq (string, "world"));
262 free (string);
263 assert (zlistx_size (list) == 0);
264
265 // Check next/back work
266 // Now populate the list with items
267 zlistx_add_start (list, "five");
268 zlistx_add_end (list, "six");
269 zlistx_add_start (list, "four");
270 zlistx_add_end (list, "seven");
271 zlistx_add_start (list, "three");
272 zlistx_add_end (list, "eight");
273 zlistx_add_start (list, "two");
274 zlistx_add_end (list, "nine");
275 zlistx_add_start (list, "one");
276 zlistx_add_end (list, "ten");
277
278 // Test our navigation skills
279 assert (zlistx_size (list) == 10);
280 assert (streq ((char *) zlistx_last (list), "ten"));
281 assert (streq ((char *) zlistx_prev (list), "nine"));
282 assert (streq ((char *) zlistx_prev (list), "eight"));
283 assert (streq ((char *) zlistx_prev (list), "seven"));
284 assert (streq ((char *) zlistx_prev (list), "six"));
285 assert (streq ((char *) zlistx_prev (list), "five"));
286 assert (streq ((char *) zlistx_first (list), "one"));
287 assert (streq ((char *) zlistx_next (list), "two"));
288 assert (streq ((char *) zlistx_next (list), "three"));
289 assert (streq ((char *) zlistx_next (list), "four"));
290
291 // Sort by alphabetical order
292 zlistx_sort (list);
293 assert (streq ((char *) zlistx_first (list), "eight"));
294 assert (streq ((char *) zlistx_last (list), "two"));
295
296 // Moving items around
297 handle = zlistx_find (list, "six");
298 zlistx_move_start (list, handle);
299 assert (streq ((char *) zlistx_first (list), "six"));
300 zlistx_move_end (list, handle);
301 assert (streq ((char *) zlistx_last (list), "six"));
302 zlistx_sort (list);
303 assert (streq ((char *) zlistx_last (list), "two"));
304
305 // Copying a list
306 zlistx_t *copy = zlistx_dup (list);
307 assert (copy);
308 assert (zlistx_size (copy) == 10);
309 assert (streq ((char *) zlistx_first (copy), "eight"));
310 assert (streq ((char *) zlistx_last (copy), "two"));
311 zlistx_destroy (&copy);
312
313 // Delete items while iterating
314 string = (char *) zlistx_first (list);
315 assert (streq (string, "eight"));
316 string = (char *) zlistx_next (list);
317 assert (streq (string, "five"));
318 zlistx_delete (list, zlistx_cursor (list));
319 string = (char *) zlistx_next (list);
320 assert (streq (string, "four"));
321
322 zlistx_purge (list);
323 zlistx_destroy (&list);
324 .fi
325 .if n \{\
326 .RE
327 .\}
328 .sp
329 .SH "AUTHORS"
330 .sp
331 The czmq manual was written by the authors in the AUTHORS file\&.
332 .SH "RESOURCES"
333 .sp
334 Main web site: \m[blue]\fB\%\fR\m[]
335 .sp
336 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
337 .SH "COPYRIGHT"
338 .sp
339 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
340 .SH "NOTES"
341 .IP " 1." 4
342 zeromq-dev@lists.zeromq.org
343 .RS 4
344 \%mailto:zeromq-dev@lists.zeromq.org
345 .RE
181181 CZMQ_EXPORT void
182182 zlistx_test (bool verbose);
183183
184 Please add '@interface' section in './../src/zlistx.c'.
184185 ----
185186
186187 DESCRIPTION
0 '\" t
1 .\" Title: zloop
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZLOOP" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zloop \- event\-driven reactor
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // Callback function for reactor socket activity
37 typedef int (zloop_reader_fn) (
38 zloop_t *loop, zsock_t *reader, void *arg);
39
40 // Callback function for reactor events (low\-level)
41 typedef int (zloop_fn) (
42 zloop_t *loop, zmq_pollitem_t *item, void *arg);
43
44 // Callback for reactor timer events
45 typedef int (zloop_timer_fn) (
46 zloop_t *loop, int timer_id, void *arg);
47
48 // Create a new zloop reactor
49 CZMQ_EXPORT zloop_t *
50 zloop_new (void);
51
52 // Destroy a reactor
53 CZMQ_EXPORT void
54 zloop_destroy (zloop_t **self_p);
55
56 // Register socket reader with the reactor\&. When the reader has messages,
57 // the reactor will call the handler, passing the arg\&. Returns 0 if OK, \-1
58 // if there was an error\&. If you register the same socket more than once,
59 // each instance will invoke its corresponding handler\&.
60 CZMQ_EXPORT int
61 zloop_reader (zloop_t *self, zsock_t *sock, zloop_reader_fn handler, void *arg);
62
63 // Cancel a socket reader from the reactor\&. If multiple readers exist for
64 // same socket, cancels ALL of them\&.
65 CZMQ_EXPORT void
66 zloop_reader_end (zloop_t *self, zsock_t *sock);
67
68 // Configure a registered reader to ignore errors\&. If you do not set this,
69 // then readers that have errors are removed from the reactor silently\&.
70 CZMQ_EXPORT void
71 zloop_reader_set_tolerant (zloop_t *self, zsock_t *sock);
72
73 // Register low\-level libzmq pollitem with the reactor\&. When the pollitem
74 // is ready, will call the handler, passing the arg\&. Returns 0 if OK, \-1
75 // if there was an error\&. If you register the pollitem more than once, each
76 // instance will invoke its corresponding handler\&. A pollitem with
77 // socket=NULL and fd=0 means \*(Aqpoll on FD zero\*(Aq\&.
78 CZMQ_EXPORT int
79 zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg);
80
81 // Cancel a pollitem from the reactor, specified by socket or FD\&. If both
82 // are specified, uses only socket\&. If multiple poll items exist for same
83 // socket/FD, cancels ALL of them\&.
84 CZMQ_EXPORT void
85 zloop_poller_end (zloop_t *self, zmq_pollitem_t *item);
86
87 // Configure a registered poller to ignore errors\&. If you do not set this,
88 // then poller that have errors are removed from the reactor silently\&.
89 CZMQ_EXPORT void
90 zloop_poller_set_tolerant (zloop_t *self, zmq_pollitem_t *item);
91
92 // Register a timer that expires after some delay and repeats some number of
93 // times\&. At each expiry, will call the handler, passing the arg\&. To run a
94 // timer forever, use 0 times\&. Returns a timer_id that is used to cancel the
95 // timer in the future\&. Returns \-1 if there was an error\&.
96 CZMQ_EXPORT int
97 zloop_timer (zloop_t *self, size_t delay, size_t times, zloop_timer_fn handler, void *arg);
98
99 // Cancel a specific timer identified by a specific timer_id (as returned by
100 // zloop_timer)\&.
101 CZMQ_EXPORT int
102 zloop_timer_end (zloop_t *self, int timer_id);
103
104 // Register a ticket timer\&. Ticket timers are very fast in the case where
105 // you use a lot of timers (thousands), and frequently remove and add them\&.
106 // The main use case is expiry timers for servers that handle many clients,
107 // and which reset the expiry timer for each message received from a client\&.
108 // Whereas normal timers perform poorly as the number of clients grows, the
109 // cost of ticket timers is constant, no matter the number of clients\&. You
110 // must set the ticket delay using zloop_set_ticket_delay before creating a
111 // ticket\&. Returns a handle to the timer that you should use in
112 // zloop_ticket_reset and zloop_ticket_delete\&.
113 CZMQ_EXPORT void *
114 zloop_ticket (zloop_t *self, zloop_timer_fn handler, void *arg);
115
116 // Reset a ticket timer, which moves it to the end of the ticket list and
117 // resets its execution time\&. This is a very fast operation\&.
118 CZMQ_EXPORT void
119 zloop_ticket_reset (zloop_t *self, void *handle);
120
121 // Delete a ticket timer\&. We do not actually delete the ticket here, as
122 // other code may still refer to the ticket\&. We mark as deleted, and remove
123 // later and safely\&.
124 CZMQ_EXPORT void
125 zloop_ticket_delete (zloop_t *self, void *handle);
126
127 // Set the ticket delay, which applies to all tickets\&. If you lower the
128 // delay and there are already tickets created, the results are undefined\&.
129 CZMQ_EXPORT void
130 zloop_set_ticket_delay (zloop_t *self, size_t ticket_delay);
131
132 // Set hard limit on number of timers allowed\&. Setting more than a small
133 // number of timers (10\-100) can have a dramatic impact on the performance
134 // of the reactor\&. For high\-volume cases, use ticket timers\&. If the hard
135 // limit is reached, the reactor stops creating new timers and logs an
136 // error\&.
137 CZMQ_EXPORT void
138 zloop_set_max_timers (zloop_t *self, size_t max_timers);
139
140 // Set verbose tracing of reactor on/off\&. The default verbose setting is
141 // off (false)\&.
142 CZMQ_EXPORT void
143 zloop_set_verbose (zloop_t *self, bool verbose);
144
145 // By default the reactor stops if the process receives a SIGINT or SIGTERM
146 // signal\&. This makes it impossible to shut\-down message based architectures
147 // like zactors\&. This method lets you switch off break handling\&. The default
148 // nonstop setting is off (false)\&.
149 CZMQ_EXPORT void
150 zloop_set_nonstop (zloop_t *self, bool nonstop);
151
152 // Start the reactor\&. Takes control of the thread and returns when the 0MQ
153 // context is terminated or the process is interrupted, or any event handler
154 // returns \-1\&. Event handlers may register new sockets and timers, and
155 // cancel sockets\&. Returns 0 if interrupted, \-1 if canceled by a handler\&.
156 CZMQ_EXPORT int
157 zloop_start (zloop_t *self);
158
159 // Self test of this class\&.
160 CZMQ_EXPORT void
161 zloop_test (bool verbose);
162
163 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zloop\&.c\*(Aq\&.
164 .fi
165 .SH "DESCRIPTION"
166 .sp
167 The zloop class provides an event\-driven reactor pattern\&. The reactor handles zmq_pollitem_t items (pollers or writers, sockets or fds), and once\-off or repeated timers\&. Its resolution is 1 msec\&. It uses a tickless timer to reduce CPU interrupts in inactive processes\&.
168 .sp
169 Please add \fI@discuss\fR section in \fI\&./\&.\&./src/zloop\&.c\fR\&.
170 .SH "EXAMPLE"
171 .PP
172 \fBFrom zloop_test method\fR.
173 .sp
174 .if n \{\
175 .RS 4
176 .\}
177 .nf
178 // Create two PAIR sockets and connect over inproc
179 zsock_t *output = zsock_new (ZMQ_PAIR);
180 assert (output);
181 zsock_bind (output, "inproc://zloop\&.test");
182
183 zsock_t *input = zsock_new (ZMQ_PAIR);
184 assert (input);
185 zsock_connect (input, "inproc://zloop\&.test");
186
187 zloop_t *loop = zloop_new ();
188 assert (loop);
189 zloop_set_verbose (loop, verbose);
190
191 // Create a timer that will be cancelled
192 int timer_id = zloop_timer (loop, 1000, 1, s_timer_event, NULL);
193 zloop_timer (loop, 5, 1, s_cancel_timer_event, &timer_id);
194
195 // After 20 msecs, send a ping message to output3
196 zloop_timer (loop, 20, 1, s_timer_event, output);
197
198 // Set up some tickets that will never expire
199 zloop_set_ticket_delay (loop, 10000);
200 void *ticket1 = zloop_ticket (loop, s_timer_event, NULL);
201 void *ticket2 = zloop_ticket (loop, s_timer_event, NULL);
202 void *ticket3 = zloop_ticket (loop, s_timer_event, NULL);
203
204 // When we get the ping message, end the reactor
205 rc = zloop_reader (loop, input, s_socket_event, NULL);
206 assert (rc == 0);
207 zloop_reader_set_tolerant (loop, input);
208 zloop_start (loop);
209
210 zloop_ticket_delete (loop, ticket1);
211 zloop_ticket_delete (loop, ticket2);
212 zloop_ticket_delete (loop, ticket3);
213
214 // Check whether loop properly ignores zsys_interrupted flag
215 // when asked to
216 zloop_destroy (&loop);
217 loop = zloop_new ();
218
219 bool timer_event_called = false;
220 zloop_timer (loop, 1, 1, s_timer_event3, &timer_event_called);
221
222 zsys_interrupted = 1;
223 zloop_start (loop);
224 // zloop returns immediately without giving any handler a chance to run
225 assert (!timer_event_called);
226
227 zloop_set_nonstop (loop, true);
228 zloop_start (loop);
229 // zloop runs the handler which will terminate the loop
230 assert (timer_event_called);
231 zsys_interrupted = 0;
232
233 // cleanup
234 zloop_destroy (&loop);
235 assert (loop == NULL);
236
237 zsock_destroy (&input);
238 zsock_destroy (&output);
239 .fi
240 .if n \{\
241 .RE
242 .\}
243 .sp
244 .SH "AUTHORS"
245 .sp
246 The czmq manual was written by the authors in the AUTHORS file\&.
247 .SH "RESOURCES"
248 .sp
249 Main web site: \m[blue]\fB\%\fR\m[]
250 .sp
251 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
252 .SH "COPYRIGHT"
253 .sp
254 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
255 .SH "NOTES"
256 .IP " 1." 4
257 zeromq-dev@lists.zeromq.org
258 .RS 4
259 \%mailto:zeromq-dev@lists.zeromq.org
260 .RE
99 ----
1010 // This is a stable class, and may not change except for emergencies. It
1111 // is provided in stable builds.
12 // This class has draft methods, which may change over time. They are not
13 // in stable releases, by default. Use --enable-drafts to enable.
1412 // Callback function for reactor socket activity
1513 typedef int (zloop_reader_fn) (
1614 zloop_t *loop, zsock_t *reader, void *arg);
120118 CZMQ_EXPORT void
121119 zloop_set_verbose (zloop_t *self, bool verbose);
122120
121 // By default the reactor stops if the process receives a SIGINT or SIGTERM
122 // signal. This makes it impossible to shut-down message based architectures
123 // like zactors. This method lets you switch off break handling. The default
124 // nonstop setting is off (false).
125 CZMQ_EXPORT void
126 zloop_set_nonstop (zloop_t *self, bool nonstop);
127
123128 // Start the reactor. Takes control of the thread and returns when the 0MQ
124129 // context is terminated or the process is interrupted, or any event handler
125130 // returns -1. Event handlers may register new sockets and timers, and
131136 CZMQ_EXPORT void
132137 zloop_test (bool verbose);
133138
134 #ifdef CZMQ_BUILD_DRAFT_API
135 // *** Draft method, for development use, may change without warning ***
136 // By default the reactor stops if the process receives a SIGINT or SIGTERM
137 // signal. This makes it impossible to shut-down message based architectures
138 // like zactors. This method lets you switch off break handling. The default
139 // nonstop setting is off (false).
140 CZMQ_EXPORT void
141 zloop_set_nonstop (zloop_t *self, bool nonstop);
142
143 #endif // CZMQ_BUILD_DRAFT_API
139 Please add '@interface' section in './../src/zloop.c'.
144140 ----
145141
146142 DESCRIPTION
151147 once-off or repeated timers. Its resolution is 1 msec. It uses a tickless
152148 timer to reduce CPU interrupts in inactive processes.
153149
154 Please add @discuss section in ../src/zloop.c.
150 Please add '@discuss' section in './../src/zloop.c'.
155151
156152 EXAMPLE
157153 -------
0 '\" t
1 .\" Title: zmakecert
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZMAKECERT" "1" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zmakecert \- no title found
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zmakecert\&.c\*(Aq\&.
35 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zmakecert\&.c\*(Aq\&.
36 .fi
37 .SH "DESCRIPTION"
38 .sp
39 Please add \fI@header\fR section in \fI\&./\&.\&./src/zmakecert\&.c\fR\&.
40 .sp
41 Please add \fI@discuss\fR section in \fI\&./\&.\&./src/zmakecert\&.c\fR\&.
42 .SH "EXAMPLE"
43 .PP
44 \fBFrom zmakecert_test method\fR.
45 .sp
46 .if n \{\
47 .RS 4
48 .\}
49 .nf
50 Please add \*(Aq@selftest\*(Aq section in \*(Aq\&./\&.\&./src/zmakecert\&.c\*(Aq\&.
51 .fi
52 .if n \{\
53 .RE
54 .\}
55 .sp
56 .SH "AUTHORS"
57 .sp
58 The czmq manual was written by the authors in the AUTHORS file\&.
59 .SH "RESOURCES"
60 .sp
61 Main web site: \m[blue]\fB\%\fR\m[]
62 .sp
63 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
64 .SH "COPYRIGHT"
65 .sp
66 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
67 .SH "NOTES"
68 .IP " 1." 4
69 zeromq-dev@lists.zeromq.org
70 .RS 4
71 \%mailto:zeromq-dev@lists.zeromq.org
72 .RE
77 SYNOPSIS
88 --------
99 ----
10 Please add @interface section in ../src/zmakecert.c.
10 Please add '@interface' section in './../src/zmakecert.c'.
11 Please add '@interface' section in './../src/zmakecert.c'.
1112 ----
1213
1314 DESCRIPTION
1415 -----------
1516
16 Please add @header section in ../src/zmakecert.c.
17 Please add '@header' section in './../src/zmakecert.c'.
1718
18 Please add @discuss section in ../src/zmakecert.c.
19 Please add '@discuss' section in './../src/zmakecert.c'.
1920
2021 EXAMPLE
2122 -------
2223 .From zmakecert_test method
2324 ----
24 Please add @selftest section in ../src/zmakecert.c.
25 Please add '@selftest' section in './../src/zmakecert.c'.
2526 ----
0 '\" t
1 .\" Title: zmonitor
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZMONITOR" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zmonitor \- socket event monitor
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // Create new zmonitor actor instance to monitor a zsock_t socket:
35 //
36 // zactor_t *monitor = zactor_new (zmonitor, mysocket);
37 //
38 // Destroy zmonitor instance\&.
39 //
40 // zactor_destroy (&monitor);
41 //
42 // Enable verbose logging of commands and activity\&.
43 //
44 // zstr_send (monitor, "VERBOSE");
45 //
46 // Listen to monitor event type (zero or types, ending in NULL):
47 // zstr_sendx (monitor, "LISTEN", type, \&.\&.\&., NULL);
48 //
49 // Events:
50 // CONNECTED
51 // CONNECT_DELAYED
52 // CONNECT_RETRIED
53 // LISTENING
54 // BIND_FAILED
55 // ACCEPTED
56 // ACCEPT_FAILED
57 // CLOSED
58 // CLOSE_FAILED
59 // DISCONNECTED
60 // MONITOR_STOPPED
61 // ALL
62 //
63 // Start monitor; after this, any further LISTEN commands are ignored\&.
64 //
65 // zstr_send (monitor, "START");
66 // zsock_wait (monitor);
67 //
68 // Receive next monitor event:
69 //
70 // zmsg_t *msg = zmsg_recv (monitor);
71 //
72 // This is the zmonitor constructor as a zactor_fn; the argument can be
73 // a zactor_t, zsock_t, or libzmq void * socket:
74 CZMQ_EXPORT void
75 zmonitor (zsock_t *pipe, void *sock);
76
77 // Selftest
78 CZMQ_EXPORT void
79 zmonitor_test (bool verbose);
80 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zmonitor\&.c\*(Aq\&.
81 .fi
82 .SH "DESCRIPTION"
83 .sp
84 The zmonitor actor provides an API for obtaining socket events such as connected, listen, disconnected, etc\&. Socket events are only available for sockets connecting or bound to ipc:// and tcp:// endpoints\&.
85 .sp
86 This class wraps the ZMQ socket monitor API, see zmq_socket_monitor for details\&. Works on all versions of libzmq from 3\&.2 onwards\&. This class replaces zproxy_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock)\&.
87 .SH "EXAMPLE"
88 .PP
89 \fBFrom zmonitor_test method\fR.
90 .sp
91 .if n \{\
92 .RS 4
93 .\}
94 .nf
95 zsock_t *client = zsock_new (ZMQ_DEALER);
96 assert (client);
97 zactor_t *clientmon = zactor_new (zmonitor, client);
98 assert (clientmon);
99 if (verbose)
100 zstr_sendx (clientmon, "VERBOSE", NULL);
101 zstr_sendx (clientmon, "LISTEN", "LISTENING", "ACCEPTED", NULL);
102 zstr_sendx (clientmon, "START", NULL);
103 zsock_wait (clientmon);
104
105 zsock_t *server = zsock_new (ZMQ_DEALER);
106 assert (server);
107 zactor_t *servermon = zactor_new (zmonitor, server);
108 assert (servermon);
109 if (verbose)
110 zstr_sendx (servermon, "VERBOSE", NULL);
111 zstr_sendx (servermon, "LISTEN", "CONNECTED", "DISCONNECTED", NULL);
112 zstr_sendx (servermon, "START", NULL);
113 zsock_wait (servermon);
114
115 // Allow a brief time for the message to get there\&.\&.\&.
116 zmq_poll (NULL, 0, 200);
117
118 // Check client is now listening
119 int port_nbr = zsock_bind (client, "tcp://127\&.0\&.0\&.1:*");
120 assert (port_nbr != \-1);
121 s_assert_event (clientmon, "LISTENING");
122
123 // Check server connected to client
124 zsock_connect (server, "tcp://127\&.0\&.0\&.1:%d", port_nbr);
125 s_assert_event (servermon, "CONNECTED");
126
127 // Check client accepted connection
128 s_assert_event (clientmon, "ACCEPTED");
129
130 zactor_destroy (&clientmon);
131 zactor_destroy (&servermon);
132 zsock_destroy (&client);
133 zsock_destroy (&server);
134 #endif
135 .fi
136 .if n \{\
137 .RE
138 .\}
139 .sp
140 .SH "AUTHORS"
141 .sp
142 The czmq manual was written by the authors in the AUTHORS file\&.
143 .SH "RESOURCES"
144 .sp
145 Main web site: \m[blue]\fB\%\fR\m[]
146 .sp
147 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
148 .SH "COPYRIGHT"
149 .sp
150 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
151 .SH "NOTES"
152 .IP " 1." 4
153 zeromq-dev@lists.zeromq.org
154 .RS 4
155 \%mailto:zeromq-dev@lists.zeromq.org
156 .RE
5353 // Selftest
5454 CZMQ_EXPORT void
5555 zmonitor_test (bool verbose);
56 Please add '@interface' section in './../src/zmonitor.c'.
5657 ----
5758
5859 DESCRIPTION
0 '\" t
1 .\" Title: zmsg
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZMSG" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zmsg \- working with multipart messages
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // This class has draft methods, which may change over time\&. They are not
37 // in stable releases, by default\&. Use \-\-enable\-drafts to enable\&.
38 // Create a new empty message object
39 CZMQ_EXPORT zmsg_t *
40 zmsg_new (void);
41
42 // Receive message from socket, returns zmsg_t object or NULL if the recv
43 // was interrupted\&. Does a blocking recv\&. If you want to not block then use
44 // the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input
45 // before receiving\&.
46 CZMQ_EXPORT zmsg_t *
47 zmsg_recv (void *source);
48
49 // Load/append an open file into new message, return the message\&.
50 // Returns NULL if the message could not be loaded\&.
51 CZMQ_EXPORT zmsg_t *
52 zmsg_load (FILE *file);
53
54 // Decodes a serialized message frame created by zmsg_encode () and returns
55 // a new zmsg_t object\&. Returns NULL if the frame was badly formatted or
56 // there was insufficient memory to work\&.
57 CZMQ_EXPORT zmsg_t *
58 zmsg_decode (zframe_t *frame);
59
60 // Generate a signal message encoding the given status\&. A signal is a short
61 // message carrying a 1\-byte success/failure code (by convention, 0 means
62 // OK)\&. Signals are encoded to be distinguishable from "normal" messages\&.
63 CZMQ_EXPORT zmsg_t *
64 zmsg_new_signal (byte status);
65
66 // Destroy a message object and all frames it contains
67 CZMQ_EXPORT void
68 zmsg_destroy (zmsg_t **self_p);
69
70 // Send message to destination socket, and destroy the message after sending
71 // it successfully\&. If the message has no frames, sends nothing but destroys
72 // the message anyhow\&. Nullifies the caller\*(Aqs reference to the message (as
73 // it is a destructor)\&.
74 CZMQ_EXPORT int
75 zmsg_send (zmsg_t **self_p, void *dest);
76
77 // Send message to destination socket as part of a multipart sequence, and
78 // destroy the message after sending it successfully\&. Note that after a
79 // zmsg_sendm, you must call zmsg_send or another method that sends a final
80 // message part\&. If the message has no frames, sends nothing but destroys
81 // the message anyhow\&. Nullifies the caller\*(Aqs reference to the message (as
82 // it is a destructor)\&.
83 CZMQ_EXPORT int
84 zmsg_sendm (zmsg_t **self_p, void *dest);
85
86 // Return size of message, i\&.e\&. number of frames (0 or more)\&.
87 CZMQ_EXPORT size_t
88 zmsg_size (zmsg_t *self);
89
90 // Return total size of all frames in message\&.
91 CZMQ_EXPORT size_t
92 zmsg_content_size (zmsg_t *self);
93
94 // Push frame to the front of the message, i\&.e\&. before all other frames\&.
95 // Message takes ownership of frame, will destroy it when message is sent\&.
96 // Returns 0 on success, \-1 on error\&. Deprecates zmsg_push, which did not
97 // nullify the caller\*(Aqs frame reference\&.
98 CZMQ_EXPORT int
99 zmsg_prepend (zmsg_t *self, zframe_t **frame_p);
100
101 // Add frame to the end of the message, i\&.e\&. after all other frames\&.
102 // Message takes ownership of frame, will destroy it when message is sent\&.
103 // Returns 0 on success\&. Deprecates zmsg_add, which did not nullify the
104 // caller\*(Aqs frame reference\&.
105 CZMQ_EXPORT int
106 zmsg_append (zmsg_t *self, zframe_t **frame_p);
107
108 // Remove first frame from message, if any\&. Returns frame, or NULL\&.
109 // Caller owns return value and must destroy it when done\&.
110 CZMQ_EXPORT zframe_t *
111 zmsg_pop (zmsg_t *self);
112
113 // Push block of memory to front of message, as a new frame\&.
114 // Returns 0 on success, \-1 on error\&.
115 CZMQ_EXPORT int
116 zmsg_pushmem (zmsg_t *self, const void *data, size_t size);
117
118 // Add block of memory to the end of the message, as a new frame\&.
119 // Returns 0 on success, \-1 on error\&.
120 CZMQ_EXPORT int
121 zmsg_addmem (zmsg_t *self, const void *data, size_t size);
122
123 // Push string as new frame to front of message\&.
124 // Returns 0 on success, \-1 on error\&.
125 CZMQ_EXPORT int
126 zmsg_pushstr (zmsg_t *self, const char *string);
127
128 // Push string as new frame to end of message\&.
129 // Returns 0 on success, \-1 on error\&.
130 CZMQ_EXPORT int
131 zmsg_addstr (zmsg_t *self, const char *string);
132
133 // Push formatted string as new frame to front of message\&.
134 // Returns 0 on success, \-1 on error\&.
135 CZMQ_EXPORT int
136 zmsg_pushstrf (zmsg_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2);
137
138 // Push formatted string as new frame to end of message\&.
139 // Returns 0 on success, \-1 on error\&.
140 CZMQ_EXPORT int
141 zmsg_addstrf (zmsg_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2);
142
143 // Pop frame off front of message, return as fresh string\&. If there were
144 // no more frames in the message, returns NULL\&.
145 // Caller owns return value and must destroy it when done\&.
146 CZMQ_EXPORT char *
147 zmsg_popstr (zmsg_t *self);
148
149 // Push encoded message as a new frame\&. Message takes ownership of
150 // submessage, so the original is destroyed in this call\&. Returns 0 on
151 // success, \-1 on error\&.
152 CZMQ_EXPORT int
153 zmsg_addmsg (zmsg_t *self, zmsg_t **msg_p);
154
155 // Remove first submessage from message, if any\&. Returns zmsg_t, or NULL if
156 // decoding was not successful\&.
157 // Caller owns return value and must destroy it when done\&.
158 CZMQ_EXPORT zmsg_t *
159 zmsg_popmsg (zmsg_t *self);
160
161 // Remove specified frame from list, if present\&. Does not destroy frame\&.
162 CZMQ_EXPORT void
163 zmsg_remove (zmsg_t *self, zframe_t *frame);
164
165 // Set cursor to first frame in message\&. Returns frame, or NULL, if the
166 // message is empty\&. Use this to navigate the frames as a list\&.
167 CZMQ_EXPORT zframe_t *
168 zmsg_first (zmsg_t *self);
169
170 // Return the next frame\&. If there are no more frames, returns NULL\&. To move
171 // to the first frame call zmsg_first()\&. Advances the cursor\&.
172 CZMQ_EXPORT zframe_t *
173 zmsg_next (zmsg_t *self);
174
175 // Return the last frame\&. If there are no frames, returns NULL\&.
176 CZMQ_EXPORT zframe_t *
177 zmsg_last (zmsg_t *self);
178
179 // Save message to an open file, return 0 if OK, else \-1\&. The message is
180 // saved as a series of frames, each with length and data\&. Note that the
181 // file is NOT guaranteed to be portable between operating systems, not
182 // versions of CZMQ\&. The file format is at present undocumented and liable
183 // to arbitrary change\&.
184 CZMQ_EXPORT int
185 zmsg_save (zmsg_t *self, FILE *file);
186
187 // Serialize multipart message to a single message frame\&. Use this method
188 // to send structured messages across transports that do not support
189 // multipart data\&. Allocates and returns a new frame containing the
190 // serialized message\&. To decode a serialized message frame, use
191 // zmsg_decode ()\&.
192 // Caller owns return value and must destroy it when done\&.
193 CZMQ_EXPORT zframe_t *
194 zmsg_encode (zmsg_t *self);
195
196 // Create copy of message, as new message object\&. Returns a fresh zmsg_t
197 // object\&. If message is null, or memory was exhausted, returns null\&.
198 // Caller owns return value and must destroy it when done\&.
199 CZMQ_EXPORT zmsg_t *
200 zmsg_dup (zmsg_t *self);
201
202 // Send message to zsys log sink (may be stdout, or system facility as
203 // configured by zsys_set_logstream)\&.
204 CZMQ_EXPORT void
205 zmsg_print (zmsg_t *self);
206
207 // Return true if the two messages have the same number of frames and each
208 // frame in the first message is identical to the corresponding frame in the
209 // other message\&. As with zframe_eq, return false if either message is NULL\&.
210 CZMQ_EXPORT bool
211 zmsg_eq (zmsg_t *self, zmsg_t *other);
212
213 // Return signal value, 0 or greater, if message is a signal, \-1 if not\&.
214 CZMQ_EXPORT int
215 zmsg_signal (zmsg_t *self);
216
217 // Probe the supplied object, and report if it looks like a zmsg_t\&.
218 CZMQ_EXPORT bool
219 zmsg_is (void *self);
220
221 // Self test of this class\&.
222 CZMQ_EXPORT void
223 zmsg_test (bool verbose);
224
225 #ifdef CZMQ_BUILD_DRAFT_API
226 // *** Draft method, for development use, may change without warning ***
227 // Return message routing ID, if the message came from a ZMQ_SERVER socket\&.
228 // Else returns zero\&.
229 CZMQ_EXPORT uint32_t
230 zmsg_routing_id (zmsg_t *self);
231
232 // *** Draft method, for development use, may change without warning ***
233 // Set routing ID on message\&. This is used if/when the message is sent to a
234 // ZMQ_SERVER socket\&.
235 CZMQ_EXPORT void
236 zmsg_set_routing_id (zmsg_t *self, uint32_t routing_id);
237
238 #endif // CZMQ_BUILD_DRAFT_API
239 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zmsg\&.c\*(Aq\&.
240 .fi
241 .SH "DESCRIPTION"
242 .sp
243 The zmsg class provides methods to send and receive multipart messages across 0MQ sockets\&. This class provides a list\-like container interface, with methods to work with the overall container\&. zmsg_t messages are composed of zero or more zframe_t frames\&.
244 .sp
245 Please add \fI@discuss\fR section in \fI\&./\&.\&./src/zmsg\&.c\fR\&.
246 .SH "EXAMPLE"
247 .PP
248 \fBFrom zmsg_test method\fR.
249 .sp
250 .if n \{\
251 .RS 4
252 .\}
253 .nf
254 // Create two PAIR sockets and connect over inproc
255 zsock_t *output = zsock_new_pair ("@inproc://zmsg\&.test");
256 assert (output);
257 zsock_t *input = zsock_new_pair (">inproc://zmsg\&.test");
258 assert (input);
259
260 // Test send and receive of single\-frame message
261 zmsg_t *msg = zmsg_new ();
262 assert (msg);
263 zframe_t *frame = zframe_new ("Hello", 5);
264 assert (frame);
265 zmsg_prepend (msg, &frame);
266 assert (zmsg_size (msg) == 1);
267 assert (zmsg_content_size (msg) == 5);
268 rc = zmsg_send (&msg, output);
269 assert (msg == NULL);
270 assert (rc == 0);
271
272 msg = zmsg_recv (input);
273 assert (msg);
274 assert (zmsg_size (msg) == 1);
275 assert (zmsg_content_size (msg) == 5);
276 zmsg_destroy (&msg);
277
278 // Test send and receive of multi\-frame message
279 msg = zmsg_new ();
280 assert (msg);
281 rc = zmsg_addmem (msg, "Frame0", 6);
282 assert (rc == 0);
283 rc = zmsg_addmem (msg, "Frame1", 6);
284 assert (rc == 0);
285 rc = zmsg_addmem (msg, "Frame2", 6);
286 assert (rc == 0);
287 rc = zmsg_addmem (msg, "Frame3", 6);
288 assert (rc == 0);
289 rc = zmsg_addmem (msg, "Frame4", 6);
290 assert (rc == 0);
291 rc = zmsg_addmem (msg, "Frame5", 6);
292 assert (rc == 0);
293 rc = zmsg_addmem (msg, "Frame6", 6);
294 assert (rc == 0);
295 rc = zmsg_addmem (msg, "Frame7", 6);
296 assert (rc == 0);
297 rc = zmsg_addmem (msg, "Frame8", 6);
298 assert (rc == 0);
299 rc = zmsg_addmem (msg, "Frame9", 6);
300 assert (rc == 0);
301 zmsg_t *copy = zmsg_dup (msg);
302 assert (copy);
303 rc = zmsg_send (&copy, output);
304 assert (rc == 0);
305 rc = zmsg_send (&msg, output);
306 assert (rc == 0);
307
308 copy = zmsg_recv (input);
309 assert (copy);
310 assert (zmsg_size (copy) == 10);
311 assert (zmsg_content_size (copy) == 60);
312 zmsg_destroy (&copy);
313
314 msg = zmsg_recv (input);
315 assert (msg);
316 assert (zmsg_size (msg) == 10);
317 assert (zmsg_content_size (msg) == 60);
318
319 // Save to a file, read back
320 FILE *file = fopen ("zmsg\&.test", "w");
321 assert (file);
322 rc = zmsg_save (msg, file);
323 assert (rc == 0);
324 fclose (file);
325
326 file = fopen ("zmsg\&.test", "r");
327 rc = zmsg_save (msg, file);
328 assert (rc == \-1);
329 fclose (file);
330 zmsg_destroy (&msg);
331
332 file = fopen ("zmsg\&.test", "r");
333 msg = zmsg_load (file);
334 assert (msg);
335 fclose (file);
336 remove ("zmsg\&.test");
337 assert (zmsg_size (msg) == 10);
338 assert (zmsg_content_size (msg) == 60);
339
340 // Remove all frames except first and last
341 int frame_nbr;
342 for (frame_nbr = 0; frame_nbr < 8; frame_nbr++) {
343 zmsg_first (msg);
344 frame = zmsg_next (msg);
345 zmsg_remove (msg, frame);
346 zframe_destroy (&frame);
347 }
348 // Test message frame manipulation
349 assert (zmsg_size (msg) == 2);
350 frame = zmsg_last (msg);
351 assert (zframe_streq (frame, "Frame9"));
352 assert (zmsg_content_size (msg) == 12);
353 frame = zframe_new ("Address", 7);
354 assert (frame);
355 zmsg_prepend (msg, &frame);
356 assert (zmsg_size (msg) == 3);
357 rc = zmsg_addstr (msg, "Body");
358 assert (rc == 0);
359 assert (zmsg_size (msg) == 4);
360 frame = zmsg_pop (msg);
361 zframe_destroy (&frame);
362 assert (zmsg_size (msg) == 3);
363 char *body = zmsg_popstr (msg);
364 assert (streq (body, "Frame0"));
365 free (body);
366 zmsg_destroy (&msg);
367
368 // Test encoding/decoding
369 msg = zmsg_new ();
370 assert (msg);
371 byte *blank = (byte *) zmalloc (100000);
372 assert (blank);
373 rc = zmsg_addmem (msg, blank, 0);
374 assert (rc == 0);
375 rc = zmsg_addmem (msg, blank, 1);
376 assert (rc == 0);
377 rc = zmsg_addmem (msg, blank, 253);
378 assert (rc == 0);
379 rc = zmsg_addmem (msg, blank, 254);
380 assert (rc == 0);
381 rc = zmsg_addmem (msg, blank, 255);
382 assert (rc == 0);
383 rc = zmsg_addmem (msg, blank, 256);
384 assert (rc == 0);
385 rc = zmsg_addmem (msg, blank, 65535);
386 assert (rc == 0);
387 rc = zmsg_addmem (msg, blank, 65536);
388 assert (rc == 0);
389 rc = zmsg_addmem (msg, blank, 65537);
390 assert (rc == 0);
391 free (blank);
392 assert (zmsg_size (msg) == 9);
393 frame = zmsg_encode (msg);
394 zmsg_destroy (&msg);
395 msg = zmsg_decode (frame);
396 assert (msg);
397 zmsg_destroy (&msg);
398 zframe_destroy (&frame);
399
400 // Test submessages
401 msg = zmsg_new ();
402 assert (msg);
403 zmsg_t *submsg = zmsg_new ();
404 zmsg_pushstr (msg, "matr");
405 zmsg_pushstr (submsg, "joska");
406 rc = zmsg_addmsg (msg, &submsg);
407 assert (rc == 0);
408 assert (submsg == NULL);
409 submsg = zmsg_popmsg (msg);
410 assert (submsg == NULL); // string "matr" is not encoded zmsg_t, so was discarded
411 submsg = zmsg_popmsg (msg);
412 assert (submsg);
413 body = zmsg_popstr (submsg);
414 assert (streq (body, "joska"));
415 free (body);
416 zmsg_destroy (&submsg);
417 frame = zmsg_pop (msg);
418 assert (frame == NULL);
419 zmsg_destroy (&msg);
420
421 // Test comparison of two messages
422 msg = zmsg_new ();
423 zmsg_addstr (msg, "One");
424 zmsg_addstr (msg, "Two");
425 zmsg_addstr (msg, "Three");
426 zmsg_t *msg_other = zmsg_new ();
427 zmsg_addstr (msg_other, "One");
428 zmsg_addstr (msg_other, "Two");
429 zmsg_addstr (msg_other, "One\-Hundred");
430 zmsg_t *msg_dup = zmsg_dup (msg);
431 zmsg_t *empty_msg = zmsg_new ();
432 zmsg_t *empty_msg_2 = zmsg_new ();
433 assert (zmsg_eq (msg, msg_dup));
434 assert (!zmsg_eq (msg, msg_other));
435 assert (zmsg_eq (empty_msg, empty_msg_2));
436 assert (!zmsg_eq (msg, NULL));
437 assert (!zmsg_eq (NULL, empty_msg));
438 assert (!zmsg_eq (NULL, NULL));
439 zmsg_destroy (&msg);
440 zmsg_destroy (&msg_other);
441 zmsg_destroy (&msg_dup);
442 zmsg_destroy (&empty_msg);
443 zmsg_destroy (&empty_msg_2);
444
445 // Test signal messages
446 msg = zmsg_new_signal (0);
447 assert (zmsg_signal (msg) == 0);
448 zmsg_destroy (&msg);
449 msg = zmsg_new_signal (\-1);
450 assert (zmsg_signal (msg) == 255);
451 zmsg_destroy (&msg);
452
453 // Now try methods on an empty message
454 msg = zmsg_new ();
455 assert (msg);
456 assert (zmsg_size (msg) == 0);
457 assert (zmsg_unwrap (msg) == NULL);
458 assert (zmsg_first (msg) == NULL);
459 assert (zmsg_last (msg) == NULL);
460 assert (zmsg_next (msg) == NULL);
461 assert (zmsg_pop (msg) == NULL);
462 // Sending an empty message is valid and destroys the message
463 assert (zmsg_send (&msg, output) == 0);
464 assert (!msg);
465
466 zsock_destroy (&input);
467 zsock_destroy (&output);
468
469 #if defined (ZMQ_SERVER)
470 // Create server and client sockets and connect over inproc
471 zsock_t *server = zsock_new_server ("inproc://zmsg\-test\-routing");
472 assert (server);
473 zsock_t *client = zsock_new_client ("inproc://zmsg\-test\-routing");
474 assert (client);
475
476 // Send request from client to server
477 zmsg_t *request = zmsg_new ();
478 assert (request);
479 zmsg_addstr (request, "Hello");
480 rc = zmsg_send (&request, client);
481 assert (rc == 0);
482 assert (!request);
483
484 // Read request and send reply
485 request = zmsg_recv (server);
486 assert (request);
487 char *string = zmsg_popstr (request);
488 assert (streq (string, "Hello"));
489 assert (zmsg_routing_id (request));
490 zstr_free (&string);
491
492 zmsg_t *reply = zmsg_new ();
493 assert (reply);
494 zmsg_addstr (reply, "World");
495 zmsg_set_routing_id (reply, zmsg_routing_id (request));
496 rc = zmsg_send (&reply, server);
497 assert (rc == 0);
498 zmsg_destroy (&request);
499
500 // Read reply
501 reply = zmsg_recv (client);
502 string = zmsg_popstr (reply);
503 assert (streq (string, "World"));
504 assert (zmsg_routing_id (reply) == 0);
505 zmsg_destroy (&reply);
506 zstr_free (&string);
507
508 // Client and server disallow multipart
509 msg = zmsg_new ();
510 zmsg_addstr (msg, "One");
511 zmsg_addstr (msg, "Two");
512 rc = zmsg_send (&msg, client);
513 assert (rc == \-1);
514 assert (zmsg_size (msg) == 2);
515 rc = zmsg_send (&msg, server);
516 assert (rc == \-1);
517 assert (zmsg_size (msg) == 2);
518 zmsg_destroy (&msg);
519
520 zsock_destroy (&client);
521 zsock_destroy (&server);
522 #endif
523 .fi
524 .if n \{\
525 .RE
526 .\}
527 .sp
528 .SH "AUTHORS"
529 .sp
530 The czmq manual was written by the authors in the AUTHORS file\&.
531 .SH "RESOURCES"
532 .sp
533 Main web site: \m[blue]\fB\%\fR\m[]
534 .sp
535 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
536 .SH "COPYRIGHT"
537 .sp
538 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
539 .SH "NOTES"
540 .IP " 1." 4
541 zeromq-dev@lists.zeromq.org
542 .RS 4
543 \%mailto:zeromq-dev@lists.zeromq.org
544 .RE
212212 zmsg_set_routing_id (zmsg_t *self, uint32_t routing_id);
213213
214214 #endif // CZMQ_BUILD_DRAFT_API
215 Please add '@interface' section in './../src/zmsg.c'.
215216 ----
216217
217218 DESCRIPTION
222223 with methods to work with the overall container. zmsg_t messages are
223224 composed of zero or more zframe_t frames.
224225
225 Please add @discuss section in ../src/zmsg.c.
226 Please add '@discuss' section in './../src/zmsg.c'.
226227
227228 EXAMPLE
228229 -------
0 '\" t
1 .\" Title: zpoller
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZPOLLER" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zpoller \- trivial socket poller class
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // Create new poller, specifying zero or more readers\&. The list of
37 // readers ends in a NULL\&. Each reader can be a zsock_t instance, a
38 // zactor_t instance, a libzmq socket (void *), or a file handle\&.
39 CZMQ_EXPORT zpoller_t *
40 zpoller_new (void *reader, \&.\&.\&.);
41
42 // Destroy a poller
43 CZMQ_EXPORT void
44 zpoller_destroy (zpoller_t **self_p);
45
46 // Add a reader to be polled\&. Returns 0 if OK, \-1 on failure\&. The reader may
47 // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance\&.
48 CZMQ_EXPORT int
49 zpoller_add (zpoller_t *self, void *reader);
50
51 // Remove a reader from the poller; returns 0 if OK, \-1 on failure\&. The reader
52 // must have been passed during construction, or in an zpoller_add () call\&.
53 CZMQ_EXPORT int
54 zpoller_remove (zpoller_t *self, void *reader);
55
56 // By default the poller stops if the process receives a SIGINT or SIGTERM
57 // signal\&. This makes it impossible to shut\-down message based architectures
58 // like zactors\&. This method lets you switch off break handling\&. The default
59 // nonstop setting is off (false)\&.
60 CZMQ_EXPORT void
61 zpoller_set_nonstop (zpoller_t *self, bool nonstop);
62
63 // Poll the registered readers for I/O, return first reader that has input\&.
64 // The reader will be a libzmq void * socket, or a zsock_t or zactor_t
65 // instance as specified in zpoller_new/zpoller_add\&. The timeout should be
66 // zero or greater, or \-1 to wait indefinitely\&. Socket priority is defined
67 // by their order in the poll list\&. If you need a balanced poll, use the low
68 // level zmq_poll method directly\&. If the poll call was interrupted (SIGINT),
69 // or the ZMQ context was destroyed, or the timeout expired, returns NULL\&.
70 // You can test the actual exit condition by calling zpoller_expired () and
71 // zpoller_terminated ()\&. The timeout is in msec\&.
72 CZMQ_EXPORT void *
73 zpoller_wait (zpoller_t *self, int timeout);
74
75 // Return true if the last zpoller_wait () call ended because the timeout
76 // expired, without any error\&.
77 CZMQ_EXPORT bool
78 zpoller_expired (zpoller_t *self);
79
80 // Return true if the last zpoller_wait () call ended because the process
81 // was interrupted, or the parent context was destroyed\&.
82 CZMQ_EXPORT bool
83 zpoller_terminated (zpoller_t *self);
84
85 // Self test of this class\&.
86 CZMQ_EXPORT void
87 zpoller_test (bool verbose);
88
89 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zpoller\&.c\*(Aq\&.
90 .fi
91 .SH "DESCRIPTION"
92 .sp
93 The zpoller class provides a minimalist interface to ZeroMQ\(cqs zmq_poll API, for the very common case of reading from a number of sockets\&. It does not provide polling for output, nor polling on file handles\&. If you need either of these, use the zmq_poll API directly\&.
94 .sp
95 The class implements the poller using the zmq_poller API if that exists, else does the work itself\&.
96 .SH "EXAMPLE"
97 .PP
98 \fBFrom zpoller_test method\fR.
99 .sp
100 .if n \{\
101 .RS 4
102 .\}
103 .nf
104 // Create a few sockets
105 zsock_t *vent = zsock_new (ZMQ_PUSH);
106 assert (vent);
107 int port_nbr = zsock_bind (vent, "tcp://127\&.0\&.0\&.1:*");
108 assert (port_nbr != \-1);
109 zsock_t *sink = zsock_new (ZMQ_PULL);
110 assert (sink);
111 int rc = zsock_connect (sink, "tcp://127\&.0\&.0\&.1:%d", port_nbr);
112 assert (rc != \-1);
113 zsock_t *bowl = zsock_new (ZMQ_PULL);
114 assert (bowl);
115 zsock_t *dish = zsock_new (ZMQ_PULL);
116 assert (dish);
117
118 // Set up poller
119 zpoller_t *poller = zpoller_new (bowl, dish, NULL);
120 assert (poller);
121
122 // Add a reader to the existing poller
123 rc = zpoller_add (poller, sink);
124 assert (rc == 0);
125
126 zstr_send (vent, "Hello, World");
127
128 // We expect a message only on the sink
129 zsock_t *which = (zsock_t *) zpoller_wait (poller, \-1);
130 assert (which == sink);
131 assert (zpoller_expired (poller) == false);
132 assert (zpoller_terminated (poller) == false);
133 char *message = zstr_recv (which);
134 assert (streq (message, "Hello, World"));
135 zstr_free (&message);
136
137 // Stop polling reader
138 rc = zpoller_remove (poller, sink);
139 assert (rc == 0);
140
141 // Check we can poll an FD
142 rc = zsock_connect (bowl, "tcp://127\&.0\&.0\&.1:%d", port_nbr);
143 assert (rc != \-1);
144 SOCKET fd = zsock_fd (bowl);
145 rc = zpoller_add (poller, (void *) &fd);
146 assert (rc != \-1);
147 zstr_send (vent, "Hello again, world");
148 assert (zpoller_wait (poller, 500) == &fd);
149
150 // Check zpoller_set_nonstop ()
151 zsys_interrupted = 1;
152 zpoller_wait (poller, 0);
153 assert (zpoller_terminated (poller));
154 zpoller_set_nonstop (poller, true);
155 zpoller_wait (poller, 0);
156 assert (!zpoller_terminated (poller));
157 zsys_interrupted = 0;
158
159 zpoller_destroy (&poller);
160 zsock_destroy (&vent);
161 zsock_destroy (&sink);
162 zsock_destroy (&bowl);
163 zsock_destroy (&dish);
164
165 #ifdef ZMQ_SERVER
166 // Check thread safe sockets
167 zpoller_destroy (&poller);
168 zsock_t *client = zsock_new (ZMQ_CLIENT);
169 assert (client);
170 zsock_t *server = zsock_new (ZMQ_SERVER);
171 assert (server);
172 poller = zpoller_new (client, server, NULL);
173 assert (poller);
174 port_nbr = zsock_bind (server, "tcp://127\&.0\&.0\&.1:*");
175 assert (port_nbr != \-1);
176 rc = zsock_connect (client, "tcp://127\&.0\&.0\&.1:%d", port_nbr);
177 assert (rc != \-1);
178
179 zstr_send (client, "Hello, World");
180
181 // We expect a message only on the server
182 which = (zsock_t *) zpoller_wait (poller, \-1);
183 assert (which == server);
184 assert (zpoller_expired (poller) == false);
185 assert (zpoller_terminated (poller) == false);
186 message = zstr_recv (which);
187 assert (streq (message, "Hello, World"));
188 zstr_free (&message);
189
190 zpoller_destroy (&poller);
191 zsock_destroy (&client);
192 zsock_destroy (&server);
193 #endif
194 .fi
195 .if n \{\
196 .RE
197 .\}
198 .sp
199 .SH "AUTHORS"
200 .sp
201 The czmq manual was written by the authors in the AUTHORS file\&.
202 .SH "RESOURCES"
203 .sp
204 Main web site: \m[blue]\fB\%\fR\m[]
205 .sp
206 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
207 .SH "COPYRIGHT"
208 .sp
209 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
210 .SH "NOTES"
211 .IP " 1." 4
212 zeromq-dev@lists.zeromq.org
213 .RS 4
214 \%mailto:zeromq-dev@lists.zeromq.org
215 .RE
99 ----
1010 // This is a stable class, and may not change except for emergencies. It
1111 // is provided in stable builds.
12 // This class has draft methods, which may change over time. They are not
13 // in stable releases, by default. Use --enable-drafts to enable.
1412 // Create new poller, specifying zero or more readers. The list of
1513 // readers ends in a NULL. Each reader can be a zsock_t instance, a
1614 // zactor_t instance, a libzmq socket (void *), or a file handle.
3028 // must have been passed during construction, or in an zpoller_add () call.
3129 CZMQ_EXPORT int
3230 zpoller_remove (zpoller_t *self, void *reader);
31
32 // By default the poller stops if the process receives a SIGINT or SIGTERM
33 // signal. This makes it impossible to shut-down message based architectures
34 // like zactors. This method lets you switch off break handling. The default
35 // nonstop setting is off (false).
36 CZMQ_EXPORT void
37 zpoller_set_nonstop (zpoller_t *self, bool nonstop);
3338
3439 // Poll the registered readers for I/O, return first reader that has input.
3540 // The reader will be a libzmq void * socket, or a zsock_t or zactor_t
5762 CZMQ_EXPORT void
5863 zpoller_test (bool verbose);
5964
60 #ifdef CZMQ_BUILD_DRAFT_API
61 // *** Draft method, for development use, may change without warning ***
62 // By default the poller stops if the process receives a SIGINT or SIGTERM
63 // signal. This makes it impossible to shut-down message based architectures
64 // like zactors. This method lets you switch off break handling. The default
65 // nonstop setting is off (false).
66 CZMQ_EXPORT void
67 zpoller_set_nonstop (zpoller_t *self, bool nonstop);
68
69 #endif // CZMQ_BUILD_DRAFT_API
65 Please add '@interface' section in './../src/zpoller.c'.
7066 ----
7167
7268 DESCRIPTION
0 '\" t
1 .\" Title: zproc
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZPROC" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zproc \- process configuration and status
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a draft class, and may change without notice\&. It is disabled in
35 // stable builds by default\&. If you use this in applications, please ask
36 // for it to be pushed to stable state\&. Use \-\-enable\-drafts to enable\&.
37 #ifdef CZMQ_BUILD_DRAFT_API
38 // *** Draft method, for development use, may change without warning ***
39 // Returns CZMQ version as a single 6\-digit integer encoding the major
40 // version (x 10000), the minor version (x 100) and the patch\&.
41 CZMQ_EXPORT int
42 zproc_czmq_version (void);
43
44 // *** Draft method, for development use, may change without warning ***
45 // Returns true if the process received a SIGINT or SIGTERM signal\&.
46 // It is good practice to use this method to exit any infinite loop
47 // processing messages\&.
48 CZMQ_EXPORT bool
49 zproc_interrupted (void);
50
51 // *** Draft method, for development use, may change without warning ***
52 // Returns true if the underlying libzmq supports CURVE security\&.
53 CZMQ_EXPORT bool
54 zproc_has_curve (void);
55
56 // *** Draft method, for development use, may change without warning ***
57 // Return current host name, for use in public tcp:// endpoints\&.
58 // If the host name is not resolvable, returns NULL\&.
59 // Caller owns return value and must destroy it when done\&.
60 CZMQ_EXPORT char *
61 zproc_hostname (void);
62
63 // *** Draft method, for development use, may change without warning ***
64 // Move the current process into the background\&. The precise effect
65 // depends on the operating system\&. On POSIX boxes, moves to a specified
66 // working directory (if specified), closes all file handles, reopens
67 // stdin, stdout, and stderr to the null device, and sets the process to
68 // ignore SIGHUP\&. On Windows, does nothing\&. Returns 0 if OK, \-1 if there
69 // was an error\&.
70 CZMQ_EXPORT void
71 zproc_daemonize (const char *workdir);
72
73 // *** Draft method, for development use, may change without warning ***
74 // Drop the process ID into the lockfile, with exclusive lock, and
75 // switch the process to the specified group and/or user\&. Any of the
76 // arguments may be null, indicating a no\-op\&. Returns 0 on success,
77 // \-1 on failure\&. Note if you combine this with zsys_daemonize, run
78 // after, not before that method, or the lockfile will hold the wrong
79 // process ID\&.
80 CZMQ_EXPORT void
81 zproc_run_as (const char *lockfile, const char *group, const char *user);
82
83 // *** Draft method, for development use, may change without warning ***
84 // Configure the number of I/O threads that ZeroMQ will use\&. A good
85 // rule of thumb is one thread per gigabit of traffic in or out\&. The
86 // default is 1, sufficient for most applications\&. If the environment
87 // variable ZSYS_IO_THREADS is defined, that provides the default\&.
88 // Note that this method is valid only before any socket is created\&.
89 CZMQ_EXPORT void
90 zproc_set_io_threads (size_t io_threads);
91
92 // *** Draft method, for development use, may change without warning ***
93 // Configure the number of sockets that ZeroMQ will allow\&. The default
94 // is 1024\&. The actual limit depends on the system, and you can query it
95 // by using zsys_socket_limit ()\&. A value of zero means "maximum"\&.
96 // Note that this method is valid only before any socket is created\&.
97 CZMQ_EXPORT void
98 zproc_set_max_sockets (size_t max_sockets);
99
100 // *** Draft method, for development use, may change without warning ***
101 // Set network interface name to use for broadcasts, particularly zbeacon\&.
102 // This lets the interface be configured for test environments where required\&.
103 // For example, on Mac OS X, zbeacon cannot bind to 255\&.255\&.255\&.255 which is
104 // the default when there is no specified interface\&. If the environment
105 // variable ZSYS_INTERFACE is set, use that as the default interface name\&.
106 // Setting the interface to "*" means "use all available interfaces"\&.
107 CZMQ_EXPORT void
108 zproc_set_biface (const char *value);
109
110 // *** Draft method, for development use, may change without warning ***
111 // Return network interface to use for broadcasts, or "" if none was set\&.
112 CZMQ_EXPORT const char *
113 zproc_biface (void);
114
115 // *** Draft method, for development use, may change without warning ***
116 // Set log identity, which is a string that prefixes all log messages sent
117 // by this process\&. The log identity defaults to the environment variable
118 // ZSYS_LOGIDENT, if that is set\&.
119 CZMQ_EXPORT void
120 zproc_set_log_ident (const char *value);
121
122 // *** Draft method, for development use, may change without warning ***
123 // Sends log output to a PUB socket bound to the specified endpoint\&. To
124 // collect such log output, create a SUB socket, subscribe to the traffic
125 // you care about, and connect to the endpoint\&. Log traffic is sent as a
126 // single string frame, in the same format as when sent to stdout\&. The
127 // log system supports a single sender; multiple calls to this method will
128 // bind the same sender to multiple endpoints\&. To disable the sender, call
129 // this method with a null argument\&.
130 CZMQ_EXPORT void
131 zproc_set_log_sender (const char *endpoint);
132
133 // *** Draft method, for development use, may change without warning ***
134 // Enable or disable logging to the system facility (syslog on POSIX boxes,
135 // event log on Windows)\&. By default this is disabled\&.
136 CZMQ_EXPORT void
137 zproc_set_log_system (bool logsystem);
138
139 // *** Draft method, for development use, may change without warning ***
140 // Log error condition \- highest priority
141 CZMQ_EXPORT void
142 zproc_log_error (const char *format, \&.\&.\&.) CHECK_PRINTF (1);
143
144 // *** Draft method, for development use, may change without warning ***
145 // Log warning condition \- high priority
146 CZMQ_EXPORT void
147 zproc_log_warning (const char *format, \&.\&.\&.) CHECK_PRINTF (1);
148
149 // *** Draft method, for development use, may change without warning ***
150 // Log normal, but significant, condition \- normal priority
151 CZMQ_EXPORT void
152 zproc_log_notice (const char *format, \&.\&.\&.) CHECK_PRINTF (1);
153
154 // *** Draft method, for development use, may change without warning ***
155 // Log informational message \- low priority
156 CZMQ_EXPORT void
157 zproc_log_info (const char *format, \&.\&.\&.) CHECK_PRINTF (1);
158
159 // *** Draft method, for development use, may change without warning ***
160 // Log debug\-level message \- lowest priority
161 CZMQ_EXPORT void
162 zproc_log_debug (const char *format, \&.\&.\&.) CHECK_PRINTF (1);
163
164 // *** Draft method, for development use, may change without warning ***
165 // Self test of this class\&.
166 CZMQ_EXPORT void
167 zproc_test (bool verbose);
168
169 #endif // CZMQ_BUILD_DRAFT_API
170 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zproc\&.c\*(Aq\&.
171 .fi
172 .SH "DESCRIPTION"
173 .sp
174 zproc \- process configuration and status
175 .sp
176 Please add \fI@discuss\fR section in \fI\&./\&.\&./src/zproc\&.c\fR\&.
177 .SH "EXAMPLE"
178 .PP
179 \fBFrom zproc_test method\fR.
180 .sp
181 .if n \{\
182 .RS 4
183 .\}
184 .nf
185 Please add \*(Aq@selftest\*(Aq section in \*(Aq\&./\&.\&./src/zproc\&.c\*(Aq\&.
186 .fi
187 .if n \{\
188 .RE
189 .\}
190 .sp
191 .SH "AUTHORS"
192 .sp
193 The czmq manual was written by the authors in the AUTHORS file\&.
194 .SH "RESOURCES"
195 .sp
196 Main web site: \m[blue]\fB\%\fR\m[]
197 .sp
198 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
199 .SH "COPYRIGHT"
200 .sp
201 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
202 .SH "NOTES"
203 .IP " 1." 4
204 zeromq-dev@lists.zeromq.org
205 .RS 4
206 \%mailto:zeromq-dev@lists.zeromq.org
207 .RE
143143 zproc_test (bool verbose);
144144
145145 #endif // CZMQ_BUILD_DRAFT_API
146 Please add '@interface' section in './../src/zproc.c'.
146147 ----
147148
148149 DESCRIPTION
150151
151152 zproc - process configuration and status
152153
153 Please add @discuss section in ../src/zproc.c.
154 Please add '@discuss' section in './../src/zproc.c'.
154155
155156 EXAMPLE
156157 -------
157158 .From zproc_test method
158159 ----
159 Please add @selftest section in ../src/zproc.c.
160 Please add '@selftest' section in './../src/zproc.c'.
160161 ----
0 '\" t
1 .\" Title: zproxy
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZPROXY" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zproxy \- run a steerable proxy in the background
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // Create new zproxy actor instance\&. The proxy switches messages between
35 // a frontend socket and a backend socket; use the FRONTEND and BACKEND
36 // commands to configure these:
37 //
38 // zactor_t *proxy = zactor_new (zproxy, NULL);
39 //
40 // Destroy zproxy instance\&. This destroys the two sockets and stops any
41 // message flow between them:
42 //
43 // zactor_destroy (&proxy);
44 //
45 // Note that all zproxy commands are synchronous, so your application always
46 // waits for a signal from the actor after each command\&.
47 //
48 // Enable verbose logging of commands and activity:
49 //
50 // zstr_send (proxy, "VERBOSE");
51 // zsock_wait (proxy);
52 //
53 // Specify frontend socket type \-\- see zsock_type_str () \-\- and attach to
54 // endpoints, see zsock_attach ()\&. Note that a proxy socket is always
55 // serverish:
56 //
57 // zstr_sendx (proxy, "FRONTEND", "XSUB", endpoints, NULL);
58 // zsock_wait (proxy);
59 //
60 // Specify backend socket type \-\- see zsock_type_str () \-\- and attach to
61 // endpoints, see zsock_attach ()\&. Note that a proxy socket is always
62 // serverish:
63 //
64 // zstr_sendx (proxy, "BACKEND", "XPUB", endpoints, NULL);
65 // zsock_wait (proxy);
66 //
67 // Capture all proxied messages; these are delivered to the application
68 // via an inproc PULL socket that you have already bound to the specified
69 // endpoint:
70 //
71 // zstr_sendx (proxy, "CAPTURE", endpoint, NULL);
72 // zsock_wait (proxy);
73 //
74 // Pause the proxy\&. A paused proxy will cease processing messages, causing
75 // them to be queued up and potentially hit the high\-water mark on the
76 // frontend or backend socket, causing messages to be dropped, or writing
77 // applications to block:
78 //
79 // zstr_sendx (proxy, "PAUSE", NULL);
80 // zsock_wait (proxy);
81 //
82 // Resume the proxy\&. Note that the proxy starts automatically as soon as it
83 // has a properly attached frontend and backend socket:
84 //
85 // zstr_sendx (proxy, "RESUME", NULL);
86 // zsock_wait (proxy);
87 //
88 // Configure an authentication domain for the "FRONTEND" or "BACKEND" proxy
89 // socket \-\- see zsock_set_zap_domain ()\&. Call before binding socket:
90 //
91 // zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL);
92 // zsock_wait (proxy);
93 //
94 // Configure PLAIN authentication for the "FRONTEND" or "BACKEND" proxy
95 // socket \-\- see zsock_set_plain_server ()\&. Call before binding socket:
96 //
97 // zstr_sendx (proxy, "PLAIN", "BACKEND", NULL);
98 // zsock_wait (proxy);
99 //
100 // Configure CURVE authentication for the "FRONTEND" or "BACKEND" proxy
101 // socket \-\- see zsock_set_curve_server () \-\- specifying both the public and
102 // secret keys of a certificate as Z85 armored strings \-\- see
103 // zcert_public_txt () and zcert_secret_txt ()\&. Call before binding socket:
104 //
105 // zstr_sendx (proxy, "CURVE", "FRONTEND", public_txt, secret_txt, NULL);
106 // zsock_wait (proxy);
107 //
108 // This is the zproxy constructor as a zactor_fn; the argument is a
109 // character string specifying frontend and backend socket types as two
110 // uppercase strings separated by a hyphen:
111 CZMQ_EXPORT void
112 zproxy (zsock_t *pipe, void *unused);
113
114 // Selftest
115 CZMQ_EXPORT void
116 zproxy_test (bool verbose);
117 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zproxy\&.c\*(Aq\&.
118 .fi
119 .SH "DESCRIPTION"
120 .sp
121 A zproxy actor switches messages between a frontend and a backend socket\&. It acts much like the zmq_proxy_steerable method, though it makes benefit of CZMQ\(cqs facilities, to be somewhat simpler to set\-up\&.
122 .sp
123 This class replaces zproxy_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock)\&.
124 .SH "EXAMPLE"
125 .PP
126 \fBFrom zproxy_test method\fR.
127 .sp
128 .if n \{\
129 .RS 4
130 .\}
131 .nf
132 // Create and configure our proxy
133 zactor_t *proxy = zactor_new (zproxy, NULL);
134 assert (proxy);
135 if (verbose) {
136 zstr_sendx (proxy, "VERBOSE", NULL);
137 zsock_wait (proxy);
138 }
139 zstr_sendx (proxy, "FRONTEND", "PULL", "inproc://frontend", NULL);
140 zsock_wait (proxy);
141 zstr_sendx (proxy, "BACKEND", "PUSH", "inproc://backend", NULL);
142 zsock_wait (proxy);
143
144 // Connect application sockets to proxy
145 zsock_t *faucet = zsock_new_push (">inproc://frontend");
146 assert (faucet);
147 zsock_t *sink = zsock_new_pull (">inproc://backend");
148 assert (sink);
149
150 // Send some messages and check they arrived
151 char *hello, *world;
152 zstr_sendx (faucet, "Hello", "World", NULL);
153 zstr_recvx (sink, &hello, &world, NULL);
154 assert (streq (hello, "Hello"));
155 assert (streq (world, "World"));
156 zstr_free (&hello);
157 zstr_free (&world);
158
159 // Test pause/resume functionality
160 zstr_sendx (proxy, "PAUSE", NULL);
161 zsock_wait (proxy);
162 zstr_sendx (faucet, "Hello", "World", NULL);
163 zsock_set_rcvtimeo (sink, 100);
164 zstr_recvx (sink, &hello, &world, NULL);
165 assert (!hello && !world);
166
167 zstr_sendx (proxy, "RESUME", NULL);
168 zsock_wait (proxy);
169 zstr_recvx (sink, &hello, &world, NULL);
170 assert (streq (hello, "Hello"));
171 assert (streq (world, "World"));
172 zstr_free (&hello);
173 zstr_free (&world);
174
175 // Test capture functionality
176 zsock_t *capture = zsock_new_pull ("inproc://capture");
177 assert (capture);
178
179 // Switch on capturing, check that it works
180 zstr_sendx (proxy, "CAPTURE", "inproc://capture", NULL);
181 zsock_wait (proxy);
182 zstr_sendx (faucet, "Hello", "World", NULL);
183 zstr_recvx (sink, &hello, &world, NULL);
184 assert (streq (hello, "Hello"));
185 assert (streq (world, "World"));
186 zstr_free (&hello);
187 zstr_free (&world);
188
189 zstr_recvx (capture, &hello, &world, NULL);
190 assert (streq (hello, "Hello"));
191 assert (streq (world, "World"));
192 zstr_free (&hello);
193 zstr_free (&world);
194
195 zsock_destroy (&faucet);
196 zsock_destroy (&sink);
197 zsock_destroy (&capture);
198 zactor_destroy (&proxy);
199
200 // Test socket creation dependency
201 proxy = zactor_new (zproxy, NULL);
202 assert (proxy);
203
204 sink = zsock_new_sub (">ipc://backend", "whatever");
205 assert (sink);
206
207 zstr_sendx (proxy, "BACKEND", "XPUB", "ipc://backend", NULL);
208 zsock_wait (proxy);
209
210 zsock_destroy(&sink);
211 zactor_destroy(&proxy);
212
213 #if (ZMQ_VERSION_MAJOR == 4)
214 // Test authentication functionality
215 # define TESTDIR "\&.test_zproxy"
216
217 // Create temporary directory for test files
218 zsys_dir_create (TESTDIR);
219
220 char *frontend = NULL;
221 char *backend = NULL;
222
223 // Check there\*(Aqs no authentication
224 s_create_test_sockets (&proxy, &faucet, &sink, verbose);
225 s_bind_test_sockets (proxy, &frontend, &backend);
226 bool success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose);
227 assert (success);
228
229 // Install the authenticator
230 zactor_t *auth = zactor_new (zauth, NULL);
231 assert (auth);
232 if (verbose) {
233 zstr_sendx (auth, "VERBOSE", NULL);
234 zsock_wait (auth);
235 }
236
237 // Check there\*(Aqs no authentication on a default NULL server
238 s_bind_test_sockets (proxy, &frontend, &backend);
239 success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose);
240 assert (success);
241
242 // When we set a domain on the server, we switch on authentication
243 // for NULL sockets, but with no policies, the client connection
244 // will be allowed\&.
245 zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL);
246 zsock_wait (proxy);
247 s_bind_test_sockets (proxy, &frontend, &backend);
248 success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose);
249 assert (success);
250
251 // Blacklist 127\&.0\&.0\&.1, connection should fail
252 zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL);
253 zsock_wait (proxy);
254 s_bind_test_sockets (proxy, &frontend, &backend);
255 zstr_sendx (auth, "DENY", "127\&.0\&.0\&.1", NULL);
256 zsock_wait (auth);
257 success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose);
258 assert (!success);
259
260 // Whitelist our address, which overrides the blacklist
261 zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL);
262 zsock_wait (proxy);
263 zstr_sendx (proxy, "DOMAIN", "BACKEND", "global", NULL);
264 zsock_wait (proxy);
265 s_bind_test_sockets (proxy, &frontend, &backend);
266 zstr_sendx (auth, "ALLOW", "127\&.0\&.0\&.1", NULL);
267 zsock_wait (auth);
268 success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose);
269 assert (success);
270
271 // Try PLAIN authentication
272
273 // Test negative case (no server\-side passwords defined)
274 zstr_sendx (proxy, "PLAIN", "FRONTEND", NULL);
275 zsock_wait (proxy);
276 s_bind_test_sockets (proxy, &frontend, &backend);
277 zsock_set_plain_username (faucet, "admin");
278 zsock_set_plain_password (faucet, "Password");
279 success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose);
280 assert (!success);
281
282 // Test positive case (server\-side passwords defined)
283 FILE *password = fopen (TESTDIR "/password\-file", "w");
284 assert (password);
285 fprintf (password, "admin=Password\en");
286 fclose (password);
287 zstr_sendx (proxy, "PLAIN", "FRONTEND", NULL);
288 zsock_wait (proxy);
289 zstr_sendx (proxy, "PLAIN", "BACKEND", NULL);
290 zsock_wait (proxy);
291 s_bind_test_sockets (proxy, &frontend, &backend);
292 zsock_set_plain_username (faucet, "admin");
293 zsock_set_plain_password (faucet, "Password");
294 zsock_set_plain_username (sink, "admin");
295 zsock_set_plain_password (sink, "Password");
296 zstr_sendx (auth, "PLAIN", TESTDIR "/password\-file", NULL);
297 zsock_wait (auth);
298 success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose);
299 assert (success);
300
301 // Test negative case (bad client password)
302 zstr_sendx (proxy, "PLAIN", "FRONTEND", NULL);
303 zsock_wait (proxy);
304 s_bind_test_sockets (proxy, &frontend, &backend);
305 zsock_set_plain_username (faucet, "admin");
306 zsock_set_plain_password (faucet, "Bogus");
307 success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose);
308 assert (!success);
309
310 if (zsys_has_curve ()) {
311 // We\*(Aqll create two new certificates and save the client public
312 // certificate on disk
313 zcert_t *server_cert = zcert_new ();
314 assert (server_cert);
315 zcert_t *client_cert = zcert_new ();
316 assert (client_cert);
317 const char *public_key = zcert_public_txt (server_cert);
318 const char *secret_key = zcert_secret_txt (server_cert);
319
320 // Try CURVE authentication
321
322 // Test without setting\-up any authentication
323 zstr_sendx (proxy, "CURVE", "FRONTEND", public_key, secret_key, NULL);
324 zsock_wait (proxy);
325 s_bind_test_sockets (proxy, &frontend, &backend);
326 zcert_apply (client_cert, faucet);
327 zsock_set_curve_serverkey (faucet, public_key);
328 success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose);
329 assert (!success);
330
331 // Test CURVE_ALLOW_ANY
332 zstr_sendx (proxy, "CURVE", "FRONTEND", public_key, secret_key, NULL);
333 zsock_wait (proxy);
334 s_bind_test_sockets (proxy, &frontend, &backend);
335 zcert_apply (client_cert, faucet);
336 zsock_set_curve_serverkey (faucet, public_key);
337 zstr_sendx (auth, "CURVE", CURVE_ALLOW_ANY, NULL);
338 zsock_wait (auth);
339 success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose);
340 assert (success);
341
342 // Test with client certificate file in authentication folder
343 zstr_sendx (proxy, "CURVE", "FRONTEND", public_key, secret_key, NULL);
344 zsock_wait (proxy);
345 zstr_sendx (proxy, "CURVE", "BACKEND", public_key, secret_key, NULL);
346 zsock_wait (proxy);
347 s_bind_test_sockets (proxy, &frontend, &backend);
348 zcert_apply (client_cert, faucet);
349 zsock_set_curve_serverkey (faucet, public_key);
350 zcert_apply (client_cert, sink);
351 zsock_set_curve_serverkey (sink, public_key);
352 zcert_save_public (client_cert, TESTDIR "/mycert\&.txt");
353 zstr_sendx (auth, "CURVE", TESTDIR, NULL);
354 zsock_wait (auth);
355 success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose);
356 assert (success);
357
358 zcert_destroy (&server_cert);
359 zcert_destroy (&client_cert);
360 }
361
362 // Remove the authenticator and check a normal connection works
363 zactor_destroy (&auth);
364 s_bind_test_sockets (proxy, &frontend, &backend);
365 success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose);
366 assert (success);
367
368 // Cleanup
369 zsock_destroy (&faucet);
370 zsock_destroy (&sink);
371 zactor_destroy (&proxy);
372 zstr_free (&frontend);
373 zstr_free (&backend);
374
375 // Delete temporary directory and test files
376 zsys_file_delete (TESTDIR "/password\-file");
377 zsys_file_delete (TESTDIR "/mycert\&.txt");
378 zsys_dir_delete (TESTDIR);
379 #endif
380 .fi
381 .if n \{\
382 .RE
383 .\}
384 .sp
385 .SH "AUTHORS"
386 .sp
387 The czmq manual was written by the authors in the AUTHORS file\&.
388 .SH "RESOURCES"
389 .sp
390 Main web site: \m[blue]\fB\%\fR\m[]
391 .sp
392 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
393 .SH "COPYRIGHT"
394 .sp
395 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
396 .SH "NOTES"
397 .IP " 1." 4
398 zeromq-dev@lists.zeromq.org
399 .RS 4
400 \%mailto:zeromq-dev@lists.zeromq.org
401 .RE
9090 // Selftest
9191 CZMQ_EXPORT void
9292 zproxy_test (bool verbose);
93 Please add '@interface' section in './../src/zproxy.c'.
9394 ----
9495
9596 DESCRIPTION
0 '\" t
1 .\" Title: zrex
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZREX" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zrex \- work with regular expressions
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // Constructor\&. Optionally, sets an expression against which we can match
35 // text and capture hits\&. If there is an error in the expression, reports
36 // zrex_valid() as false and provides the error in zrex_strerror()\&. If you
37 // set a pattern, you can call zrex_matches() to test it against text\&.
38 CZMQ_EXPORT zrex_t *
39 zrex_new (const char *expression);
40
41 // Destructor
42 CZMQ_EXPORT void
43 zrex_destroy (zrex_t **self_p);
44
45 // Return true if the expression was valid and compiled without errors\&.
46 CZMQ_EXPORT bool
47 zrex_valid (zrex_t *self);
48
49 // Return the error message generated during compilation of the expression\&.
50 CZMQ_EXPORT const char *
51 zrex_strerror (zrex_t *self);
52
53 // Returns true if the text matches the previously compiled expression\&.
54 // Use this method to compare one expression against many strings\&.
55 CZMQ_EXPORT bool
56 zrex_matches (zrex_t *self, const char *text);
57
58 // Returns true if the text matches the supplied expression\&. Use this
59 // method to compare one string against several expressions\&.
60 CZMQ_EXPORT bool
61 zrex_eq (zrex_t *self, const char *text, const char *expression);
62
63 // Returns number of hits from last zrex_matches or zrex_eq\&. If the text
64 // matched, returns 1 plus the number of capture groups\&. If the text did
65 // not match, returns zero\&. To retrieve individual capture groups, call
66 // zrex_hit ()\&.
67 CZMQ_EXPORT int
68 zrex_hits (zrex_t *self);
69
70 // Returns the Nth capture group from the last expression match, where
71 // N is 0 to the value returned by zrex_hits()\&. Capture group 0 is the
72 // whole matching string\&. Sequence 1 is the first capture group, if any,
73 // and so on\&.
74 CZMQ_EXPORT const char *
75 zrex_hit (zrex_t *self, uint index);
76
77 // Fetches hits into string variables provided by caller; this makes for
78 // nicer code than accessing hits by index\&. Caller should not modify nor
79 // free the returned values\&. Returns number of strings returned\&. This
80 // method starts at hit 1, i\&.e\&. first capture group, as hit 0 is always
81 // the original matched string\&.
82 CZMQ_EXPORT int
83 zrex_fetch (zrex_t *self, const char **string_p, \&.\&.\&.);
84
85 // Self test of this class
86 CZMQ_EXPORT void
87 zrex_test (bool verbose);
88 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zrex\&.c\*(Aq\&.
89 .fi
90 .SH "DESCRIPTION"
91 .sp
92 Wraps a very simple regular expression library (SLRE) as a CZMQ class\&. Supports this syntax:
93 .sp
94 .if n \{\
95 .RS 4
96 .\}
97 .nf
98 ^ Match beginning of a buffer
99 $ Match end of a buffer
100 () Grouping and substring capturing
101 [\&.\&.\&.] Match any character from set
102 [^\&.\&.\&.] Match any character but ones from set
103 \&. Match any character
104 \es Match whitespace
105 \eS Match non\-whitespace
106 \ed Match decimal digit
107 \eD Match non decimal digit
108 \ea Match alphabetic character
109 \eA Match non\-alphabetic character
110 \ew Match alphanumeric character
111 \eW Match non\-alphanumeric character
112 \er Match carriage return
113 \en Match newline
114 + Match one or more times (greedy)
115 +? Match one or more times (non\-greedy)
116 * Match zero or more times (greedy)
117 *? Match zero or more times (non\-greedy)
118 ? Match zero or once
119 \exDD Match byte with hex value 0xDD
120 \emeta Match one of the meta character: ^$()\&.[*+?\e
121 .fi
122 .if n \{\
123 .RE
124 .\}
125 .sp
126 Please add \fI@discuss\fR section in \fI\&./\&.\&./src/zrex\&.c\fR\&.
127 .SH "EXAMPLE"
128 .PP
129 \fBFrom zrex_test method\fR.
130 .sp
131 .if n \{\
132 .RS 4
133 .\}
134 .nf
135 // This shows the pattern of matching many lines to a single pattern
136 zrex_t *rex = zrex_new ("\e\ed+\-\e\ed+\-\e\ed+");
137 assert (rex);
138 assert (zrex_valid (rex));
139 bool matches = zrex_matches (rex, "123\-456\-789");
140 assert (matches);
141 assert (zrex_hits (rex) == 1);
142 assert (streq (zrex_hit (rex, 0), "123\-456\-789"));
143 assert (zrex_hit (rex, 1) == NULL);
144 zrex_destroy (&rex);
145
146 // Here we pick out hits using capture groups
147 rex = zrex_new ("(\e\ed+)\-(\e\ed+)\-(\e\ed+)");
148 assert (rex);
149 assert (zrex_valid (rex));
150 matches = zrex_matches (rex, "123\-456\-ABC");
151 assert (!matches);
152 matches = zrex_matches (rex, "123\-456\-789");
153 assert (matches);
154 assert (zrex_hits (rex) == 4);
155 assert (streq (zrex_hit (rex, 0), "123\-456\-789"));
156 assert (streq (zrex_hit (rex, 1), "123"));
157 assert (streq (zrex_hit (rex, 2), "456"));
158 assert (streq (zrex_hit (rex, 3), "789"));
159 zrex_destroy (&rex);
160
161 // This shows the pattern of matching one line against many
162 // patterns and then handling the case when it hits
163 rex = zrex_new (NULL); // No initial pattern
164 assert (rex);
165 char *input = "Mechanism: CURVE";
166 matches = zrex_eq (rex, input, "Version: (\&.+)");
167 assert (!matches);
168 assert (zrex_hits (rex) == 0);
169 matches = zrex_eq (rex, input, "Mechanism: (\&.+)");
170 assert (matches);
171 assert (zrex_hits (rex) == 2);
172 const char *mechanism;
173 zrex_fetch (rex, &mechanism, NULL);
174 assert (streq (zrex_hit (rex, 1), "CURVE"));
175 assert (streq (mechanism, "CURVE"));
176 zrex_destroy (&rex);
177 .fi
178 .if n \{\
179 .RE
180 .\}
181 .sp
182 .SH "AUTHORS"
183 .sp
184 The czmq manual was written by the authors in the AUTHORS file\&.
185 .SH "RESOURCES"
186 .sp
187 Main web site: \m[blue]\fB\%\fR\m[]
188 .sp
189 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
190 .SH "COPYRIGHT"
191 .sp
192 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
193 .SH "NOTES"
194 .IP " 1." 4
195 zeromq-dev@lists.zeromq.org
196 .RS 4
197 \%mailto:zeromq-dev@lists.zeromq.org
198 .RE
6161 // Self test of this class
6262 CZMQ_EXPORT void
6363 zrex_test (bool verbose);
64 Please add '@interface' section in './../src/zrex.c'.
6465 ----
6566
6667 DESCRIPTION
9394 \xDD Match byte with hex value 0xDD
9495 \meta Match one of the meta character: ^$().[*+?\
9596
96 Please add @discuss section in ../src/zrex.c.
97 Please add '@discuss' section in './../src/zrex.c'.
9798
9899 EXAMPLE
99100 -------
0 '\" t
1 .\" Title: zsock
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZSOCK" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zsock \- high\-level socket API that hides libzmq contexts and sockets
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // This class has draft methods, which may change over time\&. They are not
37 // in stable releases, by default\&. Use \-\-enable\-drafts to enable\&.
38 // Create a new socket\&. Returns the new socket, or NULL if the new socket
39 // could not be created\&. Note that the symbol zsock_new (and other
40 // constructors/destructors for zsock) are redirected to the *_checked
41 // variant, enabling intelligent socket leak detection\&. This can have
42 // performance implications if you use a LOT of sockets\&. To turn off this
43 // redirection behaviour, define ZSOCK_NOCHECK\&.
44 CZMQ_EXPORT zsock_t *
45 zsock_new (int type);
46
47 // Create a PUB socket\&. Default action is bind\&.
48 CZMQ_EXPORT zsock_t *
49 zsock_new_pub (const char *endpoint);
50
51 // Create a SUB socket, and optionally subscribe to some prefix string\&. Default
52 // action is connect\&.
53 CZMQ_EXPORT zsock_t *
54 zsock_new_sub (const char *endpoint, const char *subscribe);
55
56 // Create a REQ socket\&. Default action is connect\&.
57 CZMQ_EXPORT zsock_t *
58 zsock_new_req (const char *endpoint);
59
60 // Create a REP socket\&. Default action is bind\&.
61 CZMQ_EXPORT zsock_t *
62 zsock_new_rep (const char *endpoint);
63
64 // Create a DEALER socket\&. Default action is connect\&.
65 CZMQ_EXPORT zsock_t *
66 zsock_new_dealer (const char *endpoint);
67
68 // Create a ROUTER socket\&. Default action is bind\&.
69 CZMQ_EXPORT zsock_t *
70 zsock_new_router (const char *endpoint);
71
72 // Create a PUSH socket\&. Default action is connect\&.
73 CZMQ_EXPORT zsock_t *
74 zsock_new_push (const char *endpoint);
75
76 // Create a PULL socket\&. Default action is bind\&.
77 CZMQ_EXPORT zsock_t *
78 zsock_new_pull (const char *endpoint);
79
80 // Create an XPUB socket\&. Default action is bind\&.
81 CZMQ_EXPORT zsock_t *
82 zsock_new_xpub (const char *endpoint);
83
84 // Create an XSUB socket\&. Default action is connect\&.
85 CZMQ_EXPORT zsock_t *
86 zsock_new_xsub (const char *endpoint);
87
88 // Create a PAIR socket\&. Default action is connect\&.
89 CZMQ_EXPORT zsock_t *
90 zsock_new_pair (const char *endpoint);
91
92 // Create a STREAM socket\&. Default action is connect\&.
93 CZMQ_EXPORT zsock_t *
94 zsock_new_stream (const char *endpoint);
95
96 // Destroy the socket\&. You must use this for any socket created via the
97 // zsock_new method\&.
98 CZMQ_EXPORT void
99 zsock_destroy (zsock_t **self_p);
100
101 // Bind a socket to a formatted endpoint\&. For tcp:// endpoints, supports
102 // ephemeral ports, if you specify the port number as "*"\&. By default
103 // zsock uses the IANA designated range from C000 (49152) to FFFF (65535)\&.
104 // To override this range, follow the "*" with "[first\-last]"\&. Either or
105 // both first and last may be empty\&. To bind to a random port within the
106 // range, use "!" in place of "*"\&.
107 //
108 // Examples:
109 // tcp://127\&.0\&.0\&.1:* bind to first free port from C000 up
110 // tcp://127\&.0\&.0\&.1:! bind to random port from C000 to FFFF
111 // tcp://127\&.0\&.0\&.1:*[60000\-] bind to first free port from 60000 up
112 // tcp://127\&.0\&.0\&.1:![\-60000] bind to random port from C000 to 60000
113 // tcp://127\&.0\&.0\&.1:![55000\-55999]
114 // bind to random port from 55000 to 55999
115 //
116 // On success, returns the actual port number used, for tcp:// endpoints,
117 // and 0 for other transports\&. On failure, returns \-1\&. Note that when using
118 // ephemeral ports, a port may be reused by different services without
119 // clients being aware\&. Protocols that run on ephemeral ports should take
120 // this into account\&.
121 CZMQ_EXPORT int
122 zsock_bind (zsock_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2);
123
124 // Returns last bound endpoint, if any\&.
125 CZMQ_EXPORT const char *
126 zsock_endpoint (zsock_t *self);
127
128 // Unbind a socket from a formatted endpoint\&.
129 // Returns 0 if OK, \-1 if the endpoint was invalid or the function
130 // isn\*(Aqt supported\&.
131 CZMQ_EXPORT int
132 zsock_unbind (zsock_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2);
133
134 // Connect a socket to a formatted endpoint
135 // Returns 0 if OK, \-1 if the endpoint was invalid\&.
136 CZMQ_EXPORT int
137 zsock_connect (zsock_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2);
138
139 // Disconnect a socket from a formatted endpoint
140 // Returns 0 if OK, \-1 if the endpoint was invalid or the function
141 // isn\*(Aqt supported\&.
142 CZMQ_EXPORT int
143 zsock_disconnect (zsock_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2);
144
145 // Attach a socket to zero or more endpoints\&. If endpoints is not null,
146 // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by
147 // \*(Aq@\*(Aq (to bind the socket) or \*(Aq>\*(Aq (to connect the socket)\&. Returns 0 if all
148 // endpoints were valid, or \-1 if there was a syntax error\&. If the endpoint
149 // does not start with \*(Aq@\*(Aq or \*(Aq>\*(Aq, the serverish argument defines whether
150 // it is used to bind (serverish = true) or connect (serverish = false)\&.
151 CZMQ_EXPORT int
152 zsock_attach (zsock_t *self, const char *endpoints, bool serverish);
153
154 // Returns socket type as printable constant string\&.
155 CZMQ_EXPORT const char *
156 zsock_type_str (zsock_t *self);
157
158 // Send a \*(Aqpicture\*(Aq message to the socket (or actor)\&. The picture is a
159 // string that defines the type of each frame\&. This makes it easy to send
160 // a complex multiframe message in one call\&. The picture can contain any
161 // of these characters, each corresponding to one or two arguments:
162 //
163 // i = int (signed)
164 // 1 = uint8_t
165 // 2 = uint16_t
166 // 4 = uint32_t
167 // 8 = uint64_t
168 // s = char *
169 // b = byte *, size_t (2 arguments)
170 // c = zchunk_t *
171 // f = zframe_t *
172 // h = zhashx_t *
173 // U = zuuid_t *
174 // p = void * (sends the pointer value, only meaningful over inproc)
175 // m = zmsg_t * (sends all frames in the zmsg)
176 // z = sends zero\-sized frame (0 arguments)
177 // u = uint (deprecated)
178 //
179 // Note that s, b, c, and f are encoded the same way and the choice is
180 // offered as a convenience to the sender, which may or may not already
181 // have data in a zchunk or zframe\&. Does not change or take ownership of
182 // any arguments\&. Returns 0 if successful, \-1 if sending failed for any
183 // reason\&.
184 CZMQ_EXPORT int
185 zsock_send (void *self, const char *picture, \&.\&.\&.);
186
187 // Send a \*(Aqpicture\*(Aq message to the socket (or actor)\&. This is a va_list
188 // version of zsock_send (), so please consult its documentation for the
189 // details\&.
190 CZMQ_EXPORT int
191 zsock_vsend (void *self, const char *picture, va_list argptr);
192
193 // Receive a \*(Aqpicture\*(Aq message to the socket (or actor)\&. See zsock_send for
194 // the format and meaning of the picture\&. Returns the picture elements into
195 // a series of pointers as provided by the caller:
196 //
197 // i = int * (stores signed integer)
198 // 4 = uint32_t * (stores 32\-bit unsigned integer)
199 // 8 = uint64_t * (stores 64\-bit unsigned integer)
200 // s = char ** (allocates new string)
201 // b = byte **, size_t * (2 arguments) (allocates memory)
202 // c = zchunk_t ** (creates zchunk)
203 // f = zframe_t ** (creates zframe)
204 // U = zuuid_t * (creates a zuuid with the data)
205 // h = zhashx_t ** (creates zhashx)
206 // p = void ** (stores pointer)
207 // m = zmsg_t ** (creates a zmsg with the remaing frames)
208 // z = null, asserts empty frame (0 arguments)
209 // u = uint * (stores unsigned integer, deprecated)
210 //
211 // Note that zsock_recv creates the returned objects, and the caller must
212 // destroy them when finished with them\&. The supplied pointers do not need
213 // to be initialized\&. Returns 0 if successful, or \-1 if it failed to recv
214 // a message, in which case the pointers are not modified\&. When message
215 // frames are truncated (a short message), sets return values to zero/null\&.
216 // If an argument pointer is NULL, does not store any value (skips it)\&.
217 // An \*(Aqn\*(Aq picture matches an empty frame; if the message does not match,
218 // the method will return \-1\&.
219 CZMQ_EXPORT int
220 zsock_recv (void *self, const char *picture, \&.\&.\&.);
221
222 // Receive a \*(Aqpicture\*(Aq message from the socket (or actor)\&. This is a
223 // va_list version of zsock_recv (), so please consult its documentation
224 // for the details\&.
225 CZMQ_EXPORT int
226 zsock_vrecv (void *self, const char *picture, va_list argptr);
227
228 // Send a binary encoded \*(Aqpicture\*(Aq message to the socket (or actor)\&. This
229 // method is similar to zsock_send, except the arguments are encoded in a
230 // binary format that is compatible with zproto, and is designed to reduce
231 // memory allocations\&. The pattern argument is a string that defines the
232 // type of each argument\&. Supports these argument types:
233 //
234 // pattern C type zproto type:
235 // 1 uint8_t type = "number" size = "1"
236 // 2 uint16_t type = "number" size = "2"
237 // 4 uint32_t type = "number" size = "3"
238 // 8 uint64_t type = "number" size = "4"
239 // s char *, 0\-255 chars type = "string"
240 // S char *, 0\-2^32\-1 chars type = "longstr"
241 // c zchunk_t * type = "chunk"
242 // f zframe_t * type = "frame"
243 // u zuuid_t * type = "uuid"
244 // m zmsg_t * type = "msg"
245 // p void *, sends pointer value, only over inproc
246 //
247 // Does not change or take ownership of any arguments\&. Returns 0 if
248 // successful, \-1 if sending failed for any reason\&.
249 CZMQ_EXPORT int
250 zsock_bsend (void *self, const char *picture, \&.\&.\&.);
251
252 // Receive a binary encoded \*(Aqpicture\*(Aq message from the socket (or actor)\&.
253 // This method is similar to zsock_recv, except the arguments are encoded
254 // in a binary format that is compatible with zproto, and is designed to
255 // reduce memory allocations\&. The pattern argument is a string that defines
256 // the type of each argument\&. See zsock_bsend for the supported argument
257 // types\&. All arguments must be pointers; this call sets them to point to
258 // values held on a per\-socket basis\&.
259 // Note that zsock_brecv creates the returned objects, and the caller must
260 // destroy them when finished with them\&. The supplied pointers do not need
261 // to be initialized\&. Returns 0 if successful, or \-1 if it failed to read
262 // a message\&.
263 CZMQ_EXPORT int
264 zsock_brecv (void *self, const char *picture, \&.\&.\&.);
265
266 // Set socket to use unbounded pipes (HWM=0); use this in cases when you are
267 // totally certain the message volume can fit in memory\&. This method works
268 // across all versions of ZeroMQ\&. Takes a polymorphic socket reference\&.
269 CZMQ_EXPORT void
270 zsock_set_unbounded (void *self);
271
272 // Send a signal over a socket\&. A signal is a short message carrying a
273 // success/failure code (by convention, 0 means OK)\&. Signals are encoded
274 // to be distinguishable from "normal" messages\&. Accepts a zsock_t or a
275 // zactor_t argument, and returns 0 if successful, \-1 if the signal could
276 // not be sent\&. Takes a polymorphic socket reference\&.
277 CZMQ_EXPORT int
278 zsock_signal (void *self, byte status);
279
280 // Wait on a signal\&. Use this to coordinate between threads, over pipe
281 // pairs\&. Blocks until the signal is received\&. Returns \-1 on error, 0 or
282 // greater on success\&. Accepts a zsock_t or a zactor_t as argument\&.
283 // Takes a polymorphic socket reference\&.
284 CZMQ_EXPORT int
285 zsock_wait (void *self);
286
287 // If there is a partial message still waiting on the socket, remove and
288 // discard it\&. This is useful when reading partial messages, to get specific
289 // message types\&.
290 CZMQ_EXPORT void
291 zsock_flush (void *self);
292
293 // Probe the supplied object, and report if it looks like a zsock_t\&.
294 // Takes a polymorphic socket reference\&.
295 CZMQ_EXPORT bool
296 zsock_is (void *self);
297
298 // Probe the supplied reference\&. If it looks like a zsock_t instance, return
299 // the underlying libzmq socket handle; else if it looks like a file
300 // descriptor, return NULL; else if it looks like a libzmq socket handle,
301 // return the supplied value\&. Takes a polymorphic socket reference\&.
302 CZMQ_EXPORT void *
303 zsock_resolve (void *self);
304
305 // Get socket option `heartbeat_ivl`\&.
306 // Available from libzmq 4\&.2\&.0\&.
307 // Caller owns return value and must destroy it when done\&.
308 CZMQ_EXPORT int
309 zsock_heartbeat_ivl (void *self);
310
311 // Set socket option `heartbeat_ivl`\&.
312 // Available from libzmq 4\&.2\&.0\&.
313 CZMQ_EXPORT void
314 zsock_set_heartbeat_ivl (void *self, int heartbeat_ivl);
315
316 // Get socket option `heartbeat_ttl`\&.
317 // Available from libzmq 4\&.2\&.0\&.
318 // Caller owns return value and must destroy it when done\&.
319 CZMQ_EXPORT int
320 zsock_heartbeat_ttl (void *self);
321
322 // Set socket option `heartbeat_ttl`\&.
323 // Available from libzmq 4\&.2\&.0\&.
324 CZMQ_EXPORT void
325 zsock_set_heartbeat_ttl (void *self, int heartbeat_ttl);
326
327 // Get socket option `heartbeat_timeout`\&.
328 // Available from libzmq 4\&.2\&.0\&.
329 // Caller owns return value and must destroy it when done\&.
330 CZMQ_EXPORT int
331 zsock_heartbeat_timeout (void *self);
332
333 // Set socket option `heartbeat_timeout`\&.
334 // Available from libzmq 4\&.2\&.0\&.
335 CZMQ_EXPORT void
336 zsock_set_heartbeat_timeout (void *self, int heartbeat_timeout);
337
338 // Get socket option `use_fd`\&.
339 // Available from libzmq 4\&.2\&.0\&.
340 // Caller owns return value and must destroy it when done\&.
341 CZMQ_EXPORT int
342 zsock_use_fd (void *self);
343
344 // Set socket option `use_fd`\&.
345 // Available from libzmq 4\&.2\&.0\&.
346 CZMQ_EXPORT void
347 zsock_set_use_fd (void *self, int use_fd);
348
349 // Set socket option `xpub_manual`\&.
350 // Available from libzmq 4\&.2\&.0\&.
351 CZMQ_EXPORT void
352 zsock_set_xpub_manual (void *self, int xpub_manual);
353
354 // Set socket option `xpub_welcome_msg`\&.
355 // Available from libzmq 4\&.2\&.0\&.
356 CZMQ_EXPORT void
357 zsock_set_xpub_welcome_msg (void *self, const char *xpub_welcome_msg);
358
359 // Set socket option `stream_notify`\&.
360 // Available from libzmq 4\&.2\&.0\&.
361 CZMQ_EXPORT void
362 zsock_set_stream_notify (void *self, int stream_notify);
363
364 // Get socket option `invert_matching`\&.
365 // Available from libzmq 4\&.2\&.0\&.
366 // Caller owns return value and must destroy it when done\&.
367 CZMQ_EXPORT int
368 zsock_invert_matching (void *self);
369
370 // Set socket option `invert_matching`\&.
371 // Available from libzmq 4\&.2\&.0\&.
372 CZMQ_EXPORT void
373 zsock_set_invert_matching (void *self, int invert_matching);
374
375 // Set socket option `xpub_verboser`\&.
376 // Available from libzmq 4\&.2\&.0\&.
377 CZMQ_EXPORT void
378 zsock_set_xpub_verboser (void *self, int xpub_verboser);
379
380 // Get socket option `connect_timeout`\&.
381 // Available from libzmq 4\&.2\&.0\&.
382 // Caller owns return value and must destroy it when done\&.
383 CZMQ_EXPORT int
384 zsock_connect_timeout (void *self);
385
386 // Set socket option `connect_timeout`\&.
387 // Available from libzmq 4\&.2\&.0\&.
388 CZMQ_EXPORT void
389 zsock_set_connect_timeout (void *self, int connect_timeout);
390
391 // Get socket option `tcp_maxrt`\&.
392 // Available from libzmq 4\&.2\&.0\&.
393 // Caller owns return value and must destroy it when done\&.
394 CZMQ_EXPORT int
395 zsock_tcp_maxrt (void *self);
396
397 // Set socket option `tcp_maxrt`\&.
398 // Available from libzmq 4\&.2\&.0\&.
399 CZMQ_EXPORT void
400 zsock_set_tcp_maxrt (void *self, int tcp_maxrt);
401
402 // Get socket option `thread_safe`\&.
403 // Available from libzmq 4\&.2\&.0\&.
404 // Caller owns return value and must destroy it when done\&.
405 CZMQ_EXPORT int
406 zsock_thread_safe (void *self);
407
408 // Get socket option `multicast_maxtpdu`\&.
409 // Available from libzmq 4\&.2\&.0\&.
410 // Caller owns return value and must destroy it when done\&.
411 CZMQ_EXPORT int
412 zsock_multicast_maxtpdu (void *self);
413
414 // Set socket option `multicast_maxtpdu`\&.
415 // Available from libzmq 4\&.2\&.0\&.
416 CZMQ_EXPORT void
417 zsock_set_multicast_maxtpdu (void *self, int multicast_maxtpdu);
418
419 // Get socket option `vmci_buffer_size`\&.
420 // Available from libzmq 4\&.2\&.0\&.
421 // Caller owns return value and must destroy it when done\&.
422 CZMQ_EXPORT int
423 zsock_vmci_buffer_size (void *self);
424
425 // Set socket option `vmci_buffer_size`\&.
426 // Available from libzmq 4\&.2\&.0\&.
427 CZMQ_EXPORT void
428 zsock_set_vmci_buffer_size (void *self, int vmci_buffer_size);
429
430 // Get socket option `vmci_buffer_min_size`\&.
431 // Available from libzmq 4\&.2\&.0\&.
432 // Caller owns return value and must destroy it when done\&.
433 CZMQ_EXPORT int
434 zsock_vmci_buffer_min_size (void *self);
435
436 // Set socket option `vmci_buffer_min_size`\&.
437 // Available from libzmq 4\&.2\&.0\&.
438 CZMQ_EXPORT void
439 zsock_set_vmci_buffer_min_size (void *self, int vmci_buffer_min_size);
440
441 // Get socket option `vmci_buffer_max_size`\&.
442 // Available from libzmq 4\&.2\&.0\&.
443 // Caller owns return value and must destroy it when done\&.
444 CZMQ_EXPORT int
445 zsock_vmci_buffer_max_size (void *self);
446
447 // Set socket option `vmci_buffer_max_size`\&.
448 // Available from libzmq 4\&.2\&.0\&.
449 CZMQ_EXPORT void
450 zsock_set_vmci_buffer_max_size (void *self, int vmci_buffer_max_size);
451
452 // Get socket option `vmci_connect_timeout`\&.
453 // Available from libzmq 4\&.2\&.0\&.
454 // Caller owns return value and must destroy it when done\&.
455 CZMQ_EXPORT int
456 zsock_vmci_connect_timeout (void *self);
457
458 // Set socket option `vmci_connect_timeout`\&.
459 // Available from libzmq 4\&.2\&.0\&.
460 CZMQ_EXPORT void
461 zsock_set_vmci_connect_timeout (void *self, int vmci_connect_timeout);
462
463 // Get socket option `tos`\&.
464 // Available from libzmq 4\&.1\&.0\&.
465 // Caller owns return value and must destroy it when done\&.
466 CZMQ_EXPORT int
467 zsock_tos (void *self);
468
469 // Set socket option `tos`\&.
470 // Available from libzmq 4\&.1\&.0\&.
471 CZMQ_EXPORT void
472 zsock_set_tos (void *self, int tos);
473
474 // Set socket option `router_handover`\&.
475 // Available from libzmq 4\&.1\&.0\&.
476 CZMQ_EXPORT void
477 zsock_set_router_handover (void *self, int router_handover);
478
479 // Set socket option `connect_rid`\&.
480 // Available from libzmq 4\&.1\&.0\&.
481 CZMQ_EXPORT void
482 zsock_set_connect_rid (void *self, const char *connect_rid);
483
484 // Set socket option `connect_rid` from 32\-octet binary
485 // Available from libzmq 4\&.1\&.0\&.
486 CZMQ_EXPORT void
487 zsock_set_connect_rid_bin (void *self, const byte *connect_rid);
488
489 // Get socket option `handshake_ivl`\&.
490 // Available from libzmq 4\&.1\&.0\&.
491 // Caller owns return value and must destroy it when done\&.
492 CZMQ_EXPORT int
493 zsock_handshake_ivl (void *self);
494
495 // Set socket option `handshake_ivl`\&.
496 // Available from libzmq 4\&.1\&.0\&.
497 CZMQ_EXPORT void
498 zsock_set_handshake_ivl (void *self, int handshake_ivl);
499
500 // Get socket option `socks_proxy`\&.
501 // Available from libzmq 4\&.1\&.0\&.
502 // Caller owns return value and must destroy it when done\&.
503 CZMQ_EXPORT char *
504 zsock_socks_proxy (void *self);
505
506 // Set socket option `socks_proxy`\&.
507 // Available from libzmq 4\&.1\&.0\&.
508 CZMQ_EXPORT void
509 zsock_set_socks_proxy (void *self, const char *socks_proxy);
510
511 // Set socket option `xpub_nodrop`\&.
512 // Available from libzmq 4\&.1\&.0\&.
513 CZMQ_EXPORT void
514 zsock_set_xpub_nodrop (void *self, int xpub_nodrop);
515
516 // Set socket option `router_mandatory`\&.
517 // Available from libzmq 4\&.0\&.0\&.
518 CZMQ_EXPORT void
519 zsock_set_router_mandatory (void *self, int router_mandatory);
520
521 // Set socket option `probe_router`\&.
522 // Available from libzmq 4\&.0\&.0\&.
523 CZMQ_EXPORT void
524 zsock_set_probe_router (void *self, int probe_router);
525
526 // Set socket option `req_relaxed`\&.
527 // Available from libzmq 4\&.0\&.0\&.
528 CZMQ_EXPORT void
529 zsock_set_req_relaxed (void *self, int req_relaxed);
530
531 // Set socket option `req_correlate`\&.
532 // Available from libzmq 4\&.0\&.0\&.
533 CZMQ_EXPORT void
534 zsock_set_req_correlate (void *self, int req_correlate);
535
536 // Set socket option `conflate`\&.
537 // Available from libzmq 4\&.0\&.0\&.
538 CZMQ_EXPORT void
539 zsock_set_conflate (void *self, int conflate);
540
541 // Get socket option `zap_domain`\&.
542 // Available from libzmq 4\&.0\&.0\&.
543 // Caller owns return value and must destroy it when done\&.
544 CZMQ_EXPORT char *
545 zsock_zap_domain (void *self);
546
547 // Set socket option `zap_domain`\&.
548 // Available from libzmq 4\&.0\&.0\&.
549 CZMQ_EXPORT void
550 zsock_set_zap_domain (void *self, const char *zap_domain);
551
552 // Get socket option `mechanism`\&.
553 // Available from libzmq 4\&.0\&.0\&.
554 // Caller owns return value and must destroy it when done\&.
555 CZMQ_EXPORT int
556 zsock_mechanism (void *self);
557
558 // Get socket option `plain_server`\&.
559 // Available from libzmq 4\&.0\&.0\&.
560 // Caller owns return value and must destroy it when done\&.
561 CZMQ_EXPORT int
562 zsock_plain_server (void *self);
563
564 // Set socket option `plain_server`\&.
565 // Available from libzmq 4\&.0\&.0\&.
566 CZMQ_EXPORT void
567 zsock_set_plain_server (void *self, int plain_server);
568
569 // Get socket option `plain_username`\&.
570 // Available from libzmq 4\&.0\&.0\&.
571 // Caller owns return value and must destroy it when done\&.
572 CZMQ_EXPORT char *
573 zsock_plain_username (void *self);
574
575 // Set socket option `plain_username`\&.
576 // Available from libzmq 4\&.0\&.0\&.
577 CZMQ_EXPORT void
578 zsock_set_plain_username (void *self, const char *plain_username);
579
580 // Get socket option `plain_password`\&.
581 // Available from libzmq 4\&.0\&.0\&.
582 // Caller owns return value and must destroy it when done\&.
583 CZMQ_EXPORT char *
584 zsock_plain_password (void *self);
585
586 // Set socket option `plain_password`\&.
587 // Available from libzmq 4\&.0\&.0\&.
588 CZMQ_EXPORT void
589 zsock_set_plain_password (void *self, const char *plain_password);
590
591 // Get socket option `curve_server`\&.
592 // Available from libzmq 4\&.0\&.0\&.
593 // Caller owns return value and must destroy it when done\&.
594 CZMQ_EXPORT int
595 zsock_curve_server (void *self);
596
597 // Set socket option `curve_server`\&.
598 // Available from libzmq 4\&.0\&.0\&.
599 CZMQ_EXPORT void
600 zsock_set_curve_server (void *self, int curve_server);
601
602 // Get socket option `curve_publickey`\&.
603 // Available from libzmq 4\&.0\&.0\&.
604 // Caller owns return value and must destroy it when done\&.
605 CZMQ_EXPORT char *
606 zsock_curve_publickey (void *self);
607
608 // Set socket option `curve_publickey`\&.
609 // Available from libzmq 4\&.0\&.0\&.
610 CZMQ_EXPORT void
611 zsock_set_curve_publickey (void *self, const char *curve_publickey);
612
613 // Set socket option `curve_publickey` from 32\-octet binary
614 // Available from libzmq 4\&.0\&.0\&.
615 CZMQ_EXPORT void
616 zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey);
617
618 // Get socket option `curve_secretkey`\&.
619 // Available from libzmq 4\&.0\&.0\&.
620 // Caller owns return value and must destroy it when done\&.
621 CZMQ_EXPORT char *
622 zsock_curve_secretkey (void *self);
623
624 // Set socket option `curve_secretkey`\&.
625 // Available from libzmq 4\&.0\&.0\&.
626 CZMQ_EXPORT void
627 zsock_set_curve_secretkey (void *self, const char *curve_secretkey);
628
629 // Set socket option `curve_secretkey` from 32\-octet binary
630 // Available from libzmq 4\&.0\&.0\&.
631 CZMQ_EXPORT void
632 zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey);
633
634 // Get socket option `curve_serverkey`\&.
635 // Available from libzmq 4\&.0\&.0\&.
636 // Caller owns return value and must destroy it when done\&.
637 CZMQ_EXPORT char *
638 zsock_curve_serverkey (void *self);
639
640 // Set socket option `curve_serverkey`\&.
641 // Available from libzmq 4\&.0\&.0\&.
642 CZMQ_EXPORT void
643 zsock_set_curve_serverkey (void *self, const char *curve_serverkey);
644
645 // Set socket option `curve_serverkey` from 32\-octet binary
646 // Available from libzmq 4\&.0\&.0\&.
647 CZMQ_EXPORT void
648 zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey);
649
650 // Get socket option `gssapi_server`\&.
651 // Available from libzmq 4\&.0\&.0\&.
652 // Caller owns return value and must destroy it when done\&.
653 CZMQ_EXPORT int
654 zsock_gssapi_server (void *self);
655
656 // Set socket option `gssapi_server`\&.
657 // Available from libzmq 4\&.0\&.0\&.
658 CZMQ_EXPORT void
659 zsock_set_gssapi_server (void *self, int gssapi_server);
660
661 // Get socket option `gssapi_plaintext`\&.
662 // Available from libzmq 4\&.0\&.0\&.
663 // Caller owns return value and must destroy it when done\&.
664 CZMQ_EXPORT int
665 zsock_gssapi_plaintext (void *self);
666
667 // Set socket option `gssapi_plaintext`\&.
668 // Available from libzmq 4\&.0\&.0\&.
669 CZMQ_EXPORT void
670 zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext);
671
672 // Get socket option `gssapi_principal`\&.
673 // Available from libzmq 4\&.0\&.0\&.
674 // Caller owns return value and must destroy it when done\&.
675 CZMQ_EXPORT char *
676 zsock_gssapi_principal (void *self);
677
678 // Set socket option `gssapi_principal`\&.
679 // Available from libzmq 4\&.0\&.0\&.
680 CZMQ_EXPORT void
681 zsock_set_gssapi_principal (void *self, const char *gssapi_principal);
682
683 // Get socket option `gssapi_service_principal`\&.
684 // Available from libzmq 4\&.0\&.0\&.
685 // Caller owns return value and must destroy it when done\&.
686 CZMQ_EXPORT char *
687 zsock_gssapi_service_principal (void *self);
688
689 // Set socket option `gssapi_service_principal`\&.
690 // Available from libzmq 4\&.0\&.0\&.
691 CZMQ_EXPORT void
692 zsock_set_gssapi_service_principal (void *self, const char *gssapi_service_principal);
693
694 // Get socket option `ipv6`\&.
695 // Available from libzmq 4\&.0\&.0\&.
696 // Caller owns return value and must destroy it when done\&.
697 CZMQ_EXPORT int
698 zsock_ipv6 (void *self);
699
700 // Set socket option `ipv6`\&.
701 // Available from libzmq 4\&.0\&.0\&.
702 CZMQ_EXPORT void
703 zsock_set_ipv6 (void *self, int ipv6);
704
705 // Get socket option `immediate`\&.
706 // Available from libzmq 4\&.0\&.0\&.
707 // Caller owns return value and must destroy it when done\&.
708 CZMQ_EXPORT int
709 zsock_immediate (void *self);
710
711 // Set socket option `immediate`\&.
712 // Available from libzmq 4\&.0\&.0\&.
713 CZMQ_EXPORT void
714 zsock_set_immediate (void *self, int immediate);
715
716 // Get socket option `type`\&.
717 // Available from libzmq 3\&.0\&.0\&.
718 // Caller owns return value and must destroy it when done\&.
719 CZMQ_EXPORT int
720 zsock_type (void *self);
721
722 // Get socket option `sndhwm`\&.
723 // Available from libzmq 3\&.0\&.0\&.
724 // Caller owns return value and must destroy it when done\&.
725 CZMQ_EXPORT int
726 zsock_sndhwm (void *self);
727
728 // Set socket option `sndhwm`\&.
729 // Available from libzmq 3\&.0\&.0\&.
730 CZMQ_EXPORT void
731 zsock_set_sndhwm (void *self, int sndhwm);
732
733 // Get socket option `rcvhwm`\&.
734 // Available from libzmq 3\&.0\&.0\&.
735 // Caller owns return value and must destroy it when done\&.
736 CZMQ_EXPORT int
737 zsock_rcvhwm (void *self);
738
739 // Set socket option `rcvhwm`\&.
740 // Available from libzmq 3\&.0\&.0\&.
741 CZMQ_EXPORT void
742 zsock_set_rcvhwm (void *self, int rcvhwm);
743
744 // Get socket option `affinity`\&.
745 // Available from libzmq 3\&.0\&.0\&.
746 // Caller owns return value and must destroy it when done\&.
747 CZMQ_EXPORT int
748 zsock_affinity (void *self);
749
750 // Set socket option `affinity`\&.
751 // Available from libzmq 3\&.0\&.0\&.
752 CZMQ_EXPORT void
753 zsock_set_affinity (void *self, int affinity);
754
755 // Set socket option `subscribe`\&.
756 // Available from libzmq 3\&.0\&.0\&.
757 CZMQ_EXPORT void
758 zsock_set_subscribe (void *self, const char *subscribe);
759
760 // Set socket option `unsubscribe`\&.
761 // Available from libzmq 3\&.0\&.0\&.
762 CZMQ_EXPORT void
763 zsock_set_unsubscribe (void *self, const char *unsubscribe);
764
765 // Get socket option `identity`\&.
766 // Available from libzmq 3\&.0\&.0\&.
767 // Caller owns return value and must destroy it when done\&.
768 CZMQ_EXPORT char *
769 zsock_identity (void *self);
770
771 // Set socket option `identity`\&.
772 // Available from libzmq 3\&.0\&.0\&.
773 CZMQ_EXPORT void
774 zsock_set_identity (void *self, const char *identity);
775
776 // Get socket option `rate`\&.
777 // Available from libzmq 3\&.0\&.0\&.
778 // Caller owns return value and must destroy it when done\&.
779 CZMQ_EXPORT int
780 zsock_rate (void *self);
781
782 // Set socket option `rate`\&.
783 // Available from libzmq 3\&.0\&.0\&.
784 CZMQ_EXPORT void
785 zsock_set_rate (void *self, int rate);
786
787 // Get socket option `recovery_ivl`\&.
788 // Available from libzmq 3\&.0\&.0\&.
789 // Caller owns return value and must destroy it when done\&.
790 CZMQ_EXPORT int
791 zsock_recovery_ivl (void *self);
792
793 // Set socket option `recovery_ivl`\&.
794 // Available from libzmq 3\&.0\&.0\&.
795 CZMQ_EXPORT void
796 zsock_set_recovery_ivl (void *self, int recovery_ivl);
797
798 // Get socket option `sndbuf`\&.
799 // Available from libzmq 3\&.0\&.0\&.
800 // Caller owns return value and must destroy it when done\&.
801 CZMQ_EXPORT int
802 zsock_sndbuf (void *self);
803
804 // Set socket option `sndbuf`\&.
805 // Available from libzmq 3\&.0\&.0\&.
806 CZMQ_EXPORT void
807 zsock_set_sndbuf (void *self, int sndbuf);
808
809 // Get socket option `rcvbuf`\&.
810 // Available from libzmq 3\&.0\&.0\&.
811 // Caller owns return value and must destroy it when done\&.
812 CZMQ_EXPORT int
813 zsock_rcvbuf (void *self);
814
815 // Set socket option `rcvbuf`\&.
816 // Available from libzmq 3\&.0\&.0\&.
817 CZMQ_EXPORT void
818 zsock_set_rcvbuf (void *self, int rcvbuf);
819
820 // Get socket option `linger`\&.
821 // Available from libzmq 3\&.0\&.0\&.
822 // Caller owns return value and must destroy it when done\&.
823 CZMQ_EXPORT int
824 zsock_linger (void *self);
825
826 // Set socket option `linger`\&.
827 // Available from libzmq 3\&.0\&.0\&.
828 CZMQ_EXPORT void
829 zsock_set_linger (void *self, int linger);
830
831 // Get socket option `reconnect_ivl`\&.
832 // Available from libzmq 3\&.0\&.0\&.
833 // Caller owns return value and must destroy it when done\&.
834 CZMQ_EXPORT int
835 zsock_reconnect_ivl (void *self);
836
837 // Set socket option `reconnect_ivl`\&.
838 // Available from libzmq 3\&.0\&.0\&.
839 CZMQ_EXPORT void
840 zsock_set_reconnect_ivl (void *self, int reconnect_ivl);
841
842 // Get socket option `reconnect_ivl_max`\&.
843 // Available from libzmq 3\&.0\&.0\&.
844 // Caller owns return value and must destroy it when done\&.
845 CZMQ_EXPORT int
846 zsock_reconnect_ivl_max (void *self);
847
848 // Set socket option `reconnect_ivl_max`\&.
849 // Available from libzmq 3\&.0\&.0\&.
850 CZMQ_EXPORT void
851 zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max);
852
853 // Get socket option `backlog`\&.
854 // Available from libzmq 3\&.0\&.0\&.
855 // Caller owns return value and must destroy it when done\&.
856 CZMQ_EXPORT int
857 zsock_backlog (void *self);
858
859 // Set socket option `backlog`\&.
860 // Available from libzmq 3\&.0\&.0\&.
861 CZMQ_EXPORT void
862 zsock_set_backlog (void *self, int backlog);
863
864 // Get socket option `maxmsgsize`\&.
865 // Available from libzmq 3\&.0\&.0\&.
866 // Caller owns return value and must destroy it when done\&.
867 CZMQ_EXPORT int
868 zsock_maxmsgsize (void *self);
869
870 // Set socket option `maxmsgsize`\&.
871 // Available from libzmq 3\&.0\&.0\&.
872 CZMQ_EXPORT void
873 zsock_set_maxmsgsize (void *self, int maxmsgsize);
874
875 // Get socket option `multicast_hops`\&.
876 // Available from libzmq 3\&.0\&.0\&.
877 // Caller owns return value and must destroy it when done\&.
878 CZMQ_EXPORT int
879 zsock_multicast_hops (void *self);
880
881 // Set socket option `multicast_hops`\&.
882 // Available from libzmq 3\&.0\&.0\&.
883 CZMQ_EXPORT void
884 zsock_set_multicast_hops (void *self, int multicast_hops);
885
886 // Get socket option `rcvtimeo`\&.
887 // Available from libzmq 3\&.0\&.0\&.
888 // Caller owns return value and must destroy it when done\&.
889 CZMQ_EXPORT int
890 zsock_rcvtimeo (void *self);
891
892 // Set socket option `rcvtimeo`\&.
893 // Available from libzmq 3\&.0\&.0\&.
894 CZMQ_EXPORT void
895 zsock_set_rcvtimeo (void *self, int rcvtimeo);
896
897 // Get socket option `sndtimeo`\&.
898 // Available from libzmq 3\&.0\&.0\&.
899 // Caller owns return value and must destroy it when done\&.
900 CZMQ_EXPORT int
901 zsock_sndtimeo (void *self);
902
903 // Set socket option `sndtimeo`\&.
904 // Available from libzmq 3\&.0\&.0\&.
905 CZMQ_EXPORT void
906 zsock_set_sndtimeo (void *self, int sndtimeo);
907
908 // Set socket option `xpub_verbose`\&.
909 // Available from libzmq 3\&.0\&.0\&.
910 CZMQ_EXPORT void
911 zsock_set_xpub_verbose (void *self, int xpub_verbose);
912
913 // Get socket option `tcp_keepalive`\&.
914 // Available from libzmq 3\&.0\&.0\&.
915 // Caller owns return value and must destroy it when done\&.
916 CZMQ_EXPORT int
917 zsock_tcp_keepalive (void *self);
918
919 // Set socket option `tcp_keepalive`\&.
920 // Available from libzmq 3\&.0\&.0\&.
921 CZMQ_EXPORT void
922 zsock_set_tcp_keepalive (void *self, int tcp_keepalive);
923
924 // Get socket option `tcp_keepalive_idle`\&.
925 // Available from libzmq 3\&.0\&.0\&.
926 // Caller owns return value and must destroy it when done\&.
927 CZMQ_EXPORT int
928 zsock_tcp_keepalive_idle (void *self);
929
930 // Set socket option `tcp_keepalive_idle`\&.
931 // Available from libzmq 3\&.0\&.0\&.
932 CZMQ_EXPORT void
933 zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle);
934
935 // Get socket option `tcp_keepalive_cnt`\&.
936 // Available from libzmq 3\&.0\&.0\&.
937 // Caller owns return value and must destroy it when done\&.
938 CZMQ_EXPORT int
939 zsock_tcp_keepalive_cnt (void *self);
940
941 // Set socket option `tcp_keepalive_cnt`\&.
942 // Available from libzmq 3\&.0\&.0\&.
943 CZMQ_EXPORT void
944 zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt);
945
946 // Get socket option `tcp_keepalive_intvl`\&.
947 // Available from libzmq 3\&.0\&.0\&.
948 // Caller owns return value and must destroy it when done\&.
949 CZMQ_EXPORT int
950 zsock_tcp_keepalive_intvl (void *self);
951
952 // Set socket option `tcp_keepalive_intvl`\&.
953 // Available from libzmq 3\&.0\&.0\&.
954 CZMQ_EXPORT void
955 zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl);
956
957 // Get socket option `tcp_accept_filter`\&.
958 // Available from libzmq 3\&.0\&.0\&.
959 // Caller owns return value and must destroy it when done\&.
960 CZMQ_EXPORT char *
961 zsock_tcp_accept_filter (void *self);
962
963 // Set socket option `tcp_accept_filter`\&.
964 // Available from libzmq 3\&.0\&.0\&.
965 CZMQ_EXPORT void
966 zsock_set_tcp_accept_filter (void *self, const char *tcp_accept_filter);
967
968 // Get socket option `rcvmore`\&.
969 // Available from libzmq 3\&.0\&.0\&.
970 // Caller owns return value and must destroy it when done\&.
971 CZMQ_EXPORT int
972 zsock_rcvmore (void *self);
973
974 // Get socket option `fd`\&.
975 // Available from libzmq 3\&.0\&.0\&.
976 // Caller owns return value and must destroy it when done\&.
977 CZMQ_EXPORT SOCKET
978 zsock_fd (void *self);
979
980 // Get socket option `events`\&.
981 // Available from libzmq 3\&.0\&.0\&.
982 // Caller owns return value and must destroy it when done\&.
983 CZMQ_EXPORT int
984 zsock_events (void *self);
985
986 // Get socket option `last_endpoint`\&.
987 // Available from libzmq 3\&.0\&.0\&.
988 // Caller owns return value and must destroy it when done\&.
989 CZMQ_EXPORT char *
990 zsock_last_endpoint (void *self);
991
992 // Set socket option `router_raw`\&.
993 // Available from libzmq 3\&.0\&.0\&.
994 CZMQ_EXPORT void
995 zsock_set_router_raw (void *self, int router_raw);
996
997 // Get socket option `ipv4only`\&.
998 // Available from libzmq 3\&.0\&.0\&.
999 // Caller owns return value and must destroy it when done\&.
1000 CZMQ_EXPORT int
1001 zsock_ipv4only (void *self);
1002
1003 // Set socket option `ipv4only`\&.
1004 // Available from libzmq 3\&.0\&.0\&.
1005 CZMQ_EXPORT void
1006 zsock_set_ipv4only (void *self, int ipv4only);
1007
1008 // Set socket option `delay_attach_on_connect`\&.
1009 // Available from libzmq 3\&.0\&.0\&.
1010 CZMQ_EXPORT void
1011 zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect);
1012
1013 // Self test of this class\&.
1014 CZMQ_EXPORT void
1015 zsock_test (bool verbose);
1016
1017 #ifdef CZMQ_BUILD_DRAFT_API
1018 // *** Draft method, for development use, may change without warning ***
1019 // Create a SERVER socket\&. Default action is bind\&.
1020 CZMQ_EXPORT zsock_t *
1021 zsock_new_server (const char *endpoint);
1022
1023 // *** Draft method, for development use, may change without warning ***
1024 // Create a CLIENT socket\&. Default action is connect\&.
1025 CZMQ_EXPORT zsock_t *
1026 zsock_new_client (const char *endpoint);
1027
1028 // *** Draft method, for development use, may change without warning ***
1029 // Create a RADIO socket\&. Default action is bind\&.
1030 CZMQ_EXPORT zsock_t *
1031 zsock_new_radio (const char *endpoint);
1032
1033 // *** Draft method, for development use, may change without warning ***
1034 // Create a DISH socket\&. Default action is connect\&.
1035 CZMQ_EXPORT zsock_t *
1036 zsock_new_dish (const char *endpoint);
1037
1038 // *** Draft method, for development use, may change without warning ***
1039 // Create a GATHER socket\&. Default action is bind\&.
1040 CZMQ_EXPORT zsock_t *
1041 zsock_new_gather (const char *endpoint);
1042
1043 // *** Draft method, for development use, may change without warning ***
1044 // Create a SCATTER socket\&. Default action is connect\&.
1045 CZMQ_EXPORT zsock_t *
1046 zsock_new_scatter (const char *endpoint);
1047
1048 // *** Draft method, for development use, may change without warning ***
1049 // Return socket routing ID if any\&. This returns 0 if the socket is not
1050 // of type ZMQ_SERVER or if no request was already received on it\&.
1051 CZMQ_EXPORT uint32_t
1052 zsock_routing_id (zsock_t *self);
1053
1054 // *** Draft method, for development use, may change without warning ***
1055 // Set routing ID on socket\&. The socket MUST be of type ZMQ_SERVER\&.
1056 // This will be used when sending messages on the socket via the zsock API\&.
1057 CZMQ_EXPORT void
1058 zsock_set_routing_id (zsock_t *self, uint32_t routing_id);
1059
1060 // *** Draft method, for development use, may change without warning ***
1061 // Join a group for the RADIO\-DISH pattern\&. Call only on ZMQ_DISH\&.
1062 // Returns 0 if OK, \-1 if failed\&.
1063 CZMQ_EXPORT int
1064 zsock_join (void *self, const char *group);
1065
1066 // *** Draft method, for development use, may change without warning ***
1067 // Leave a group for the RADIO\-DISH pattern\&. Call only on ZMQ_DISH\&.
1068 // Returns 0 if OK, \-1 if failed\&.
1069 CZMQ_EXPORT int
1070 zsock_leave (void *self, const char *group);
1071
1072 #endif // CZMQ_BUILD_DRAFT_API
1073 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zsock\&.c\*(Aq\&.
1074 .fi
1075 .SH "DESCRIPTION"
1076 .sp
1077 The zsock class wraps the libzmq socket handle (a void *) with a proper structure that follows the CLASS rules for construction and destruction\&. Some zsock methods take a void * "polymorphic" reference, which can be either a zsock_t or a zactor_t reference, or a libzmq void *\&.
1078 .sp
1079 Please add \fI@discuss\fR section in \fI\&./\&.\&./src/zsock\&.c\fR\&.
1080 .SH "EXAMPLE"
1081 .PP
1082 \fBFrom zsock_test method\fR.
1083 .sp
1084 .if n \{\
1085 .RS 4
1086 .\}
1087 .nf
1088 zsock_t *writer = zsock_new_push ("@tcp://127\&.0\&.0\&.1:5560");
1089 assert (writer);
1090 assert (zsock_resolve (writer) != writer);
1091 assert (streq (zsock_type_str (writer), "PUSH"));
1092
1093 int rc;
1094 #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0))
1095 // Check unbind
1096 rc = zsock_unbind (writer, "tcp://127\&.0\&.0\&.1:%d", 5560);
1097 assert (rc == 0);
1098
1099 // In some cases and especially when running under Valgrind, doing
1100 // a bind immediately after an unbind causes an EADDRINUSE error\&.
1101 // Even a short sleep allows the OS to release the port for reuse\&.
1102 zclock_sleep (100);
1103
1104 // Bind again
1105 rc = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:%d", 5560);
1106 assert (rc == 5560);
1107 assert (streq (zsock_endpoint (writer), "tcp://127\&.0\&.0\&.1:5560"));
1108 #endif
1109
1110 zsock_t *reader = zsock_new_pull (">tcp://127\&.0\&.0\&.1:5560");
1111 assert (reader);
1112 assert (zsock_resolve (reader) != reader);
1113 assert (streq (zsock_type_str (reader), "PULL"));
1114
1115 // Basic Hello, World
1116 zstr_send (writer, "Hello, World");
1117 zmsg_t *msg = zmsg_recv (reader);
1118 assert (msg);
1119 char *string = zmsg_popstr (msg);
1120 assert (streq (string, "Hello, World"));
1121 free (string);
1122 zmsg_destroy (&msg);
1123
1124 // Test resolve libzmq socket
1125 #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0))
1126 void *zmq_ctx = zmq_ctx_new ();
1127 #else
1128 void *zmq_ctx = zmq_ctx_new (1);
1129 #endif
1130 assert (zmq_ctx);
1131 void *zmq_sock = zmq_socket (zmq_ctx, ZMQ_PUB);
1132 assert (zmq_sock);
1133 assert (zsock_resolve (zmq_sock) == zmq_sock);
1134 zmq_close (zmq_sock);
1135 zmq_ctx_term (zmq_ctx);
1136
1137 // Test resolve zsock
1138 zsock_t *resolve = zsock_new_pub("@tcp://127\&.0\&.0\&.1:5561");
1139 assert (resolve);
1140 assert (zsock_resolve (resolve) == resolve\->handle);
1141 zsock_destroy (&resolve);
1142
1143 // Test resolve FD
1144 SOCKET fd = zsock_fd (reader);
1145 assert (zsock_resolve ((void *) &fd) == NULL);
1146
1147 // Test binding to ephemeral ports, sequential and random
1148 int port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:*");
1149 assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST);
1150 port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:*[50000\-]");
1151 assert (port >= 50000 && port <= DYNAMIC_LAST);
1152 port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:*[\-50001]");
1153 assert (port >= DYNAMIC_FIRST && port <= 50001);
1154 port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:*[60000\-60050]");
1155 assert (port >= 60000 && port <= 60050);
1156
1157 port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:!");
1158 assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST);
1159 port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:![50000\-]");
1160 assert (port >= 50000 && port <= DYNAMIC_LAST);
1161 port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:![\-50001]");
1162 assert (port >= DYNAMIC_FIRST && port <= 50001);
1163 port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:![60000\-60050]");
1164 assert (port >= 60000 && port <= 60050);
1165
1166 // Test zsock_attach method
1167 zsock_t *server = zsock_new (ZMQ_DEALER);
1168 assert (server);
1169 rc = zsock_attach (server, "@inproc://myendpoint,tcp://127\&.0\&.0\&.1:5556,inproc://others", true);
1170 assert (rc == 0);
1171 rc = zsock_attach (server, "", false);
1172 assert (rc == 0);
1173 rc = zsock_attach (server, NULL, true);
1174 assert (rc == 0);
1175 rc = zsock_attach (server, ">a,@b, c,, ", false);
1176 assert (rc == \-1);
1177 zsock_destroy (&server);
1178
1179 // Test zsock_endpoint method
1180 rc = zsock_bind (writer, "inproc://test\&.%s", "writer");
1181 assert (rc == 0);
1182 assert (streq (zsock_endpoint (writer), "inproc://test\&.writer"));
1183
1184 // Test error state when connecting to an invalid socket type
1185 // (\*(Aqtxp://\*(Aq instead of \*(Aqtcp://\*(Aq, typo intentional)
1186 rc = zsock_connect (reader, "txp://127\&.0\&.0\&.1:5560");
1187 assert (rc == \-1);
1188
1189 // Test signal/wait methods
1190 rc = zsock_signal (writer, 123);
1191 assert (rc == 0);
1192 rc = zsock_wait (reader);
1193 assert (rc == 123);
1194
1195 // Test zsock_send/recv pictures
1196 uint8_t number1 = 123;
1197 uint16_t number2 = 123 * 123;
1198 uint32_t number4 = 123 * 123;
1199 number4 *= 123;
1200 uint32_t number4_MAX = UINT32_MAX;
1201 uint64_t number8 = 123 * 123;
1202 number8 *= 123;
1203 number8 *= 123;
1204 uint64_t number8_MAX = UINT64_MAX;
1205
1206 zchunk_t *chunk = zchunk_new ("HELLO", 5);
1207 assert (chunk);
1208 zframe_t *frame = zframe_new ("WORLD", 5);
1209 assert (frame);
1210 zhashx_t *hash = zhashx_new ();
1211 assert (hash);
1212 zuuid_t *uuid = zuuid_new ();
1213 assert (uuid);
1214 zhashx_set_destructor (hash, (zhashx_destructor_fn *) zstr_free);
1215 zhashx_set_duplicator (hash, (zhashx_duplicator_fn *) strdup);
1216 zhashx_insert (hash, "1", "value A");
1217 zhashx_insert (hash, "2", "value B");
1218 char *original = "pointer";
1219
1220 // Test zsock_recv into each supported type
1221 zsock_send (writer, "i124488zsbcfUhp",
1222 \-12345, number1, number2, number4, number4_MAX,
1223 number8, number8_MAX,
1224 "This is a string", "ABCDE", 5,
1225 chunk, frame, uuid, hash, original);
1226 char *uuid_str = strdup (zuuid_str (uuid));
1227 zchunk_destroy (&chunk);
1228 zframe_destroy (&frame);
1229 zuuid_destroy (&uuid);
1230 zhashx_destroy (&hash);
1231
1232 int integer;
1233 byte *data;
1234 size_t size;
1235 char *pointer;
1236 number8_MAX = number8 = number4_MAX = number4 = number2 = number1 = 0ULL;
1237 rc = zsock_recv (reader, "i124488zsbcfUhp",
1238 &integer, &number1, &number2, &number4, &number4_MAX,
1239 &number8, &number8_MAX, &string, &data, &size, &chunk,
1240 &frame, &uuid, &hash, &pointer);
1241 assert (rc == 0);
1242 assert (integer == \-12345);
1243 assert (number1 == 123);
1244 assert (number2 == 123 * 123);
1245 assert (number4 == 123 * 123 * 123);
1246 assert (number4_MAX == UINT32_MAX);
1247 assert (number8 == 123 * 123 * 123 * 123);
1248 assert (number8_MAX == UINT64_MAX);
1249 assert (streq (string, "This is a string"));
1250 assert (memcmp (data, "ABCDE", 5) == 0);
1251 assert (size == 5);
1252 assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0);
1253 assert (zchunk_size (chunk) == 5);
1254 assert (streq (uuid_str, zuuid_str (uuid)));
1255 assert (memcmp (zframe_data (frame), "WORLD", 5) == 0);
1256 assert (zframe_size (frame) == 5);
1257 char *value = (char *) zhashx_lookup (hash, "1");
1258 assert (streq (value, "value A"));
1259 value = (char *) zhashx_lookup (hash, "2");
1260 assert (streq (value, "value B"));
1261 assert (original == pointer);
1262 free (string);
1263 free (data);
1264 free (uuid_str);
1265 zframe_destroy (&frame);
1266 zchunk_destroy (&chunk);
1267 zhashx_destroy (&hash);
1268 zuuid_destroy (&uuid);
1269
1270 // Test zsock_recv of short message; this lets us return a failure
1271 // with a status code and then nothing else; the receiver will get
1272 // the status code and NULL/zero for all other values
1273 zsock_send (writer, "i", \-1);
1274 zsock_recv (reader, "izsbcfp",
1275 &integer, &string, &data, &size, &chunk, &frame, &pointer);
1276 assert (integer == \-1);
1277 assert (string == NULL);
1278 assert (data == NULL);
1279 assert (size == 0);
1280 assert (chunk == NULL);
1281 assert (frame == NULL);
1282 assert (pointer == NULL);
1283
1284 msg = zmsg_new ();
1285 zmsg_addstr (msg, "frame 1");
1286 zmsg_addstr (msg, "frame 2");
1287 zsock_send (writer, "szm", "header", msg);
1288 zmsg_destroy (&msg);
1289
1290 zsock_recv (reader, "szm", &string, &msg);
1291
1292 assert (streq ("header", string));
1293 assert (zmsg_size (msg) == 2);
1294 assert (zframe_streq (zmsg_first (msg), "frame 1"));
1295 assert (zframe_streq (zmsg_next (msg), "frame 2"));
1296 zstr_free (&string);
1297 zmsg_destroy (&msg);
1298
1299 // Test zsock_recv with null arguments
1300 chunk = zchunk_new ("HELLO", 5);
1301 assert (chunk);
1302 frame = zframe_new ("WORLD", 5);
1303 assert (frame);
1304 zsock_send (writer, "izsbcfp",
1305 \-12345, "This is a string", "ABCDE", 5, chunk, frame, original);
1306 zframe_destroy (&frame);
1307 zchunk_destroy (&chunk);
1308 zsock_recv (reader, "izsbcfp", &integer, NULL, NULL, NULL, &chunk, NULL, NULL);
1309 assert (integer == \-12345);
1310 assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0);
1311 assert (zchunk_size (chunk) == 5);
1312 zchunk_destroy (&chunk);
1313
1314 // Test zsock_bsend/brecv pictures with binary encoding
1315 frame = zframe_new ("Hello", 5);
1316 chunk = zchunk_new ("World", 5);
1317
1318 msg = zmsg_new ();
1319 zmsg_addstr (msg, "Hello");
1320 zmsg_addstr (msg, "World");
1321
1322 zsock_bsend (writer, "1248sSpcfm",
1323 number1, number2, number4, number8,
1324 "Hello, World",
1325 "Goodbye cruel World!",
1326 original,
1327 chunk, frame, msg);
1328 zchunk_destroy (&chunk);
1329 zframe_destroy (&frame);
1330 zmsg_destroy (&msg);
1331
1332 number8 = number4 = number2 = number1 = 0;
1333 char *longstr;
1334 zsock_brecv (reader, "1248sSpcfm",
1335 &number1, &number2, &number4, &number8,
1336 &string, &longstr,
1337 &pointer,
1338 &chunk, &frame, &msg);
1339 assert (number1 == 123);
1340 assert (number2 == 123 * 123);
1341 assert (number4 == 123 * 123 * 123);
1342 assert (number8 == 123 * 123 * 123 * 123);
1343 assert (streq (string, "Hello, World"));
1344 assert (streq (longstr, "Goodbye cruel World!"));
1345 assert (pointer == original);
1346 zstr_free (&longstr);
1347 zchunk_destroy (&chunk);
1348 zframe_destroy (&frame);
1349 zmsg_destroy (&msg);
1350
1351 #ifdef ZMQ_SERVER
1352
1353 // Test zsock_bsend/brecv pictures with binary encoding on SERVER and CLIENT sockets
1354 server = zsock_new_server ("tcp://127\&.0\&.0\&.1:5561");
1355 assert (server);
1356 zsock_t* client = zsock_new_client ("tcp://127\&.0\&.0\&.1:5561");
1357 assert (client);
1358
1359 // From client to server
1360 chunk = zchunk_new ("World", 5);
1361 zsock_bsend (client, "1248sSpc",
1362 number1, number2, number4, number8,
1363 "Hello, World",
1364 "Goodbye cruel World!",
1365 original,
1366 chunk);
1367 zchunk_destroy (&chunk);
1368
1369 number8 = number4 = number2 = number1 = 0;
1370 zsock_brecv (server, "1248sSpc",
1371 &number1, &number2, &number4, &number8,
1372 &string, &longstr,
1373 &pointer,
1374 &chunk);
1375 assert (number1 == 123);
1376 assert (number2 == 123 * 123);
1377 assert (number4 == 123 * 123 * 123);
1378 assert (number8 == 123 * 123 * 123 * 123);
1379 assert (streq (string, "Hello, World"));
1380 assert (streq (longstr, "Goodbye cruel World!"));
1381 assert (pointer == original);
1382 assert (zsock_routing_id (server));
1383 zstr_free (&longstr);
1384 zchunk_destroy (&chunk);
1385
1386 // From server to client
1387 chunk = zchunk_new ("World", 5);
1388 zsock_bsend (server, "1248sSpc",
1389 number1, number2, number4, number8,
1390 "Hello, World",
1391 "Goodbye cruel World!",
1392 original,
1393 chunk);
1394 zchunk_destroy (&chunk);
1395
1396 number8 = number4 = number2 = number1 = 0;
1397 zsock_brecv (client, "1248sSpc",
1398 &number1, &number2, &number4, &number8,
1399 &string, &longstr,
1400 &pointer,
1401 &chunk);
1402 assert (number1 == 123);
1403 assert (number2 == 123 * 123);
1404 assert (number4 == 123 * 123 * 123);
1405 assert (number8 == 123 * 123 * 123 * 123);
1406 assert (streq (string, "Hello, World"));
1407 assert (streq (longstr, "Goodbye cruel World!"));
1408 assert (pointer == original);
1409 assert (zsock_routing_id (client) == 0);
1410 zstr_free (&longstr);
1411 zchunk_destroy (&chunk);
1412
1413 zsock_destroy (&client);
1414 zsock_destroy (&server);
1415
1416 #endif
1417
1418 #ifdef ZMQ_SCATTER
1419
1420 zsock_t* gather = zsock_new_gather ("inproc://test\-gather\-scatter");
1421 assert (gather);
1422 zsock_t* scatter = zsock_new_scatter ("inproc://test\-gather\-scatter");
1423 assert (scatter);
1424
1425 rc = zstr_send (scatter, "HELLO");
1426 assert (rc == 0);
1427
1428 char* message;
1429 message = zstr_recv (gather);
1430 assert (streq(message, "HELLO"));
1431 zstr_free (&message);
1432
1433 zsock_destroy (&gather);
1434 zsock_destroy (&scatter);
1435
1436 #endif
1437
1438 // Check that we can send a zproto format message
1439 zsock_bsend (writer, "1111sS4", 0xAA, 0xA0, 0x02, 0x01, "key", "value", 1234);
1440 zgossip_msg_t *gossip = zgossip_msg_new ();
1441 zgossip_msg_recv (gossip, reader);
1442 assert (zgossip_msg_id (gossip) == ZGOSSIP_MSG_PUBLISH);
1443 zgossip_msg_destroy (&gossip);
1444
1445 zsock_destroy (&reader);
1446 zsock_destroy (&writer);
1447 .fi
1448 .if n \{\
1449 .RE
1450 .\}
1451 .sp
1452 .SH "AUTHORS"
1453 .sp
1454 The czmq manual was written by the authors in the AUTHORS file\&.
1455 .SH "RESOURCES"
1456 .sp
1457 Main web site: \m[blue]\fB\%\fR\m[]
1458 .sp
1459 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
1460 .SH "COPYRIGHT"
1461 .sp
1462 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
1463 .SH "NOTES"
1464 .IP " 1." 4
1465 zeromq-dev@lists.zeromq.org
1466 .RS 4
1467 \%mailto:zeromq-dev@lists.zeromq.org
1468 .RE
279279 zsock_resolve (void *self);
280280
281281 // Get socket option `heartbeat_ivl`.
282 // Available from libzmq 4.2.0.
282283 // Caller owns return value and must destroy it when done.
283284 CZMQ_EXPORT int
284285 zsock_heartbeat_ivl (void *self);
285286
286287 // Set socket option `heartbeat_ivl`.
288 // Available from libzmq 4.2.0.
287289 CZMQ_EXPORT void
288290 zsock_set_heartbeat_ivl (void *self, int heartbeat_ivl);
289291
290292 // Get socket option `heartbeat_ttl`.
293 // Available from libzmq 4.2.0.
291294 // Caller owns return value and must destroy it when done.
292295 CZMQ_EXPORT int
293296 zsock_heartbeat_ttl (void *self);
294297
295298 // Set socket option `heartbeat_ttl`.
299 // Available from libzmq 4.2.0.
296300 CZMQ_EXPORT void
297301 zsock_set_heartbeat_ttl (void *self, int heartbeat_ttl);
298302
299303 // Get socket option `heartbeat_timeout`.
304 // Available from libzmq 4.2.0.
300305 // Caller owns return value and must destroy it when done.
301306 CZMQ_EXPORT int
302307 zsock_heartbeat_timeout (void *self);
303308
304309 // Set socket option `heartbeat_timeout`.
310 // Available from libzmq 4.2.0.
305311 CZMQ_EXPORT void
306312 zsock_set_heartbeat_timeout (void *self, int heartbeat_timeout);
307313
308 // Get socket option `use_fd`.
314 // Get socket option `use_fd`.
315 // Available from libzmq 4.2.0.
309316 // Caller owns return value and must destroy it when done.
310317 CZMQ_EXPORT int
311318 zsock_use_fd (void *self);
312319
313 // Set socket option `use_fd`.
320 // Set socket option `use_fd`.
321 // Available from libzmq 4.2.0.
314322 CZMQ_EXPORT void
315323 zsock_set_use_fd (void *self, int use_fd);
316324
317325 // Set socket option `xpub_manual`.
326 // Available from libzmq 4.2.0.
318327 CZMQ_EXPORT void
319328 zsock_set_xpub_manual (void *self, int xpub_manual);
320329
321330 // Set socket option `xpub_welcome_msg`.
331 // Available from libzmq 4.2.0.
322332 CZMQ_EXPORT void
323333 zsock_set_xpub_welcome_msg (void *self, const char *xpub_welcome_msg);
324334
325335 // Set socket option `stream_notify`.
336 // Available from libzmq 4.2.0.
326337 CZMQ_EXPORT void
327338 zsock_set_stream_notify (void *self, int stream_notify);
328339
329340 // Get socket option `invert_matching`.
341 // Available from libzmq 4.2.0.
330342 // Caller owns return value and must destroy it when done.
331343 CZMQ_EXPORT int
332344 zsock_invert_matching (void *self);
333345
334346 // Set socket option `invert_matching`.
347 // Available from libzmq 4.2.0.
335348 CZMQ_EXPORT void
336349 zsock_set_invert_matching (void *self, int invert_matching);
337350
338351 // Set socket option `xpub_verboser`.
352 // Available from libzmq 4.2.0.
339353 CZMQ_EXPORT void
340354 zsock_set_xpub_verboser (void *self, int xpub_verboser);
341355
342356 // Get socket option `connect_timeout`.
357 // Available from libzmq 4.2.0.
343358 // Caller owns return value and must destroy it when done.
344359 CZMQ_EXPORT int
345360 zsock_connect_timeout (void *self);
346361
347362 // Set socket option `connect_timeout`.
363 // Available from libzmq 4.2.0.
348364 CZMQ_EXPORT void
349365 zsock_set_connect_timeout (void *self, int connect_timeout);
350366
351367 // Get socket option `tcp_maxrt`.
368 // Available from libzmq 4.2.0.
352369 // Caller owns return value and must destroy it when done.
353370 CZMQ_EXPORT int
354371 zsock_tcp_maxrt (void *self);
355372
356373 // Set socket option `tcp_maxrt`.
374 // Available from libzmq 4.2.0.
357375 CZMQ_EXPORT void
358376 zsock_set_tcp_maxrt (void *self, int tcp_maxrt);
359377
360378 // Get socket option `thread_safe`.
379 // Available from libzmq 4.2.0.
361380 // Caller owns return value and must destroy it when done.
362381 CZMQ_EXPORT int
363382 zsock_thread_safe (void *self);
364383
365384 // Get socket option `multicast_maxtpdu`.
385 // Available from libzmq 4.2.0.
366386 // Caller owns return value and must destroy it when done.
367387 CZMQ_EXPORT int
368388 zsock_multicast_maxtpdu (void *self);
369389
370390 // Set socket option `multicast_maxtpdu`.
391 // Available from libzmq 4.2.0.
371392 CZMQ_EXPORT void
372393 zsock_set_multicast_maxtpdu (void *self, int multicast_maxtpdu);
373394
374395 // Get socket option `vmci_buffer_size`.
396 // Available from libzmq 4.2.0.
375397 // Caller owns return value and must destroy it when done.
376398 CZMQ_EXPORT int
377399 zsock_vmci_buffer_size (void *self);
378400
379401 // Set socket option `vmci_buffer_size`.
402 // Available from libzmq 4.2.0.
380403 CZMQ_EXPORT void
381404 zsock_set_vmci_buffer_size (void *self, int vmci_buffer_size);
382405
383406 // Get socket option `vmci_buffer_min_size`.
407 // Available from libzmq 4.2.0.
384408 // Caller owns return value and must destroy it when done.
385409 CZMQ_EXPORT int
386410 zsock_vmci_buffer_min_size (void *self);
387411
388412 // Set socket option `vmci_buffer_min_size`.
413 // Available from libzmq 4.2.0.
389414 CZMQ_EXPORT void
390415 zsock_set_vmci_buffer_min_size (void *self, int vmci_buffer_min_size);
391416
392417 // Get socket option `vmci_buffer_max_size`.
418 // Available from libzmq 4.2.0.
393419 // Caller owns return value and must destroy it when done.
394420 CZMQ_EXPORT int
395421 zsock_vmci_buffer_max_size (void *self);
396422
397423 // Set socket option `vmci_buffer_max_size`.
424 // Available from libzmq 4.2.0.
398425 CZMQ_EXPORT void
399426 zsock_set_vmci_buffer_max_size (void *self, int vmci_buffer_max_size);
400427
401428 // Get socket option `vmci_connect_timeout`.
429 // Available from libzmq 4.2.0.
402430 // Caller owns return value and must destroy it when done.
403431 CZMQ_EXPORT int
404432 zsock_vmci_connect_timeout (void *self);
405433
406434 // Set socket option `vmci_connect_timeout`.
435 // Available from libzmq 4.2.0.
407436 CZMQ_EXPORT void
408437 zsock_set_vmci_connect_timeout (void *self, int vmci_connect_timeout);
409438
410 // Get socket option `tos`.
439 // Get socket option `tos`.
440 // Available from libzmq 4.1.0.
411441 // Caller owns return value and must destroy it when done.
412442 CZMQ_EXPORT int
413443 zsock_tos (void *self);
414444
415 // Set socket option `tos`.
445 // Set socket option `tos`.
446 // Available from libzmq 4.1.0.
416447 CZMQ_EXPORT void
417448 zsock_set_tos (void *self, int tos);
418449
419450 // Set socket option `router_handover`.
451 // Available from libzmq 4.1.0.
420452 CZMQ_EXPORT void
421453 zsock_set_router_handover (void *self, int router_handover);
422454
423455 // Set socket option `connect_rid`.
456 // Available from libzmq 4.1.0.
424457 CZMQ_EXPORT void
425458 zsock_set_connect_rid (void *self, const char *connect_rid);
426459
427460 // Set socket option `connect_rid` from 32-octet binary
461 // Available from libzmq 4.1.0.
428462 CZMQ_EXPORT void
429463 zsock_set_connect_rid_bin (void *self, const byte *connect_rid);
430464
431465 // Get socket option `handshake_ivl`.
466 // Available from libzmq 4.1.0.
432467 // Caller owns return value and must destroy it when done.
433468 CZMQ_EXPORT int
434469 zsock_handshake_ivl (void *self);
435470
436471 // Set socket option `handshake_ivl`.
472 // Available from libzmq 4.1.0.
437473 CZMQ_EXPORT void
438474 zsock_set_handshake_ivl (void *self, int handshake_ivl);
439475
440476 // Get socket option `socks_proxy`.
477 // Available from libzmq 4.1.0.
441478 // Caller owns return value and must destroy it when done.
442479 CZMQ_EXPORT char *
443480 zsock_socks_proxy (void *self);
444481
445482 // Set socket option `socks_proxy`.
483 // Available from libzmq 4.1.0.
446484 CZMQ_EXPORT void
447485 zsock_set_socks_proxy (void *self, const char *socks_proxy);
448486
449487 // Set socket option `xpub_nodrop`.
488 // Available from libzmq 4.1.0.
450489 CZMQ_EXPORT void
451490 zsock_set_xpub_nodrop (void *self, int xpub_nodrop);
452491
453492 // Set socket option `router_mandatory`.
493 // Available from libzmq 4.0.0.
454494 CZMQ_EXPORT void
455495 zsock_set_router_mandatory (void *self, int router_mandatory);
456496
457497 // Set socket option `probe_router`.
498 // Available from libzmq 4.0.0.
458499 CZMQ_EXPORT void
459500 zsock_set_probe_router (void *self, int probe_router);
460501
461502 // Set socket option `req_relaxed`.
503 // Available from libzmq 4.0.0.
462504 CZMQ_EXPORT void
463505 zsock_set_req_relaxed (void *self, int req_relaxed);
464506
465507 // Set socket option `req_correlate`.
508 // Available from libzmq 4.0.0.
466509 CZMQ_EXPORT void
467510 zsock_set_req_correlate (void *self, int req_correlate);
468511
469512 // Set socket option `conflate`.
513 // Available from libzmq 4.0.0.
470514 CZMQ_EXPORT void
471515 zsock_set_conflate (void *self, int conflate);
472516
473517 // Get socket option `zap_domain`.
518 // Available from libzmq 4.0.0.
474519 // Caller owns return value and must destroy it when done.
475520 CZMQ_EXPORT char *
476521 zsock_zap_domain (void *self);
477522
478523 // Set socket option `zap_domain`.
524 // Available from libzmq 4.0.0.
479525 CZMQ_EXPORT void
480526 zsock_set_zap_domain (void *self, const char *zap_domain);
481527
482528 // Get socket option `mechanism`.
529 // Available from libzmq 4.0.0.
483530 // Caller owns return value and must destroy it when done.
484531 CZMQ_EXPORT int
485532 zsock_mechanism (void *self);
486533
487534 // Get socket option `plain_server`.
535 // Available from libzmq 4.0.0.
488536 // Caller owns return value and must destroy it when done.
489537 CZMQ_EXPORT int
490538 zsock_plain_server (void *self);
491539
492540 // Set socket option `plain_server`.
541 // Available from libzmq 4.0.0.
493542 CZMQ_EXPORT void
494543 zsock_set_plain_server (void *self, int plain_server);
495544
496545 // Get socket option `plain_username`.
546 // Available from libzmq 4.0.0.
497547 // Caller owns return value and must destroy it when done.
498548 CZMQ_EXPORT char *
499549 zsock_plain_username (void *self);
500550
501551 // Set socket option `plain_username`.
552 // Available from libzmq 4.0.0.
502553 CZMQ_EXPORT void
503554 zsock_set_plain_username (void *self, const char *plain_username);
504555
505556 // Get socket option `plain_password`.
557 // Available from libzmq 4.0.0.
506558 // Caller owns return value and must destroy it when done.
507559 CZMQ_EXPORT char *
508560 zsock_plain_password (void *self);
509561
510562 // Set socket option `plain_password`.
563 // Available from libzmq 4.0.0.
511564 CZMQ_EXPORT void
512565 zsock_set_plain_password (void *self, const char *plain_password);
513566
514567 // Get socket option `curve_server`.
568 // Available from libzmq 4.0.0.
515569 // Caller owns return value and must destroy it when done.
516570 CZMQ_EXPORT int
517571 zsock_curve_server (void *self);
518572
519573 // Set socket option `curve_server`.
574 // Available from libzmq 4.0.0.
520575 CZMQ_EXPORT void
521576 zsock_set_curve_server (void *self, int curve_server);
522577
523578 // Get socket option `curve_publickey`.
579 // Available from libzmq 4.0.0.
524580 // Caller owns return value and must destroy it when done.
525581 CZMQ_EXPORT char *
526582 zsock_curve_publickey (void *self);
527583
528584 // Set socket option `curve_publickey`.
585 // Available from libzmq 4.0.0.
529586 CZMQ_EXPORT void
530587 zsock_set_curve_publickey (void *self, const char *curve_publickey);
531588
532589 // Set socket option `curve_publickey` from 32-octet binary
590 // Available from libzmq 4.0.0.
533591 CZMQ_EXPORT void
534592 zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey);
535593
536594 // Get socket option `curve_secretkey`.
595 // Available from libzmq 4.0.0.
537596 // Caller owns return value and must destroy it when done.
538597 CZMQ_EXPORT char *
539598 zsock_curve_secretkey (void *self);
540599
541600 // Set socket option `curve_secretkey`.
601 // Available from libzmq 4.0.0.
542602 CZMQ_EXPORT void
543603 zsock_set_curve_secretkey (void *self, const char *curve_secretkey);
544604
545605 // Set socket option `curve_secretkey` from 32-octet binary
606 // Available from libzmq 4.0.0.
546607 CZMQ_EXPORT void
547608 zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey);
548609
549610 // Get socket option `curve_serverkey`.
611 // Available from libzmq 4.0.0.
550612 // Caller owns return value and must destroy it when done.
551613 CZMQ_EXPORT char *
552614 zsock_curve_serverkey (void *self);
553615
554616 // Set socket option `curve_serverkey`.
617 // Available from libzmq 4.0.0.
555618 CZMQ_EXPORT void
556619 zsock_set_curve_serverkey (void *self, const char *curve_serverkey);
557620
558621 // Set socket option `curve_serverkey` from 32-octet binary
622 // Available from libzmq 4.0.0.
559623 CZMQ_EXPORT void
560624 zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey);
561625
562626 // Get socket option `gssapi_server`.
627 // Available from libzmq 4.0.0.
563628 // Caller owns return value and must destroy it when done.
564629 CZMQ_EXPORT int
565630 zsock_gssapi_server (void *self);
566631
567632 // Set socket option `gssapi_server`.
633 // Available from libzmq 4.0.0.
568634 CZMQ_EXPORT void
569635 zsock_set_gssapi_server (void *self, int gssapi_server);
570636
571637 // Get socket option `gssapi_plaintext`.
638 // Available from libzmq 4.0.0.
572639 // Caller owns return value and must destroy it when done.
573640 CZMQ_EXPORT int
574641 zsock_gssapi_plaintext (void *self);
575642
576643 // Set socket option `gssapi_plaintext`.
644 // Available from libzmq 4.0.0.
577645 CZMQ_EXPORT void
578646 zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext);
579647
580648 // Get socket option `gssapi_principal`.
649 // Available from libzmq 4.0.0.
581650 // Caller owns return value and must destroy it when done.
582651 CZMQ_EXPORT char *
583652 zsock_gssapi_principal (void *self);
584653
585654 // Set socket option `gssapi_principal`.
655 // Available from libzmq 4.0.0.
586656 CZMQ_EXPORT void
587657 zsock_set_gssapi_principal (void *self, const char *gssapi_principal);
588658
589659 // Get socket option `gssapi_service_principal`.
660 // Available from libzmq 4.0.0.
590661 // Caller owns return value and must destroy it when done.
591662 CZMQ_EXPORT char *
592663 zsock_gssapi_service_principal (void *self);
593664
594665 // Set socket option `gssapi_service_principal`.
666 // Available from libzmq 4.0.0.
595667 CZMQ_EXPORT void
596668 zsock_set_gssapi_service_principal (void *self, const char *gssapi_service_principal);
597669
598 // Get socket option `ipv6`.
670 // Get socket option `ipv6`.
671 // Available from libzmq 4.0.0.
599672 // Caller owns return value and must destroy it when done.
600673 CZMQ_EXPORT int
601674 zsock_ipv6 (void *self);
602675
603 // Set socket option `ipv6`.
676 // Set socket option `ipv6`.
677 // Available from libzmq 4.0.0.
604678 CZMQ_EXPORT void
605679 zsock_set_ipv6 (void *self, int ipv6);
606680
607681 // Get socket option `immediate`.
682 // Available from libzmq 4.0.0.
608683 // Caller owns return value and must destroy it when done.
609684 CZMQ_EXPORT int
610685 zsock_immediate (void *self);
611686
612687 // Set socket option `immediate`.
688 // Available from libzmq 4.0.0.
613689 CZMQ_EXPORT void
614690 zsock_set_immediate (void *self, int immediate);
615691
616 // Set socket option `router_raw`.
617 CZMQ_EXPORT void
618 zsock_set_router_raw (void *self, int router_raw);
619
620 // Get socket option `ipv4only`.
621 // Caller owns return value and must destroy it when done.
622 CZMQ_EXPORT int
623 zsock_ipv4only (void *self);
624
625 // Set socket option `ipv4only`.
626 CZMQ_EXPORT void
627 zsock_set_ipv4only (void *self, int ipv4only);
628
629 // Set socket option `delay_attach_on_connect`.
630 CZMQ_EXPORT void
631 zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect);
632
633 // Get socket option `type`.
692 // Get socket option `type`.
693 // Available from libzmq 3.0.0.
634694 // Caller owns return value and must destroy it when done.
635695 CZMQ_EXPORT int
636696 zsock_type (void *self);
637697
638 // Get socket option `sndhwm`.
698 // Get socket option `sndhwm`.
699 // Available from libzmq 3.0.0.
639700 // Caller owns return value and must destroy it when done.
640701 CZMQ_EXPORT int
641702 zsock_sndhwm (void *self);
642703
643 // Set socket option `sndhwm`.
704 // Set socket option `sndhwm`.
705 // Available from libzmq 3.0.0.
644706 CZMQ_EXPORT void
645707 zsock_set_sndhwm (void *self, int sndhwm);
646708
647 // Get socket option `rcvhwm`.
709 // Get socket option `rcvhwm`.
710 // Available from libzmq 3.0.0.
648711 // Caller owns return value and must destroy it when done.
649712 CZMQ_EXPORT int
650713 zsock_rcvhwm (void *self);
651714
652 // Set socket option `rcvhwm`.
715 // Set socket option `rcvhwm`.
716 // Available from libzmq 3.0.0.
653717 CZMQ_EXPORT void
654718 zsock_set_rcvhwm (void *self, int rcvhwm);
655719
656720 // Get socket option `affinity`.
721 // Available from libzmq 3.0.0.
657722 // Caller owns return value and must destroy it when done.
658723 CZMQ_EXPORT int
659724 zsock_affinity (void *self);
660725
661726 // Set socket option `affinity`.
727 // Available from libzmq 3.0.0.
662728 CZMQ_EXPORT void
663729 zsock_set_affinity (void *self, int affinity);
664730
665731 // Set socket option `subscribe`.
732 // Available from libzmq 3.0.0.
666733 CZMQ_EXPORT void
667734 zsock_set_subscribe (void *self, const char *subscribe);
668735
669736 // Set socket option `unsubscribe`.
737 // Available from libzmq 3.0.0.
670738 CZMQ_EXPORT void
671739 zsock_set_unsubscribe (void *self, const char *unsubscribe);
672740
673741 // Get socket option `identity`.
742 // Available from libzmq 3.0.0.
674743 // Caller owns return value and must destroy it when done.
675744 CZMQ_EXPORT char *
676745 zsock_identity (void *self);
677746
678747 // Set socket option `identity`.
748 // Available from libzmq 3.0.0.
679749 CZMQ_EXPORT void
680750 zsock_set_identity (void *self, const char *identity);
681751
682 // Get socket option `rate`.
752 // Get socket option `rate`.
753 // Available from libzmq 3.0.0.
683754 // Caller owns return value and must destroy it when done.
684755 CZMQ_EXPORT int
685756 zsock_rate (void *self);
686757
687 // Set socket option `rate`.
758 // Set socket option `rate`.
759 // Available from libzmq 3.0.0.
688760 CZMQ_EXPORT void
689761 zsock_set_rate (void *self, int rate);
690762
691763 // Get socket option `recovery_ivl`.
764 // Available from libzmq 3.0.0.
692765 // Caller owns return value and must destroy it when done.
693766 CZMQ_EXPORT int
694767 zsock_recovery_ivl (void *self);
695768
696769 // Set socket option `recovery_ivl`.
770 // Available from libzmq 3.0.0.
697771 CZMQ_EXPORT void
698772 zsock_set_recovery_ivl (void *self, int recovery_ivl);
699773
700 // Get socket option `sndbuf`.
774 // Get socket option `sndbuf`.
775 // Available from libzmq 3.0.0.
701776 // Caller owns return value and must destroy it when done.
702777 CZMQ_EXPORT int
703778 zsock_sndbuf (void *self);
704779
705 // Set socket option `sndbuf`.
780 // Set socket option `sndbuf`.
781 // Available from libzmq 3.0.0.
706782 CZMQ_EXPORT void
707783 zsock_set_sndbuf (void *self, int sndbuf);
708784
709 // Get socket option `rcvbuf`.
785 // Get socket option `rcvbuf`.
786 // Available from libzmq 3.0.0.
710787 // Caller owns return value and must destroy it when done.
711788 CZMQ_EXPORT int
712789 zsock_rcvbuf (void *self);
713790
714 // Set socket option `rcvbuf`.
791 // Set socket option `rcvbuf`.
792 // Available from libzmq 3.0.0.
715793 CZMQ_EXPORT void
716794 zsock_set_rcvbuf (void *self, int rcvbuf);
717795
718 // Get socket option `linger`.
796 // Get socket option `linger`.
797 // Available from libzmq 3.0.0.
719798 // Caller owns return value and must destroy it when done.
720799 CZMQ_EXPORT int
721800 zsock_linger (void *self);
722801
723 // Set socket option `linger`.
802 // Set socket option `linger`.
803 // Available from libzmq 3.0.0.
724804 CZMQ_EXPORT void
725805 zsock_set_linger (void *self, int linger);
726806
727807 // Get socket option `reconnect_ivl`.
808 // Available from libzmq 3.0.0.
728809 // Caller owns return value and must destroy it when done.
729810 CZMQ_EXPORT int
730811 zsock_reconnect_ivl (void *self);
731812
732813 // Set socket option `reconnect_ivl`.
814 // Available from libzmq 3.0.0.
733815 CZMQ_EXPORT void
734816 zsock_set_reconnect_ivl (void *self, int reconnect_ivl);
735817
736818 // Get socket option `reconnect_ivl_max`.
819 // Available from libzmq 3.0.0.
737820 // Caller owns return value and must destroy it when done.
738821 CZMQ_EXPORT int
739822 zsock_reconnect_ivl_max (void *self);
740823
741824 // Set socket option `reconnect_ivl_max`.
825 // Available from libzmq 3.0.0.
742826 CZMQ_EXPORT void
743827 zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max);
744828
745829 // Get socket option `backlog`.
830 // Available from libzmq 3.0.0.
746831 // Caller owns return value and must destroy it when done.
747832 CZMQ_EXPORT int
748833 zsock_backlog (void *self);
749834
750835 // Set socket option `backlog`.
836 // Available from libzmq 3.0.0.
751837 CZMQ_EXPORT void
752838 zsock_set_backlog (void *self, int backlog);
753839
754840 // Get socket option `maxmsgsize`.
841 // Available from libzmq 3.0.0.
755842 // Caller owns return value and must destroy it when done.
756843 CZMQ_EXPORT int
757844 zsock_maxmsgsize (void *self);
758845
759846 // Set socket option `maxmsgsize`.
847 // Available from libzmq 3.0.0.
760848 CZMQ_EXPORT void
761849 zsock_set_maxmsgsize (void *self, int maxmsgsize);
762850
763851 // Get socket option `multicast_hops`.
852 // Available from libzmq 3.0.0.
764853 // Caller owns return value and must destroy it when done.
765854 CZMQ_EXPORT int
766855 zsock_multicast_hops (void *self);
767856
768857 // Set socket option `multicast_hops`.
858 // Available from libzmq 3.0.0.
769859 CZMQ_EXPORT void
770860 zsock_set_multicast_hops (void *self, int multicast_hops);
771861
772862 // Get socket option `rcvtimeo`.
863 // Available from libzmq 3.0.0.
773864 // Caller owns return value and must destroy it when done.
774865 CZMQ_EXPORT int
775866 zsock_rcvtimeo (void *self);
776867
777868 // Set socket option `rcvtimeo`.
869 // Available from libzmq 3.0.0.
778870 CZMQ_EXPORT void
779871 zsock_set_rcvtimeo (void *self, int rcvtimeo);
780872
781873 // Get socket option `sndtimeo`.
874 // Available from libzmq 3.0.0.
782875 // Caller owns return value and must destroy it when done.
783876 CZMQ_EXPORT int
784877 zsock_sndtimeo (void *self);
785878
786879 // Set socket option `sndtimeo`.
880 // Available from libzmq 3.0.0.
787881 CZMQ_EXPORT void
788882 zsock_set_sndtimeo (void *self, int sndtimeo);
789883
790884 // Set socket option `xpub_verbose`.
885 // Available from libzmq 3.0.0.
791886 CZMQ_EXPORT void
792887 zsock_set_xpub_verbose (void *self, int xpub_verbose);
793888
794889 // Get socket option `tcp_keepalive`.
890 // Available from libzmq 3.0.0.
795891 // Caller owns return value and must destroy it when done.
796892 CZMQ_EXPORT int
797893 zsock_tcp_keepalive (void *self);
798894
799895 // Set socket option `tcp_keepalive`.
896 // Available from libzmq 3.0.0.
800897 CZMQ_EXPORT void
801898 zsock_set_tcp_keepalive (void *self, int tcp_keepalive);
802899
803900 // Get socket option `tcp_keepalive_idle`.
901 // Available from libzmq 3.0.0.
804902 // Caller owns return value and must destroy it when done.
805903 CZMQ_EXPORT int
806904 zsock_tcp_keepalive_idle (void *self);
807905
808906 // Set socket option `tcp_keepalive_idle`.
907 // Available from libzmq 3.0.0.
809908 CZMQ_EXPORT void
810909 zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle);
811910
812911 // Get socket option `tcp_keepalive_cnt`.
912 // Available from libzmq 3.0.0.
813913 // Caller owns return value and must destroy it when done.
814914 CZMQ_EXPORT int
815915 zsock_tcp_keepalive_cnt (void *self);
816916
817917 // Set socket option `tcp_keepalive_cnt`.
918 // Available from libzmq 3.0.0.
818919 CZMQ_EXPORT void
819920 zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt);
820921
821922 // Get socket option `tcp_keepalive_intvl`.
923 // Available from libzmq 3.0.0.
822924 // Caller owns return value and must destroy it when done.
823925 CZMQ_EXPORT int
824926 zsock_tcp_keepalive_intvl (void *self);
825927
826928 // Set socket option `tcp_keepalive_intvl`.
929 // Available from libzmq 3.0.0.
827930 CZMQ_EXPORT void
828931 zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl);
829932
830933 // Get socket option `tcp_accept_filter`.
934 // Available from libzmq 3.0.0.
831935 // Caller owns return value and must destroy it when done.
832936 CZMQ_EXPORT char *
833937 zsock_tcp_accept_filter (void *self);
834938
835939 // Set socket option `tcp_accept_filter`.
940 // Available from libzmq 3.0.0.
836941 CZMQ_EXPORT void
837942 zsock_set_tcp_accept_filter (void *self, const char *tcp_accept_filter);
838943
839944 // Get socket option `rcvmore`.
945 // Available from libzmq 3.0.0.
840946 // Caller owns return value and must destroy it when done.
841947 CZMQ_EXPORT int
842948 zsock_rcvmore (void *self);
843949
844 // Get socket option `fd`.
950 // Get socket option `fd`.
951 // Available from libzmq 3.0.0.
845952 // Caller owns return value and must destroy it when done.
846953 CZMQ_EXPORT SOCKET
847954 zsock_fd (void *self);
848955
849 // Get socket option `events`.
956 // Get socket option `events`.
957 // Available from libzmq 3.0.0.
850958 // Caller owns return value and must destroy it when done.
851959 CZMQ_EXPORT int
852960 zsock_events (void *self);
853961
854962 // Get socket option `last_endpoint`.
963 // Available from libzmq 3.0.0.
855964 // Caller owns return value and must destroy it when done.
856965 CZMQ_EXPORT char *
857966 zsock_last_endpoint (void *self);
967
968 // Set socket option `router_raw`.
969 // Available from libzmq 3.0.0.
970 CZMQ_EXPORT void
971 zsock_set_router_raw (void *self, int router_raw);
972
973 // Get socket option `ipv4only`.
974 // Available from libzmq 3.0.0.
975 // Caller owns return value and must destroy it when done.
976 CZMQ_EXPORT int
977 zsock_ipv4only (void *self);
978
979 // Set socket option `ipv4only`.
980 // Available from libzmq 3.0.0.
981 CZMQ_EXPORT void
982 zsock_set_ipv4only (void *self, int ipv4only);
983
984 // Set socket option `delay_attach_on_connect`.
985 // Available from libzmq 3.0.0.
986 CZMQ_EXPORT void
987 zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect);
858988
859989 // Self test of this class.
860990 CZMQ_EXPORT void
9161046 zsock_leave (void *self, const char *group);
9171047
9181048 #endif // CZMQ_BUILD_DRAFT_API
1049 Please add '@interface' section in './../src/zsock.c'.
9191050 ----
9201051
9211052 DESCRIPTION
9261057 Some zsock methods take a void * "polymorphic" reference, which can be
9271058 either a zsock_t or a zactor_t reference, or a libzmq void *.
9281059
929 Please add @discuss section in ../src/zsock.c.
1060 Please add '@discuss' section in './../src/zsock.c'.
9301061
9311062 EXAMPLE
9321063 -------
10421173 // Test zsock_send/recv pictures
10431174 uint8_t number1 = 123;
10441175 uint16_t number2 = 123 * 123;
1045 uint32_t number4 = 123 * 123 * 123;
1046 uint64_t number4_MAX = UINT32_MAX;
1047 uint64_t number8 = 123 * 123 * 123 * 123;
1176 uint32_t number4 = 123 * 123;
1177 number4 *= 123;
1178 uint32_t number4_MAX = UINT32_MAX;
1179 uint64_t number8 = 123 * 123;
1180 number8 *= 123;
1181 number8 *= 123;
10481182 uint64_t number8_MAX = UINT64_MAX;
10491183
10501184 zchunk_t *chunk = zchunk_new ("HELLO", 5);
10771211 byte *data;
10781212 size_t size;
10791213 char *pointer;
1080 number8_MAX = number8 = number4 = number2 = number1 = 0;
1214 number8_MAX = number8 = number4_MAX = number4 = number2 = number1 = 0ULL;
10811215 rc = zsock_recv (reader, "i124488zsbcfUhp",
10821216 &integer, &number1, &number2, &number4, &number4_MAX,
10831217 &number8, &number8_MAX, &string, &data, &size, &chunk,
0 '\" t
1 .\" Title: zstr
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZSTR" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zstr \- sending and receiving strings
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // This class has draft methods, which may change over time\&. They are not
37 // in stable releases, by default\&. Use \-\-enable\-drafts to enable\&.
38 // Receive C string from socket\&. Caller must free returned string using
39 // zstr_free()\&. Returns NULL if the context is being terminated or the
40 // process was interrupted\&.
41 // Caller owns return value and must destroy it when done\&.
42 CZMQ_EXPORT char *
43 zstr_recv (void *source);
44
45 // Receive a series of strings (until NULL) from multipart data\&.
46 // Each string is allocated and filled with string data; if there
47 // are not enough frames, unallocated strings are set to NULL\&.
48 // Returns \-1 if the message could not be read, else returns the
49 // number of strings filled, zero or more\&. Free each returned string
50 // using zstr_free()\&. If not enough strings are provided, remaining
51 // multipart frames in the message are dropped\&.
52 CZMQ_EXPORT int
53 zstr_recvx (void *source, char **string_p, \&.\&.\&.);
54
55 // Send a C string to a socket, as a frame\&. The string is sent without
56 // trailing null byte; to read this you can use zstr_recv, or a similar
57 // method that adds a null terminator on the received string\&. String
58 // may be NULL, which is sent as ""\&.
59 CZMQ_EXPORT int
60 zstr_send (void *dest, const char *string);
61
62 // Send a C string to a socket, as zstr_send(), with a MORE flag, so that
63 // you can send further strings in the same multi\-part message\&.
64 CZMQ_EXPORT int
65 zstr_sendm (void *dest, const char *string);
66
67 // Send a formatted string to a socket\&. Note that you should NOT use
68 // user\-supplied strings in the format (they may contain \*(Aq%\*(Aq which
69 // will create security holes)\&.
70 CZMQ_EXPORT int
71 zstr_sendf (void *dest, const char *format, \&.\&.\&.) CHECK_PRINTF (2);
72
73 // Send a formatted string to a socket, as for zstr_sendf(), with a
74 // MORE flag, so that you can send further strings in the same multi\-part
75 // message\&.
76 CZMQ_EXPORT int
77 zstr_sendfm (void *dest, const char *format, \&.\&.\&.) CHECK_PRINTF (2);
78
79 // Send a series of strings (until NULL) as multipart data
80 // Returns 0 if the strings could be sent OK, or \-1 on error\&.
81 CZMQ_EXPORT int
82 zstr_sendx (void *dest, const char *string, \&.\&.\&.);
83
84 // Free a provided string, and nullify the parent pointer\&. Safe to call on
85 // a null pointer\&.
86 CZMQ_EXPORT void
87 zstr_free (char **string_p);
88
89 // Self test of this class\&.
90 CZMQ_EXPORT void
91 zstr_test (bool verbose);
92
93 #ifdef CZMQ_BUILD_DRAFT_API
94 // *** Draft method, for development use, may change without warning ***
95 // Accepts a void pointer and returns a fresh character string\&. If source
96 // is null, returns an empty string\&.
97 // Caller owns return value and must destroy it when done\&.
98 CZMQ_EXPORT char *
99 zstr_str (void *source);
100
101 #endif // CZMQ_BUILD_DRAFT_API
102 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zstr\&.c\*(Aq\&.
103 .fi
104 .SH "DESCRIPTION"
105 .sp
106 The zstr class provides utility functions for sending and receiving C strings across 0MQ sockets\&. It sends strings without a terminating null, and appends a null byte on received strings\&. This class is for simple message sending\&.
107 .sp
108 .if n \{\
109 .RS 4
110 .\}
111 .nf
112 Memory Wire
113 +\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-+ +\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-+
114 Send | S t r i n g | 0 | \-\-\-\-> | 6 | S t r i n g |
115 +\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-+ +\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-+
116 .fi
117 .if n \{\
118 .RE
119 .\}
120 .sp
121 .if n \{\
122 .RS 4
123 .\}
124 .nf
125 Wire Heap
126 +\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-+
127 Recv | 6 | S t r i n g | \-\-\-\-> | S t r i n g | 0 |
128 +\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-+
129 .fi
130 .if n \{\
131 .RE
132 .\}
133 .SH "EXAMPLE"
134 .PP
135 \fBFrom zstr_test method\fR.
136 .sp
137 .if n \{\
138 .RS 4
139 .\}
140 .nf
141 // Create two PAIR sockets and connect over inproc
142 zsock_t *output = zsock_new_pair ("@inproc://zstr\&.test");
143 assert (output);
144 zsock_t *input = zsock_new_pair (">inproc://zstr\&.test");
145 assert (input);
146
147 // Send ten strings, five strings with MORE flag and then END
148 int string_nbr;
149 for (string_nbr = 0; string_nbr < 10; string_nbr++)
150 zstr_sendf (output, "this is string %d", string_nbr);
151 zstr_sendx (output, "This", "is", "almost", "the", "very", "END", NULL);
152
153 // Read and count until we receive END
154 string_nbr = 0;
155 for (string_nbr = 0;; string_nbr++) {
156 char *string = zstr_recv (input);
157 assert (string);
158 if (streq (string, "END")) {
159 zstr_free (&string);
160 break;
161 }
162 zstr_free (&string);
163 }
164 assert (string_nbr == 15);
165
166 zsock_destroy (&input);
167 zsock_destroy (&output);
168
169 #if defined (ZMQ_SERVER)
170 // Test SERVER/CLIENT over zstr
171 zsock_t *server = zsock_new_server ("inproc://zstr\-test\-routing");
172 zsock_t *client = zsock_new_client ("inproc://zstr\-test\-routing");;
173 assert (server);
174 assert (client);
175
176 // Try normal ping\-pong to check reply routing ID
177 int rc = zstr_send (client, "Hello");
178 assert (rc == 0);
179 char *request = zstr_recv (server);
180 assert (streq (request, "Hello"));
181 assert (zsock_routing_id (server));
182 free (request);
183
184 rc = zstr_send (server, "World");
185 assert (rc == 0);
186 char *reply = zstr_recv (client);
187 assert (streq (reply, "World"));
188 free (reply);
189
190 rc = zstr_sendf (server, "%s", "World");
191 assert (rc == 0);
192 reply = zstr_recv (client);
193 assert (streq (reply, "World"));
194 free (reply);
195
196 // Try ping\-pong using sendx and recx
197 rc = zstr_sendx (client, "Hello", NULL);
198 assert (rc == 0);
199 rc = zstr_recvx (server, &request, NULL);
200 assert (rc >= 0);
201 assert (streq (request, "Hello"));
202 free (request);
203
204 rc = zstr_sendx (server, "World", NULL);
205 assert (rc == 0);
206 rc = zstr_recvx (client, &reply, NULL);
207 assert (rc >= 0);
208 assert (streq (reply, "World"));
209 free (reply);
210
211 // Client and server disallow multipart
212 rc = zstr_sendm (client, "Hello");
213 assert (rc == \-1);
214 rc = zstr_sendm (server, "World");
215 assert (rc == \-1);
216
217 zsock_destroy (&client);
218 zsock_destroy (&server);
219 #endif
220 .fi
221 .if n \{\
222 .RE
223 .\}
224 .sp
225 .SH "AUTHORS"
226 .sp
227 The czmq manual was written by the authors in the AUTHORS file\&.
228 .SH "RESOURCES"
229 .sp
230 Main web site: \m[blue]\fB\%\fR\m[]
231 .sp
232 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
233 .SH "COPYRIGHT"
234 .sp
235 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
236 .SH "NOTES"
237 .IP " 1." 4
238 zeromq-dev@lists.zeromq.org
239 .RS 4
240 \%mailto:zeromq-dev@lists.zeromq.org
241 .RE
7575 zstr_str (void *source);
7676
7777 #endif // CZMQ_BUILD_DRAFT_API
78 Please add '@interface' section in './../src/zstr.c'.
7879 ----
7980
8081 DESCRIPTION
0 '\" t
1 .\" Title: zsys
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZSYS" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zsys \- system\-level methods
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 #define UDP_FRAME_MAX 255 // Max size of UDP frame
35
36 // Callback for interrupt signal handler
37 typedef void (zsys_handler_fn) (int signal_value);
38
39 // Initialize CZMQ zsys layer; this happens automatically when you create
40 // a socket or an actor; however this call lets you force initialization
41 // earlier, so e\&.g\&. logging is properly set\-up before you start working\&.
42 // Not threadsafe, so call only from main thread\&. Safe to call multiple
43 // times\&. Returns global CZMQ context\&.
44 CZMQ_EXPORT void *
45 zsys_init (void);
46
47 // Optionally shut down the CZMQ zsys layer; this normally happens automatically
48 // when the process exits; however this call lets you force a shutdown
49 // earlier, avoiding any potential problems with atexit() ordering, especially
50 // with Windows dlls\&.
51 CZMQ_EXPORT void
52 zsys_shutdown (void);
53
54 // Get a new ZMQ socket, automagically creating a ZMQ context if this is
55 // the first time\&. Caller is responsible for destroying the ZMQ socket
56 // before process exits, to avoid a ZMQ deadlock\&. Note: you should not use
57 // this method in CZMQ apps, use zsock_new() instead\&.
58 // *** This is for CZMQ internal use only and may change arbitrarily ***
59 CZMQ_EXPORT void *
60 zsys_socket (int type, const char *filename, size_t line_nbr);
61
62 // Destroy/close a ZMQ socket\&. You should call this for every socket you
63 // create using zsys_socket()\&.
64 // *** This is for CZMQ internal use only and may change arbitrarily ***
65 CZMQ_EXPORT int
66 zsys_close (void *handle, const char *filename, size_t line_nbr);
67
68 // Return ZMQ socket name for socket type
69 // *** This is for CZMQ internal use only and may change arbitrarily ***
70 CZMQ_EXPORT char *
71 zsys_sockname (int socktype);
72
73 // Create a pipe, which consists of two PAIR sockets connected over inproc\&.
74 // The pipe is configured to use the zsys_pipehwm setting\&. Returns the
75 // frontend socket successful, NULL if failed\&.
76 CZMQ_EXPORT zsock_t *
77 zsys_create_pipe (zsock_t **backend_p);
78
79 // Set interrupt handler; this saves the default handlers so that a
80 // zsys_handler_reset () can restore them\&. If you call this multiple times
81 // then the last handler will take affect\&. If handler_fn is NULL, disables
82 // default SIGINT/SIGTERM handling in CZMQ\&.
83 CZMQ_EXPORT void
84 zsys_handler_set (zsys_handler_fn *handler_fn);
85
86 // Reset interrupt handler, call this at exit if needed
87 CZMQ_EXPORT void
88 zsys_handler_reset (void);
89
90 // Set default interrupt handler, so Ctrl\-C or SIGTERM will set
91 // zsys_interrupted\&. Idempotent; safe to call multiple times\&.
92 // *** This is for CZMQ internal use only and may change arbitrarily ***
93 CZMQ_EXPORT void
94 zsys_catch_interrupts (void);
95
96 // Return 1 if file exists, else zero
97 CZMQ_EXPORT bool
98 zsys_file_exists (const char *filename);
99
100 // Return size of file, or \-1 if not found
101 CZMQ_EXPORT ssize_t
102 zsys_file_size (const char *filename);
103
104 // Return file modification time\&. Returns 0 if the file does not exist\&.
105 CZMQ_EXPORT time_t
106 zsys_file_modified (const char *filename);
107
108 // Return file mode; provides at least support for the POSIX S_ISREG(m)
109 // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes\&.
110 // Returns a mode_t cast to int, or \-1 in case of error\&.
111 CZMQ_EXPORT int
112 zsys_file_mode (const char *filename);
113
114 // Delete file\&. Does not complain if the file is absent
115 CZMQ_EXPORT int
116 zsys_file_delete (const char *filename);
117
118 // Check if file is \*(Aqstable\*(Aq
119 CZMQ_EXPORT bool
120 zsys_file_stable (const char *filename);
121
122 // Create a file path if it doesn\*(Aqt exist\&. The file path is treated as a
123 // printf format\&.
124 CZMQ_EXPORT int
125 zsys_dir_create (const char *pathname, \&.\&.\&.);
126
127 // Remove a file path if empty; the pathname is treated as printf format\&.
128 CZMQ_EXPORT int
129 zsys_dir_delete (const char *pathname, \&.\&.\&.);
130
131 // Move to a specified working directory\&. Returns 0 if OK, \-1 if this failed\&.
132 CZMQ_EXPORT int
133 zsys_dir_change (const char *pathname);
134
135 // Set private file creation mode; all files created from here will be
136 // readable/writable by the owner only\&.
137 CZMQ_EXPORT void
138 zsys_file_mode_private (void);
139
140 // Reset default file creation mode; all files created from here will use
141 // process file mode defaults\&.
142 CZMQ_EXPORT void
143 zsys_file_mode_default (void);
144
145 // Return the CZMQ version for run\-time API detection; returns version
146 // number into provided fields, providing reference isn\*(Aqt null in each case\&.
147 CZMQ_EXPORT void
148 zsys_version (int *major, int *minor, int *patch);
149
150 // Format a string using printf formatting, returning a freshly allocated
151 // buffer\&. If there was insufficient memory, returns NULL\&. Free the returned
152 // string using zstr_free()\&.
153 CZMQ_EXPORT char *
154 zsys_sprintf (const char *format, \&.\&.\&.);
155
156 // Format a string with a va_list argument, returning a freshly allocated
157 // buffer\&. If there was insufficient memory, returns NULL\&. Free the returned
158 // string using zstr_free()\&.
159 CZMQ_EXPORT char *
160 zsys_vprintf (const char *format, va_list argptr);
161
162 // Create UDP beacon socket; if the routable option is true, uses
163 // multicast (not yet implemented), else uses broadcast\&. This method
164 // and related ones might _eventually_ be moved to a zudp class\&.
165 // *** This is for CZMQ internal use only and may change arbitrarily ***
166 CZMQ_EXPORT SOCKET
167 zsys_udp_new (bool routable);
168
169 // Close a UDP socket
170 // *** This is for CZMQ internal use only and may change arbitrarily ***
171 CZMQ_EXPORT int
172 zsys_udp_close (SOCKET handle);
173
174 // Send zframe to UDP socket, return \-1 if sending failed due to
175 // interface having disappeared (happens easily with WiFi)
176 // *** This is for CZMQ internal use only and may change arbitrarily ***
177 CZMQ_EXPORT int
178 zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address, int addrlen);
179
180 // Receive zframe from UDP socket, and set address of peer that sent it
181 // The peername must be a char [INET_ADDRSTRLEN] array\&.
182 // *** This is for CZMQ internal use only and may change arbitrarily ***
183 CZMQ_EXPORT zframe_t *
184 zsys_udp_recv (SOCKET udpsock, char *peername, int peerlen);
185
186 // Handle an I/O error on some socket operation; will report and die on
187 // fatal errors, and continue silently on "try again" errors\&.
188 // *** This is for CZMQ internal use only and may change arbitrarily ***
189 CZMQ_EXPORT void
190 zsys_socket_error (const char *reason);
191
192 // Return current host name, for use in public tcp:// endpoints\&. Caller gets
193 // a freshly allocated string, should free it using zstr_free()\&. If the host
194 // name is not resolvable, returns NULL\&.
195 CZMQ_EXPORT char *
196 zsys_hostname (void);
197
198 // Move the current process into the background\&. The precise effect depends
199 // on the operating system\&. On POSIX boxes, moves to a specified working
200 // directory (if specified), closes all file handles, reopens stdin, stdout,
201 // and stderr to the null device, and sets the process to ignore SIGHUP\&. On
202 // Windows, does nothing\&. Returns 0 if OK, \-1 if there was an error\&.
203 CZMQ_EXPORT int
204 zsys_daemonize (const char *workdir);
205
206 // Drop the process ID into the lockfile, with exclusive lock, and switch
207 // the process to the specified group and/or user\&. Any of the arguments
208 // may be null, indicating a no\-op\&. Returns 0 on success, \-1 on failure\&.
209 // Note if you combine this with zsys_daemonize, run after, not before
210 // that method, or the lockfile will hold the wrong process ID\&.
211 CZMQ_EXPORT int
212 zsys_run_as (const char *lockfile, const char *group, const char *user);
213
214 // Returns true if the underlying libzmq supports CURVE security\&.
215 // Uses a heuristic probe according to the version of libzmq being used\&.
216 CZMQ_EXPORT bool
217 zsys_has_curve (void);
218
219 // Configure the number of I/O threads that ZeroMQ will use\&. A good
220 // rule of thumb is one thread per gigabit of traffic in or out\&. The
221 // default is 1, sufficient for most applications\&. If the environment
222 // variable ZSYS_IO_THREADS is defined, that provides the default\&.
223 // Note that this method is valid only before any socket is created\&.
224 CZMQ_EXPORT void
225 zsys_set_io_threads (size_t io_threads);
226
227 // Configure the number of sockets that ZeroMQ will allow\&. The default
228 // is 1024\&. The actual limit depends on the system, and you can query it
229 // by using zsys_socket_limit ()\&. A value of zero means "maximum"\&.
230 // Note that this method is valid only before any socket is created\&.
231 CZMQ_EXPORT void
232 zsys_set_max_sockets (size_t max_sockets);
233
234 // Return maximum number of ZeroMQ sockets that the system will support\&.
235 CZMQ_EXPORT size_t
236 zsys_socket_limit (void);
237
238 // Configure the maximum allowed size of a message sent\&.
239 // The default is INT_MAX\&.
240 CZMQ_EXPORT void
241 zsys_set_max_msgsz (int max_msgsz);
242
243 // Return maximum message size\&.
244 CZMQ_EXPORT int
245 zsys_max_msgsz (void);
246
247 // Configure the default linger timeout in msecs for new zsock instances\&.
248 // You can also set this separately on each zsock_t instance\&. The default
249 // linger time is zero, i\&.e\&. any pending messages will be dropped\&. If the
250 // environment variable ZSYS_LINGER is defined, that provides the default\&.
251 // Note that process exit will typically be delayed by the linger time\&.
252 CZMQ_EXPORT void
253 zsys_set_linger (size_t linger);
254
255 // Configure the default outgoing pipe limit (HWM) for new zsock instances\&.
256 // You can also set this separately on each zsock_t instance\&. The default
257 // HWM is 1,000, on all versions of ZeroMQ\&. If the environment variable
258 // ZSYS_SNDHWM is defined, that provides the default\&. Note that a value of
259 // zero means no limit, i\&.e\&. infinite memory consumption\&.
260 CZMQ_EXPORT void
261 zsys_set_sndhwm (size_t sndhwm);
262
263 // Configure the default incoming pipe limit (HWM) for new zsock instances\&.
264 // You can also set this separately on each zsock_t instance\&. The default
265 // HWM is 1,000, on all versions of ZeroMQ\&. If the environment variable
266 // ZSYS_RCVHWM is defined, that provides the default\&. Note that a value of
267 // zero means no limit, i\&.e\&. infinite memory consumption\&.
268 CZMQ_EXPORT void
269 zsys_set_rcvhwm (size_t rcvhwm);
270
271 // Configure the default HWM for zactor internal pipes; this is set on both
272 // ends of the pipe, for outgoing messages only (sndhwm)\&. The default HWM is
273 // 1,000, on all versions of ZeroMQ\&. If the environment var ZSYS_ACTORHWM is
274 // defined, that provides the default\&. Note that a value of zero means no
275 // limit, i\&.e\&. infinite memory consumption\&.
276 CZMQ_EXPORT void
277 zsys_set_pipehwm (size_t pipehwm);
278
279 // Return the HWM for zactor internal pipes\&.
280 CZMQ_EXPORT size_t
281 zsys_pipehwm (void);
282
283 // Configure use of IPv6 for new zsock instances\&. By default sockets accept
284 // and make only IPv4 connections\&. When you enable IPv6, sockets will accept
285 // and connect to both IPv4 and IPv6 peers\&. You can override the setting on
286 // each zsock_t instance\&. The default is IPv4 only (ipv6 set to 0)\&. If the
287 // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the
288 // default\&. Note: has no effect on ZMQ v2\&.
289 CZMQ_EXPORT void
290 zsys_set_ipv6 (int ipv6);
291
292 // Return use of IPv6 for zsock instances\&.
293 CZMQ_EXPORT int
294 zsys_ipv6 (void);
295
296 // Set network interface name to use for broadcasts, particularly zbeacon\&.
297 // This lets the interface be configured for test environments where required\&.
298 // For example, on Mac OS X, zbeacon cannot bind to 255\&.255\&.255\&.255 which is
299 // the default when there is no specified interface\&. If the environment
300 // variable ZSYS_INTERFACE is set, use that as the default interface name\&.
301 // Setting the interface to "*" means "use all available interfaces"\&.
302 CZMQ_EXPORT void
303 zsys_set_interface (const char *value);
304
305 // Return network interface to use for broadcasts, or "" if none was set\&.
306 CZMQ_EXPORT const char *
307 zsys_interface (void);
308
309 // Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon\&.
310 // This needs to be set IPv6 is enabled as IPv6 can have multiple addresses
311 // on a given interface\&. If the environment variable ZSYS_IPV6_ADDRESS is set,
312 // use that as the default IPv6 address\&.
313 CZMQ_EXPORT void
314 zsys_set_ipv6_address (const char *value);
315
316 // Return IPv6 address to use for zbeacon reception, or "" if none was set\&.
317 CZMQ_EXPORT const char *
318 zsys_ipv6_address (void);
319
320 // Set IPv6 milticast address to use for sending zbeacon messages\&. This needs
321 // to be set if IPv6 is enabled\&. If the environment variable
322 // ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast
323 // address\&.
324 CZMQ_EXPORT void
325 zsys_set_ipv6_mcast_address (const char *value);
326
327 // Return IPv6 multicast address to use for sending zbeacon, or "" if none was
328 // set\&.
329 CZMQ_EXPORT const char *
330 zsys_ipv6_mcast_address (void);
331
332 // Configure the automatic use of pre\-allocated FDs when creating new sockets\&.
333 // If 0 (default), nothing will happen\&. Else, when a new socket is bound, the
334 // system API will be used to check if an existing pre\-allocated FD with a
335 // matching port (if TCP) or path (if IPC) exists, and if it does it will be
336 // set via the ZMQ_USE_FD socket option so that the library will use it
337 // instead of creating a new socket\&.
338 CZMQ_EXPORT void
339 zsys_set_auto_use_fd (int auto_use_fd);
340
341 // Return use of automatic pre\-allocated FDs for zsock instances\&.
342 CZMQ_EXPORT int
343 zsys_auto_use_fd (void);
344
345 // Set log identity, which is a string that prefixes all log messages sent
346 // by this process\&. The log identity defaults to the environment variable
347 // ZSYS_LOGIDENT, if that is set\&.
348 CZMQ_EXPORT void
349 zsys_set_logident (const char *value);
350
351 // Set stream to receive log traffic\&. By default, log traffic is sent to
352 // stdout\&. If you set the stream to NULL, no stream will receive the log
353 // traffic (it may still be sent to the system facility)\&.
354 CZMQ_EXPORT void
355 zsys_set_logstream (FILE *stream);
356
357 // Sends log output to a PUB socket bound to the specified endpoint\&. To
358 // collect such log output, create a SUB socket, subscribe to the traffic
359 // you care about, and connect to the endpoint\&. Log traffic is sent as a
360 // single string frame, in the same format as when sent to stdout\&. The
361 // log system supports a single sender; multiple calls to this method will
362 // bind the same sender to multiple endpoints\&. To disable the sender, call
363 // this method with a null argument\&.
364 CZMQ_EXPORT void
365 zsys_set_logsender (const char *endpoint);
366
367 // Enable or disable logging to the system facility (syslog on POSIX boxes,
368 // event log on Windows)\&. By default this is disabled\&.
369 CZMQ_EXPORT void
370 zsys_set_logsystem (bool logsystem);
371
372 // Log error condition \- highest priority
373 CZMQ_EXPORT void
374 zsys_error (const char *format, \&.\&.\&.);
375
376 // Log warning condition \- high priority
377 CZMQ_EXPORT void
378 zsys_warning (const char *format, \&.\&.\&.);
379
380 // Log normal, but significant, condition \- normal priority
381 CZMQ_EXPORT void
382 zsys_notice (const char *format, \&.\&.\&.);
383
384 // Log informational message \- low priority
385 CZMQ_EXPORT void
386 zsys_info (const char *format, \&.\&.\&.);
387
388 // Log debug\-level message \- lowest priority
389 CZMQ_EXPORT void
390 zsys_debug (const char *format, \&.\&.\&.);
391
392 // Self test of this class
393 CZMQ_EXPORT void
394 zsys_test (bool verbose);
395
396 // Global signal indicator, TRUE when user presses Ctrl\-C or the process
397 // gets a SIGTERM signal\&.
398 CZMQ_EXPORT extern volatile int zsys_interrupted;
399 // Deprecated name for this variable
400 CZMQ_EXPORT extern volatile int zctx_interrupted;
401 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zsys\&.c\*(Aq\&.
402 .fi
403 .SH "DESCRIPTION"
404 .sp
405 The zsys class provides a portable wrapper for system calls\&. We collect them here to reduce the number of weird #ifdefs in other classes\&. As far as possible, the bulk of CZMQ classes are fully portable\&.
406 .sp
407 Please add \fI@discuss\fR section in \fI\&./\&.\&./src/zsys\&.c\fR\&.
408 .SH "EXAMPLE"
409 .PP
410 \fBFrom zsys_test method\fR.
411 .sp
412 .if n \{\
413 .RS 4
414 .\}
415 .nf
416 zsys_catch_interrupts ();
417
418 // Check capabilities without using the return value
419 int rc = zsys_has_curve ();
420
421 if (verbose) {
422 char *hostname = zsys_hostname ();
423 zsys_info ("host name is %s", hostname);
424 free (hostname);
425 zsys_info ("system limit is %zu ZeroMQ sockets", zsys_socket_limit ());
426 }
427 zsys_set_linger (0);
428 zsys_set_sndhwm (1000);
429 zsys_set_rcvhwm (1000);
430 zsys_set_pipehwm (2500);
431 assert (zsys_pipehwm () == 2500);
432 zsys_set_ipv6 (0);
433
434 // Test pipe creation
435 zsock_t *pipe_back;
436 zsock_t *pipe_front = zsys_create_pipe (&pipe_back);
437 zstr_send (pipe_front, "Hello");
438 char *string = zstr_recv (pipe_back);
439 assert (streq (string, "Hello"));
440 free (string);
441 zsock_destroy (&pipe_back);
442 zsock_destroy (&pipe_front);
443
444 // Test file manipulation
445 rc = zsys_file_delete ("nosuchfile");
446 assert (rc == \-1);
447
448 bool rc_bool = zsys_file_exists ("nosuchfile");
449 assert (rc_bool != true);
450
451 rc = (int) zsys_file_size ("nosuchfile");
452 assert (rc == \-1);
453
454 time_t when = zsys_file_modified ("\&.");
455 assert (when > 0);
456
457 int mode = zsys_file_mode ("\&.");
458 assert (S_ISDIR (mode));
459 assert (mode & S_IRUSR);
460 assert (mode & S_IWUSR);
461
462 zsys_file_mode_private ();
463 rc = zsys_dir_create ("%s/%s", "\&.", "\&.testsys/subdir");
464 assert (rc == 0);
465 when = zsys_file_modified ("\&./\&.testsys/subdir");
466 assert (when > 0);
467 assert (!zsys_file_stable ("\&./\&.testsys/subdir"));
468 rc = zsys_dir_delete ("%s/%s", "\&.", "\&.testsys/subdir");
469 assert (rc == 0);
470 rc = zsys_dir_delete ("%s/%s", "\&.", "\&.testsys");
471 assert (rc == 0);
472 zsys_file_mode_default ();
473 assert (zsys_dir_change ("\&.") == 0);
474
475 int major, minor, patch;
476 zsys_version (&major, &minor, &patch);
477 assert (major == CZMQ_VERSION_MAJOR);
478 assert (minor == CZMQ_VERSION_MINOR);
479 assert (patch == CZMQ_VERSION_PATCH);
480
481 string = zsys_sprintf ("%s %02x", "Hello", 16);
482 assert (streq (string, "Hello 10"));
483 free (string);
484
485 char *str64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,\&.";
486 int num10 = 1234567890;
487 string = zsys_sprintf ("%s%s%s%s%d", str64, str64, str64, str64, num10);
488 assert (strlen (string) == (4 * 64 + 10));
489 free (string);
490
491 // Test logging system
492 zsys_set_logident ("czmq_selftest");
493 zsys_set_logsender ("inproc://logging");
494 void *logger = zsys_socket (ZMQ_SUB, NULL, 0);
495 assert (logger);
496 rc = zmq_connect (logger, "inproc://logging");
497 assert (rc == 0);
498 rc = zmq_setsockopt (logger, ZMQ_SUBSCRIBE, "", 0);
499 assert (rc == 0);
500
501 if (verbose) {
502 zsys_error ("This is an %s message", "error");
503 zsys_warning ("This is a %s message", "warning");
504 zsys_notice ("This is a %s message", "notice");
505 zsys_info ("This is a %s message", "info");
506 zsys_debug ("This is a %s message", "debug");
507 zsys_set_logident ("hello, world");
508 zsys_info ("This is a %s message", "info");
509 zsys_debug ("This is a %s message", "debug");
510
511 // Check that logsender functionality is working
512 char *received = zstr_recv (logger);
513 assert (received);
514 zstr_free (&received);
515 }
516 zsys_close (logger, NULL, 0);
517 .fi
518 .if n \{\
519 .RE
520 .\}
521 .sp
522 .SH "AUTHORS"
523 .sp
524 The czmq manual was written by the authors in the AUTHORS file\&.
525 .SH "RESOURCES"
526 .sp
527 Main web site: \m[blue]\fB\%\fR\m[]
528 .sp
529 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
530 .SH "COPYRIGHT"
531 .sp
532 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
533 .SH "NOTES"
534 .IP " 1." 4
535 zeromq-dev@lists.zeromq.org
536 .RS 4
537 \%mailto:zeromq-dev@lists.zeromq.org
538 .RE
374374 CZMQ_EXPORT extern volatile int zsys_interrupted;
375375 // Deprecated name for this variable
376376 CZMQ_EXPORT extern volatile int zctx_interrupted;
377 Please add '@interface' section in './../src/zsys.c'.
377378 ----
378379
379380 DESCRIPTION
383384 them here to reduce the number of weird #ifdefs in other classes. As far
384385 as possible, the bulk of CZMQ classes are fully portable.
385386
386 Please add @discuss section in ../src/zsys.c.
387 Please add '@discuss' section in './../src/zsys.c'.
387388
388389 EXAMPLE
389390 -------
0 '\" t
1 .\" Title: ztimerset
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZTIMERSET" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 ztimerset \- timer set
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a draft class, and may change without notice\&. It is disabled in
35 // stable builds by default\&. If you use this in applications, please ask
36 // for it to be pushed to stable state\&. Use \-\-enable\-drafts to enable\&.
37 #ifdef CZMQ_BUILD_DRAFT_API
38 // Callback function for timer event\&.
39 typedef void (ztimerset_fn) (
40 int timer_id, void *arg);
41
42 // *** Draft method, for development use, may change without warning ***
43 // Create new timer set\&.
44 CZMQ_EXPORT ztimerset_t *
45 ztimerset_new (void);
46
47 // *** Draft method, for development use, may change without warning ***
48 // Destroy a timer set
49 CZMQ_EXPORT void
50 ztimerset_destroy (ztimerset_t **self_p);
51
52 // *** Draft method, for development use, may change without warning ***
53 // Add a timer to the set\&. Returns timer id if OK, \-1 on failure\&.
54 CZMQ_EXPORT int
55 ztimerset_add (ztimerset_t *self, size_t interval, ztimerset_fn handler, void *arg);
56
57 // *** Draft method, for development use, may change without warning ***
58 // Cancel a timer\&. Returns 0 if OK, \-1 on failure\&.
59 CZMQ_EXPORT int
60 ztimerset_cancel (ztimerset_t *self, int timer_id);
61
62 // *** Draft method, for development use, may change without warning ***
63 // Set timer interval\&. Returns 0 if OK, \-1 on failure\&.
64 // This method is slow, canceling the timer and adding a new one yield better performance\&.
65 CZMQ_EXPORT int
66 ztimerset_set_interval (ztimerset_t *self, int timer_id, size_t interval);
67
68 // *** Draft method, for development use, may change without warning ***
69 // Reset timer to start interval counting from current time\&. Returns 0 if OK, \-1 on failure\&.
70 // This method is slow, canceling the timer and adding a new one yield better performance\&.
71 CZMQ_EXPORT int
72 ztimerset_reset (ztimerset_t *self, int timer_id);
73
74 // *** Draft method, for development use, may change without warning ***
75 // Return the time until the next interval\&.
76 // Should be used as timeout parameter for the zpoller wait method\&.
77 // The timeout is in msec\&.
78 CZMQ_EXPORT int
79 ztimerset_timeout (ztimerset_t *self);
80
81 // *** Draft method, for development use, may change without warning ***
82 // Invoke callback function of all timers which their interval has elapsed\&.
83 // Should be call after zpoller wait method\&.
84 // Returns 0 if OK, \-1 on failure\&.
85 CZMQ_EXPORT int
86 ztimerset_execute (ztimerset_t *self);
87
88 // *** Draft method, for development use, may change without warning ***
89 // Self test of this class\&.
90 CZMQ_EXPORT void
91 ztimerset_test (bool verbose);
92
93 #endif // CZMQ_BUILD_DRAFT_API
94 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/ztimerset\&.c\*(Aq\&.
95 .fi
96 .SH "DESCRIPTION"
97 .sp
98 ztimerset \- timer set
99 .sp
100 Please add \fI@discuss\fR section in \fI\&./\&.\&./src/ztimerset\&.c\fR\&.
101 .SH "EXAMPLE"
102 .PP
103 \fBFrom ztimerset_test method\fR.
104 .sp
105 .if n \{\
106 .RS 4
107 .\}
108 .nf
109 // Simple create/destroy test
110 ztimerset_t *self = ztimerset_new ();
111 assert (self);
112
113 // Adding timer
114 bool timer_invoked = false;
115 int timer_id = ztimerset_add (self, 100, handler, &timer_invoked);
116 assert (timer_id != \-1);
117 int rc = ztimerset_execute (self);
118 assert (rc == 0);
119 assert (!timer_invoked);
120 int timeout = ztimerset_timeout (self);
121 assert (timeout > 0);
122 zclock_sleep (timeout);
123 rc = ztimerset_execute (self);
124 assert (rc == 0);
125 assert (timer_invoked);
126
127 // Cancel timer
128 timeout = ztimerset_timeout (self);
129 assert (timeout > 0);
130 rc = ztimerset_cancel (self, timer_id);
131 assert (rc == 0);
132 timeout = ztimerset_timeout (self);
133 assert(timeout == \-1);
134
135 // Reset a timer
136 timer_id = ztimerset_add (self, 100, handler, &timer_invoked);
137 assert (timer_id != \-1);
138 timeout = ztimerset_timeout (self);
139 assert (timeout > 0);
140 zclock_sleep (timeout / 2);
141 timeout = ztimerset_timeout (self);
142 rc = ztimerset_reset(self, timer_id);
143 assert (rc == 0);
144 int timeout2 = ztimerset_timeout (self);
145 assert (timeout2 > timeout);
146 rc = ztimerset_cancel (self, timer_id);
147 assert (rc == 0);
148
149 // Set interval
150 timer_id = ztimerset_add (self, 100, handler, &timer_invoked);
151 assert (timer_id != \-1);
152 timeout = ztimerset_timeout (self);
153 rc = ztimerset_set_interval(self, timer_id, 200);
154 timeout2 = ztimerset_timeout (self);
155 assert (timeout2 > timeout);
156
157 ztimerset_destroy (&self);
158 .fi
159 .if n \{\
160 .RE
161 .\}
162 .sp
163 .SH "AUTHORS"
164 .sp
165 The czmq manual was written by the authors in the AUTHORS file\&.
166 .SH "RESOURCES"
167 .sp
168 Main web site: \m[blue]\fB\%\fR\m[]
169 .sp
170 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
171 .SH "COPYRIGHT"
172 .sp
173 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
174 .SH "NOTES"
175 .IP " 1." 4
176 zeromq-dev@lists.zeromq.org
177 .RS 4
178 \%mailto:zeromq-dev@lists.zeromq.org
179 .RE
6767 ztimerset_test (bool verbose);
6868
6969 #endif // CZMQ_BUILD_DRAFT_API
70 Please add '@interface' section in './../src/ztimerset.c'.
7071 ----
7172
7273 DESCRIPTION
7475
7576 ztimerset - timer set
7677
77 Please add @discuss section in ../src/ztimerset.c.
78 Please add '@discuss' section in './../src/ztimerset.c'.
7879
7980 EXAMPLE
8081 -------
0 '\" t
1 .\" Title: ztrie
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZTRIE" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 ztrie \- simple trie for tokenizable strings
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a draft class, and may change without notice\&. It is disabled in
35 // stable builds by default\&. If you use this in applications, please ask
36 // for it to be pushed to stable state\&. Use \-\-enable\-drafts to enable\&.
37 #ifdef CZMQ_BUILD_DRAFT_API
38 // Callback function for ztrie_node to destroy node data\&.
39 typedef void (ztrie_destroy_data_fn) (
40 void **data);
41
42 // *** Draft method, for development use, may change without warning ***
43 // Creates a new ztrie\&.
44 CZMQ_EXPORT ztrie_t *
45 ztrie_new (char delimiter);
46
47 // *** Draft method, for development use, may change without warning ***
48 // Destroy the ztrie\&.
49 CZMQ_EXPORT void
50 ztrie_destroy (ztrie_t **self_p);
51
52 // *** Draft method, for development use, may change without warning ***
53 // Inserts a new route into the tree and attaches the data\&. Returns \-1
54 // if the route already exists, otherwise 0\&. This method takes ownership of
55 // the provided data if a destroy_data_fn is provided\&.
56 CZMQ_EXPORT int
57 ztrie_insert_route (ztrie_t *self, const char *path, void *data, ztrie_destroy_data_fn destroy_data_fn);
58
59 // *** Draft method, for development use, may change without warning ***
60 // Removes a route from the trie and destroys its data\&. Returns \-1 if the
61 // route does not exists, otherwise 0\&.
62 // the start of the list call zlist_first ()\&. Advances the cursor\&.
63 CZMQ_EXPORT int
64 ztrie_remove_route (ztrie_t *self, const char *path);
65
66 // *** Draft method, for development use, may change without warning ***
67 // Returns true if the path matches a route in the tree, otherwise false\&.
68 CZMQ_EXPORT bool
69 ztrie_matches (ztrie_t *self, const char *path);
70
71 // *** Draft method, for development use, may change without warning ***
72 // Returns the data of a matched route from last ztrie_matches\&. If the path
73 // did not match, returns NULL\&. Do not delete the data as it\*(Aqs owned by
74 // ztrie\&.
75 CZMQ_EXPORT void *
76 ztrie_hit_data (ztrie_t *self);
77
78 // *** Draft method, for development use, may change without warning ***
79 // Returns the count of parameters that a matched route has\&.
80 CZMQ_EXPORT size_t
81 ztrie_hit_parameter_count (ztrie_t *self);
82
83 // *** Draft method, for development use, may change without warning ***
84 // Returns the parameters of a matched route with named regexes from last
85 // ztrie_matches\&. If the path did not match or the route did not contain any
86 // named regexes, returns NULL\&.
87 CZMQ_EXPORT zhashx_t *
88 ztrie_hit_parameters (ztrie_t *self);
89
90 // *** Draft method, for development use, may change without warning ***
91 // Returns the asterisk matched part of a route, if there has been no match
92 // or no asterisk match, returns NULL\&.
93 CZMQ_EXPORT const char *
94 ztrie_hit_asterisk_match (ztrie_t *self);
95
96 // *** Draft method, for development use, may change without warning ***
97 // Print the trie
98 CZMQ_EXPORT void
99 ztrie_print (ztrie_t *self);
100
101 // *** Draft method, for development use, may change without warning ***
102 // Self test of this class\&.
103 CZMQ_EXPORT void
104 ztrie_test (bool verbose);
105
106 #endif // CZMQ_BUILD_DRAFT_API
107 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/ztrie\&.c\*(Aq\&.
108 .fi
109 .SH "DESCRIPTION"
110 .sp
111 This is a variant of a trie or prefix tree where all the descendants of a node have a common prefix of the string associated with that node\&. This implementation is specialized for strings that can be tokenized by a delimiter like a URL, URI or URN\&. Routes in the tree can be matched by regular expressions and by using capturing groups parts of a matched route can be easily obtained\&.
112 .sp
113 Note that the performance for pure string based matching is okay but on short strings zhash and zhashx are 3\-4 times faster\&.
114 .SH "EXAMPLE"
115 .PP
116 \fBFrom ztrie_test method\fR.
117 .sp
118 .if n \{\
119 .RS 4
120 .\}
121 .nf
122 // Create a new trie for matching strings that can be tokenized by a slash
123 // (e\&.g\&. URLs minus the protocol, address and port)\&.
124 ztrie_t *self = ztrie_new (\*(Aq/\*(Aq);
125 assert (self);
126
127 int ret = 0;
128
129 // Let\*(Aqs start by inserting a couple of routes into the trie\&.
130 // This one is for the route \*(Aq/foo/bar\*(Aq the slash at the beginning of the
131 // route is important because everything before the first delimiter will be
132 // discarded\&. A slash at the end of a route is optional though\&. The data
133 // associated with this node is passed without destroy function which means
134 // it must be destroyed by the caller\&.
135 int foo_bar_data = 10;
136 ret = ztrie_insert_route (self, "/foo/bar", &foo_bar_data, NULL);
137 assert (ret == 0);
138
139 // Now suppose we like to match all routes with two tokens that start with
140 // \*(Aq/foo/\*(Aq but aren\*(Aqt \*(Aq/foo/bar\*(Aq\&. This is possible by using regular
141 // expressions which are enclosed in an opening and closing curly bracket\&.
142 // Tokens that contain regular expressions are always match after string
143 // based tokens\&.
144 // Note: There is no order in which regular expressions are sorted thus
145 // if you enter multiple expressions for a route you will have to make
146 // sure they don\*(Aqt have overlapping results\&. For example \*(Aq/foo/{[^/]+}\*(Aq
147 // and \*(Aq/foo/{\ed+} having could turn out badly\&.
148 int foo_other_data = 100;
149 ret = ztrie_insert_route (self, "/foo/{[^/]+}", &foo_other_data, NULL);
150 assert (ret == 0);
151
152 // Regular expression are only matched against tokens of the same level\&.
153 // This allows us to append to are route with a regular expression as if
154 // it were a string\&.
155 ret = ztrie_insert_route (self, "/foo/{[^/]+}/gulp", NULL, NULL);
156 assert (ret == 0);
157
158 // Routes are identified by their endpoint, which is the last token of the route\&.
159 // It is possible to insert routes for a node that already exists but isn\*(Aqt an
160 // endpoint yet\&. The delimiter at the end of a route is optional and has no effect\&.
161 ret = ztrie_insert_route (self, "/foo/", NULL, NULL);
162 assert (ret == 0);
163
164 // If you try to insert a route which already exists the method will return \-1\&.
165 ret = ztrie_insert_route (self, "/foo", NULL, NULL);
166 assert (ret == \-1);
167
168 // It is not allowed to insert routes with empty tokens\&.
169 ret = ztrie_insert_route (self, "//foo", NULL, NULL);
170 assert (ret == \-1);
171
172 // Everything before the first delimiter is ignored so \*(Aqfoo/bar/baz\*(Aq is equivalent
173 // to \*(Aq/bar/baz\*(Aq\&.
174 ret = ztrie_insert_route (self, "foo/bar/baz", NULL, NULL);
175 assert (ret == 0);
176 ret = ztrie_insert_route (self, "/bar/baz", NULL, NULL);
177 assert (ret == \-1);
178
179 // Of course you are allowed to remove routes, in case there is data associated with a
180 // route and a destroy data function has been supplied that data will be destroyed\&.
181 ret = ztrie_remove_route (self, "/foo");
182 assert (ret == 0);
183
184 // Removing a non existent route will as well return \-1\&.
185 ret = ztrie_remove_route (self, "/foo");
186 assert (ret == \-1);
187
188 // Removing a route with a regular expression must exactly match the entered one\&.
189 ret = ztrie_remove_route (self, "/foo/{[^/]+}");
190 assert (ret == 0);
191
192 // Next we like to match a path by regular expressions and also extract matched
193 // parts of a route\&. This can be done by naming the regular expression\&. The name of a
194 // regular expression is entered at the beginning of the curly brackets and separated
195 // by a colon from the regular expression\&. The first one in this examples is named
196 // \*(Aqname\*(Aq and names the expression \*(Aq[^/]\*(Aq\&. If there is no capturing group defined in
197 // the expression the whole matched string will be associated with this parameter\&. In
198 // case you don\*(Aqt like the get the whole matched string use a capturing group, like
199 // it has been done for the \*(Aqid\*(Aq parameter\&. This is nice but you can even match as
200 // many parameter for a token as you like\&. Therefore simply put the parameter names
201 // separated by colons in front of the regular expression and make sure to add a
202 // capturing group for each parameter\&. The first parameter will be associated with
203 // the first capturing and so on\&.
204 char *data = (char *) malloc (80);
205 sprintf (data, "%s", "Hello World!");
206 ret = ztrie_insert_route (self, "/baz/{name:[^/]+}/{id:\-\-(\e\ed+)}/{street:nr:(\e\ea+)(\e\ed+)}", data, NULL);
207 assert (ret == 0);
208
209 // There is a lot you can do with regular expression but matching routes
210 // of arbitrary length wont work\&. Therefore we make use of the asterisk
211 // operator\&. Just place it at the end of your route, e\&.g\&. \*(Aq/config/bar/*\*(Aq\&.
212 ret = ztrie_insert_route (self, "/config/bar/*", NULL, NULL);
213 assert (ret == 0);
214
215 // Appending to an asterisk as you would to with a regular expression
216 // isn\*(Aqt valid\&.
217 ret = ztrie_insert_route (self, "/config/bar/*/bar", NULL, NULL);
218 assert (ret == \-1);
219
220 // The asterisk operator will only work as a leaf in the tree\&. If you
221 // enter an asterisk in the middle of your route it will simply be
222 // interpreted as a string\&.
223 ret = ztrie_insert_route (self, "/test/*/bar", NULL, NULL);
224 assert (ret == 0);
225
226 // If a parent has an asterisk as child it is not allowed to have
227 // other siblings\&.
228 ret = ztrie_insert_route (self, "/config/bar/foo/glup", NULL, NULL);
229 assert (ret != 0);
230
231 // Test matches
232 bool hasMatch = false;
233
234 // The route \*(Aq/bar/foo\*(Aq will fail to match as this route has never been inserted\&.
235 hasMatch = ztrie_matches (self, "/bar/foo");
236 assert (!hasMatch);
237
238 // The route \*(Aq/foo/bar\*(Aq will match and we can obtain the data associated with it\&.
239 hasMatch = ztrie_matches (self, "/foo/bar");
240 assert (hasMatch);
241 int foo_bar_hit_data = *((int *) ztrie_hit_data (self));
242 assert (foo_bar_data == foo_bar_hit_data);
243
244 // This route is part of another but is no endpoint itself thus the matches will fail\&.
245 hasMatch = ztrie_matches (self, "/baz/blub");
246 assert (!hasMatch);
247
248 // This route will match our named regular expressions route\&. Thus we can extract data
249 // from the route by their names\&.
250 hasMatch = ztrie_matches (self, "/baz/blub/\-\-11/abc23");
251 assert (hasMatch);
252 char *match_data = (char *) ztrie_hit_data (self);
253 assert (streq ("Hello World!", match_data));
254 zhashx_t *parameters = ztrie_hit_parameters (self);
255 assert (zhashx_size (parameters) == 4);
256 assert (streq ("blub", (char *) zhashx_lookup (parameters, "name")));
257 assert (streq ("11", (char *) zhashx_lookup (parameters, "id")));
258 assert (streq ("abc", (char *) zhashx_lookup (parameters, "street")));
259 assert (streq ("23", (char *) zhashx_lookup (parameters, "nr")));
260 zhashx_destroy (&parameters);
261
262 // This will match our asterisk route \*(Aq/config/bar/*\*(Aq\&. As the result we
263 // can obtain the asterisk matched part of the route\&.
264 hasMatch = ztrie_matches (self, "/config/bar/foo/bar");
265 assert (hasMatch);
266 assert (streq (ztrie_hit_asterisk_match (self), "foo/bar"));
267
268 zstr_free (&data);
269 ztrie_destroy (&self);
270 .fi
271 .if n \{\
272 .RE
273 .\}
274 .sp
275 .SH "AUTHORS"
276 .sp
277 The czmq manual was written by the authors in the AUTHORS file\&.
278 .SH "RESOURCES"
279 .sp
280 Main web site: \m[blue]\fB\%\fR\m[]
281 .sp
282 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
283 .SH "COPYRIGHT"
284 .sp
285 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
286 .SH "NOTES"
287 .IP " 1." 4
288 zeromq-dev@lists.zeromq.org
289 .RS 4
290 \%mailto:zeromq-dev@lists.zeromq.org
291 .RE
8080 ztrie_test (bool verbose);
8181
8282 #endif // CZMQ_BUILD_DRAFT_API
83 Please add '@interface' section in './../src/ztrie.c'.
8384 ----
8485
8586 DESCRIPTION
0 '\" t
1 .\" Title: zuuid
2 .\" Author: [see the "AUTHORS" section]
3 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
4 .\" Date: 12/31/2016
5 .\" Manual: CZMQ Manual
6 .\" Source: CZMQ 4.0.2
7 .\" Language: English
8 .\"
9 .TH "ZUUID" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
10 .\" -----------------------------------------------------------------
11 .\" * Define some portability stuff
12 .\" -----------------------------------------------------------------
13 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 .\" http://bugs.debian.org/507673
15 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .ie \n(.g .ds Aq \(aq
18 .el .ds Aq '
19 .\" -----------------------------------------------------------------
20 .\" * set default formatting
21 .\" -----------------------------------------------------------------
22 .\" disable hyphenation
23 .nh
24 .\" disable justification (adjust text to left margin only)
25 .ad l
26 .\" -----------------------------------------------------------------
27 .\" * MAIN CONTENT STARTS HERE *
28 .\" -----------------------------------------------------------------
29 .SH "NAME"
30 zuuid \- UUID support class
31 .SH "SYNOPSIS"
32 .sp
33 .nf
34 // This is a stable class, and may not change except for emergencies\&. It
35 // is provided in stable builds\&.
36 // Create a new UUID object\&.
37 CZMQ_EXPORT zuuid_t *
38 zuuid_new (void);
39
40 // Create UUID object from supplied ZUUID_LEN\-octet value\&.
41 CZMQ_EXPORT zuuid_t *
42 zuuid_new_from (const byte *source);
43
44 // Destroy a specified UUID object\&.
45 CZMQ_EXPORT void
46 zuuid_destroy (zuuid_t **self_p);
47
48 // Set UUID to new supplied ZUUID_LEN\-octet value\&.
49 CZMQ_EXPORT void
50 zuuid_set (zuuid_t *self, const byte *source);
51
52 // Set UUID to new supplied string value skipping \*(Aq\-\*(Aq and \*(Aq{\*(Aq \*(Aq}\*(Aq
53 // optional delimiters\&. Return 0 if OK, else returns \-1\&.
54 CZMQ_EXPORT int
55 zuuid_set_str (zuuid_t *self, const char *source);
56
57 // Return UUID binary data\&.
58 CZMQ_EXPORT const byte *
59 zuuid_data (zuuid_t *self);
60
61 // Return UUID binary size
62 CZMQ_EXPORT size_t
63 zuuid_size (zuuid_t *self);
64
65 // Returns UUID as string
66 CZMQ_EXPORT const char *
67 zuuid_str (zuuid_t *self);
68
69 // Return UUID in the canonical string format: 8\-4\-4\-4\-12, in lower
70 // case\&. Caller does not modify or free returned value\&. See
71 // http://en\&.wikipedia\&.org/wiki/Universally_unique_identifier
72 CZMQ_EXPORT const char *
73 zuuid_str_canonical (zuuid_t *self);
74
75 // Store UUID blob in target array
76 CZMQ_EXPORT void
77 zuuid_export (zuuid_t *self, byte *target);
78
79 // Check if UUID is same as supplied value
80 CZMQ_EXPORT bool
81 zuuid_eq (zuuid_t *self, const byte *compare);
82
83 // Check if UUID is different from supplied value
84 CZMQ_EXPORT bool
85 zuuid_neq (zuuid_t *self, const byte *compare);
86
87 // Make copy of UUID object; if uuid is null, or memory was exhausted,
88 // returns null\&.
89 CZMQ_EXPORT zuuid_t *
90 zuuid_dup (zuuid_t *self);
91
92 // Self test of this class\&.
93 CZMQ_EXPORT void
94 zuuid_test (bool verbose);
95
96 Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zuuid\&.c\*(Aq\&.
97 .fi
98 .SH "DESCRIPTION"
99 .sp
100 The zuuid class generates UUIDs and provides methods for working with them\&. If you build CZMQ with libuuid, on Unix/Linux, it will use that library\&. On Windows it will use UuidCreate()\&. Otherwise it will use a random number generator to produce convincing imitations of UUIDs\&.
101 .sp
102 Please add \fI@discuss\fR section in \fI\&./\&.\&./src/zuuid\&.c\fR\&.
103 .SH "EXAMPLE"
104 .PP
105 \fBFrom zuuid_test method\fR.
106 .sp
107 .if n \{\
108 .RS 4
109 .\}
110 .nf
111 // Simple create/destroy test
112 assert (ZUUID_LEN == 16);
113 assert (ZUUID_STR_LEN == 32);
114
115 zuuid_t *uuid = zuuid_new ();
116 assert (uuid);
117 assert (zuuid_size (uuid) == ZUUID_LEN);
118 assert (strlen (zuuid_str (uuid)) == ZUUID_STR_LEN);
119 zuuid_t *copy = zuuid_dup (uuid);
120 assert (streq (zuuid_str (uuid), zuuid_str (copy)));
121
122 // Check set/set_str/export methods
123 const char *myuuid = "8CB3E9A9649B4BEF8DE225E9C2CEBB38";
124 const char *myuuid2 = "8CB3E9A9\-649B\-4BEF\-8DE2\-25E9C2CEBB38";
125 const char *myuuid3 = "{8CB3E9A9\-649B\-4BEF\-8DE2\-25E9C2CEBB38}";
126 const char *myuuid4 = "8CB3E9A9649B4BEF8DE225E9C2CEBB3838";
127 int rc = zuuid_set_str (uuid, myuuid);
128 assert (rc == 0);
129 assert (streq (zuuid_str (uuid), myuuid));
130 rc = zuuid_set_str (uuid, myuuid2);
131 assert (rc == 0);
132 assert (streq (zuuid_str (uuid), myuuid));
133 rc = zuuid_set_str (uuid, myuuid3);
134 assert (rc == 0);
135 assert (streq (zuuid_str (uuid), myuuid));
136 rc = zuuid_set_str (uuid, myuuid4);
137 assert (rc == \-1);
138 byte copy_uuid [ZUUID_LEN];
139 zuuid_export (uuid, copy_uuid);
140 zuuid_set (uuid, copy_uuid);
141 assert (streq (zuuid_str (uuid), myuuid));
142
143 // Check the canonical string format
144 assert (streq (zuuid_str_canonical (uuid),
145 "8cb3e9a9\-649b\-4bef\-8de2\-25e9c2cebb38"));
146
147 zuuid_destroy (&uuid);
148 zuuid_destroy (&copy);
149 .fi
150 .if n \{\
151 .RE
152 .\}
153 .sp
154 .SH "AUTHORS"
155 .sp
156 The czmq manual was written by the authors in the AUTHORS file\&.
157 .SH "RESOURCES"
158 .sp
159 Main web site: \m[blue]\fB\%\fR\m[]
160 .sp
161 Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
162 .SH "COPYRIGHT"
163 .sp
164 Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
165 .SH "NOTES"
166 .IP " 1." 4
167 zeromq-dev@lists.zeromq.org
168 .RS 4
169 \%mailto:zeromq-dev@lists.zeromq.org
170 .RE
6969 CZMQ_EXPORT void
7070 zuuid_test (bool verbose);
7171
72 Please add '@interface' section in './../src/zuuid.c'.
7273 ----
7374
7475 DESCRIPTION
7980 library. On Windows it will use UuidCreate(). Otherwise it will use a
8081 random number generator to produce convincing imitations of UUIDs.
8182
82 Please add @discuss section in ../src/zuuid.c.
83 Please add '@discuss' section in './../src/zuuid.c'.
8384
8485 EXAMPLE
8586 -------
2727 // CZMQ version macros for compile-time API detection
2828 #define CZMQ_VERSION_MAJOR 4
2929 #define CZMQ_VERSION_MINOR 0
30 #define CZMQ_VERSION_PATCH 1
30 #define CZMQ_VERSION_PATCH 2
3131
3232 #define CZMQ_MAKE_VERSION(major, minor, patch) \
3333 ((major) * 10000 + (minor) * 100 + (patch))
192192 #elif (defined (sinix))
193193 # define __UTYPE_SINIX
194194 # define __UNIX__
195 #elif (defined (SOLARIS) || defined (__SRV4))
195 #elif (defined (SOLARIS) || defined (__SVR4)) || defined (SVR4)
196196 # define __UTYPE_SUNSOLARIS
197197 # define __UNIX__
198198 #elif (defined (SUNOS) || defined (SUN) || defined (sun))
420420 #define strneq(s1,s2) (strcmp ((s1), (s2)))
421421
422422 // Provide random number from 0..(num-1)
423 // Note that (at least in Solaris) while rand() returns an int limited by
424 // RAND_MAX, random() returns a 32-bit value all filled with random bits.
423425 #if (defined (__WINDOWS__)) || (defined (__UTYPE_IBMAIX)) \
424 || (defined (__UTYPE_HPUX)) || (defined (__UTYPE_SUNOS))
426 || (defined (__UTYPE_HPUX)) || (defined (__UTYPE_SUNOS)) || (defined (__UTYPE_SOLARIS))
425427 # define randof(num) (int) ((float) (num) * rand () / (RAND_MAX + 1.0))
426428 #else
427 # define randof(num) (int) ((float) (num) * random () / (RAND_MAX + 1.0))
429 # if defined(RAND_MAX)
430 # define randof(num) (int) ((float) (num) * (random () % RAND_MAX) / (RAND_MAX + 1.0))
431 # else
432 # define randof(num) (int) ((float) (num) * (uint32_t)random () / (UINT32_MAX + 1.0))
433 # endif
428434 #endif
429435
430436 // Windows MSVS doesn't have stdbool
(No changes)
(No changes)
(No changes)
(No changes)
298298 zsock_resolve (void *self);
299299
300300 // Get socket option `heartbeat_ivl`.
301 // Available from libzmq 4.2.0.
301302 // Caller owns return value and must destroy it when done.
302303 CZMQ_EXPORT int
303304 zsock_heartbeat_ivl (void *self);
304305
305306 // Set socket option `heartbeat_ivl`.
307 // Available from libzmq 4.2.0.
306308 CZMQ_EXPORT void
307309 zsock_set_heartbeat_ivl (void *self, int heartbeat_ivl);
308310
309311 // Get socket option `heartbeat_ttl`.
312 // Available from libzmq 4.2.0.
310313 // Caller owns return value and must destroy it when done.
311314 CZMQ_EXPORT int
312315 zsock_heartbeat_ttl (void *self);
313316
314317 // Set socket option `heartbeat_ttl`.
318 // Available from libzmq 4.2.0.
315319 CZMQ_EXPORT void
316320 zsock_set_heartbeat_ttl (void *self, int heartbeat_ttl);
317321
318322 // Get socket option `heartbeat_timeout`.
323 // Available from libzmq 4.2.0.
319324 // Caller owns return value and must destroy it when done.
320325 CZMQ_EXPORT int
321326 zsock_heartbeat_timeout (void *self);
322327
323328 // Set socket option `heartbeat_timeout`.
329 // Available from libzmq 4.2.0.
324330 CZMQ_EXPORT void
325331 zsock_set_heartbeat_timeout (void *self, int heartbeat_timeout);
326332
327 // Get socket option `use_fd`.
333 // Get socket option `use_fd`.
334 // Available from libzmq 4.2.0.
328335 // Caller owns return value and must destroy it when done.
329336 CZMQ_EXPORT int
330337 zsock_use_fd (void *self);
331338
332 // Set socket option `use_fd`.
339 // Set socket option `use_fd`.
340 // Available from libzmq 4.2.0.
333341 CZMQ_EXPORT void
334342 zsock_set_use_fd (void *self, int use_fd);
335343
336344 // Set socket option `xpub_manual`.
345 // Available from libzmq 4.2.0.
337346 CZMQ_EXPORT void
338347 zsock_set_xpub_manual (void *self, int xpub_manual);
339348
340349 // Set socket option `xpub_welcome_msg`.
350 // Available from libzmq 4.2.0.
341351 CZMQ_EXPORT void
342352 zsock_set_xpub_welcome_msg (void *self, const char *xpub_welcome_msg);
343353
344354 // Set socket option `stream_notify`.
355 // Available from libzmq 4.2.0.
345356 CZMQ_EXPORT void
346357 zsock_set_stream_notify (void *self, int stream_notify);
347358
348359 // Get socket option `invert_matching`.
360 // Available from libzmq 4.2.0.
349361 // Caller owns return value and must destroy it when done.
350362 CZMQ_EXPORT int
351363 zsock_invert_matching (void *self);
352364
353365 // Set socket option `invert_matching`.
366 // Available from libzmq 4.2.0.
354367 CZMQ_EXPORT void
355368 zsock_set_invert_matching (void *self, int invert_matching);
356369
357370 // Set socket option `xpub_verboser`.
371 // Available from libzmq 4.2.0.
358372 CZMQ_EXPORT void
359373 zsock_set_xpub_verboser (void *self, int xpub_verboser);
360374
361375 // Get socket option `connect_timeout`.
376 // Available from libzmq 4.2.0.
362377 // Caller owns return value and must destroy it when done.
363378 CZMQ_EXPORT int
364379 zsock_connect_timeout (void *self);
365380
366381 // Set socket option `connect_timeout`.
382 // Available from libzmq 4.2.0.
367383 CZMQ_EXPORT void
368384 zsock_set_connect_timeout (void *self, int connect_timeout);
369385
370386 // Get socket option `tcp_maxrt`.
387 // Available from libzmq 4.2.0.
371388 // Caller owns return value and must destroy it when done.
372389 CZMQ_EXPORT int
373390 zsock_tcp_maxrt (void *self);
374391
375392 // Set socket option `tcp_maxrt`.
393 // Available from libzmq 4.2.0.
376394 CZMQ_EXPORT void
377395 zsock_set_tcp_maxrt (void *self, int tcp_maxrt);
378396
379397 // Get socket option `thread_safe`.
398 // Available from libzmq 4.2.0.
380399 // Caller owns return value and must destroy it when done.
381400 CZMQ_EXPORT int
382401 zsock_thread_safe (void *self);
383402
384403 // Get socket option `multicast_maxtpdu`.
404 // Available from libzmq 4.2.0.
385405 // Caller owns return value and must destroy it when done.
386406 CZMQ_EXPORT int
387407 zsock_multicast_maxtpdu (void *self);
388408
389409 // Set socket option `multicast_maxtpdu`.
410 // Available from libzmq 4.2.0.
390411 CZMQ_EXPORT void
391412 zsock_set_multicast_maxtpdu (void *self, int multicast_maxtpdu);
392413
393414 // Get socket option `vmci_buffer_size`.
415 // Available from libzmq 4.2.0.
394416 // Caller owns return value and must destroy it when done.
395417 CZMQ_EXPORT int
396418 zsock_vmci_buffer_size (void *self);
397419
398420 // Set socket option `vmci_buffer_size`.
421 // Available from libzmq 4.2.0.
399422 CZMQ_EXPORT void
400423 zsock_set_vmci_buffer_size (void *self, int vmci_buffer_size);
401424
402425 // Get socket option `vmci_buffer_min_size`.
426 // Available from libzmq 4.2.0.
403427 // Caller owns return value and must destroy it when done.
404428 CZMQ_EXPORT int
405429 zsock_vmci_buffer_min_size (void *self);
406430
407431 // Set socket option `vmci_buffer_min_size`.
432 // Available from libzmq 4.2.0.
408433 CZMQ_EXPORT void
409434 zsock_set_vmci_buffer_min_size (void *self, int vmci_buffer_min_size);
410435
411436 // Get socket option `vmci_buffer_max_size`.
437 // Available from libzmq 4.2.0.
412438 // Caller owns return value and must destroy it when done.
413439 CZMQ_EXPORT int
414440 zsock_vmci_buffer_max_size (void *self);
415441
416442 // Set socket option `vmci_buffer_max_size`.
443 // Available from libzmq 4.2.0.
417444 CZMQ_EXPORT void
418445 zsock_set_vmci_buffer_max_size (void *self, int vmci_buffer_max_size);
419446
420447 // Get socket option `vmci_connect_timeout`.
448 // Available from libzmq 4.2.0.
421449 // Caller owns return value and must destroy it when done.
422450 CZMQ_EXPORT int
423451 zsock_vmci_connect_timeout (void *self);
424452
425453 // Set socket option `vmci_connect_timeout`.
454 // Available from libzmq 4.2.0.
426455 CZMQ_EXPORT void
427456 zsock_set_vmci_connect_timeout (void *self, int vmci_connect_timeout);
428457
429 // Get socket option `tos`.
458 // Get socket option `tos`.
459 // Available from libzmq 4.1.0.
430460 // Caller owns return value and must destroy it when done.
431461 CZMQ_EXPORT int
432462 zsock_tos (void *self);
433463
434 // Set socket option `tos`.
464 // Set socket option `tos`.
465 // Available from libzmq 4.1.0.
435466 CZMQ_EXPORT void
436467 zsock_set_tos (void *self, int tos);
437468
438469 // Set socket option `router_handover`.
470 // Available from libzmq 4.1.0.
439471 CZMQ_EXPORT void
440472 zsock_set_router_handover (void *self, int router_handover);
441473
442474 // Set socket option `connect_rid`.
475 // Available from libzmq 4.1.0.
443476 CZMQ_EXPORT void
444477 zsock_set_connect_rid (void *self, const char *connect_rid);
445478
446479 // Set socket option `connect_rid` from 32-octet binary
480 // Available from libzmq 4.1.0.
447481 CZMQ_EXPORT void
448482 zsock_set_connect_rid_bin (void *self, const byte *connect_rid);
449483
450484 // Get socket option `handshake_ivl`.
485 // Available from libzmq 4.1.0.
451486 // Caller owns return value and must destroy it when done.
452487 CZMQ_EXPORT int
453488 zsock_handshake_ivl (void *self);
454489
455490 // Set socket option `handshake_ivl`.
491 // Available from libzmq 4.1.0.
456492 CZMQ_EXPORT void
457493 zsock_set_handshake_ivl (void *self, int handshake_ivl);
458494
459495 // Get socket option `socks_proxy`.
496 // Available from libzmq 4.1.0.
460497 // Caller owns return value and must destroy it when done.
461498 CZMQ_EXPORT char *
462499 zsock_socks_proxy (void *self);
463500
464501 // Set socket option `socks_proxy`.
502 // Available from libzmq 4.1.0.
465503 CZMQ_EXPORT void
466504 zsock_set_socks_proxy (void *self, const char *socks_proxy);
467505
468506 // Set socket option `xpub_nodrop`.
507 // Available from libzmq 4.1.0.
469508 CZMQ_EXPORT void
470509 zsock_set_xpub_nodrop (void *self, int xpub_nodrop);
471510
472511 // Set socket option `router_mandatory`.
512 // Available from libzmq 4.0.0.
473513 CZMQ_EXPORT void
474514 zsock_set_router_mandatory (void *self, int router_mandatory);
475515
476516 // Set socket option `probe_router`.
517 // Available from libzmq 4.0.0.
477518 CZMQ_EXPORT void
478519 zsock_set_probe_router (void *self, int probe_router);
479520
480521 // Set socket option `req_relaxed`.
522 // Available from libzmq 4.0.0.
481523 CZMQ_EXPORT void
482524 zsock_set_req_relaxed (void *self, int req_relaxed);
483525
484526 // Set socket option `req_correlate`.
527 // Available from libzmq 4.0.0.
485528 CZMQ_EXPORT void
486529 zsock_set_req_correlate (void *self, int req_correlate);
487530
488531 // Set socket option `conflate`.
532 // Available from libzmq 4.0.0.
489533 CZMQ_EXPORT void
490534 zsock_set_conflate (void *self, int conflate);
491535
492536 // Get socket option `zap_domain`.
537 // Available from libzmq 4.0.0.
493538 // Caller owns return value and must destroy it when done.
494539 CZMQ_EXPORT char *
495540 zsock_zap_domain (void *self);
496541
497542 // Set socket option `zap_domain`.
543 // Available from libzmq 4.0.0.
498544 CZMQ_EXPORT void
499545 zsock_set_zap_domain (void *self, const char *zap_domain);
500546
501547 // Get socket option `mechanism`.
548 // Available from libzmq 4.0.0.
502549 // Caller owns return value and must destroy it when done.
503550 CZMQ_EXPORT int
504551 zsock_mechanism (void *self);
505552
506553 // Get socket option `plain_server`.
554 // Available from libzmq 4.0.0.
507555 // Caller owns return value and must destroy it when done.
508556 CZMQ_EXPORT int
509557 zsock_plain_server (void *self);
510558
511559 // Set socket option `plain_server`.
560 // Available from libzmq 4.0.0.
512561 CZMQ_EXPORT void
513562 zsock_set_plain_server (void *self, int plain_server);
514563
515564 // Get socket option `plain_username`.
565 // Available from libzmq 4.0.0.
516566 // Caller owns return value and must destroy it when done.
517567 CZMQ_EXPORT char *
518568 zsock_plain_username (void *self);
519569
520570 // Set socket option `plain_username`.
571 // Available from libzmq 4.0.0.
521572 CZMQ_EXPORT void
522573 zsock_set_plain_username (void *self, const char *plain_username);
523574
524575 // Get socket option `plain_password`.
576 // Available from libzmq 4.0.0.
525577 // Caller owns return value and must destroy it when done.
526578 CZMQ_EXPORT char *
527579 zsock_plain_password (void *self);
528580
529581 // Set socket option `plain_password`.
582 // Available from libzmq 4.0.0.
530583 CZMQ_EXPORT void
531584 zsock_set_plain_password (void *self, const char *plain_password);
532585
533586 // Get socket option `curve_server`.
587 // Available from libzmq 4.0.0.
534588 // Caller owns return value and must destroy it when done.
535589 CZMQ_EXPORT int
536590 zsock_curve_server (void *self);
537591
538592 // Set socket option `curve_server`.
593 // Available from libzmq 4.0.0.
539594 CZMQ_EXPORT void
540595 zsock_set_curve_server (void *self, int curve_server);
541596
542597 // Get socket option `curve_publickey`.
598 // Available from libzmq 4.0.0.
543599 // Caller owns return value and must destroy it when done.
544600 CZMQ_EXPORT char *
545601 zsock_curve_publickey (void *self);
546602
547603 // Set socket option `curve_publickey`.
604 // Available from libzmq 4.0.0.
548605 CZMQ_EXPORT void
549606 zsock_set_curve_publickey (void *self, const char *curve_publickey);
550607
551608 // Set socket option `curve_publickey` from 32-octet binary
609 // Available from libzmq 4.0.0.
552610 CZMQ_EXPORT void
553611 zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey);
554612
555613 // Get socket option `curve_secretkey`.
614 // Available from libzmq 4.0.0.
556615 // Caller owns return value and must destroy it when done.
557616 CZMQ_EXPORT char *
558617 zsock_curve_secretkey (void *self);
559618
560619 // Set socket option `curve_secretkey`.
620 // Available from libzmq 4.0.0.
561621 CZMQ_EXPORT void
562622 zsock_set_curve_secretkey (void *self, const char *curve_secretkey);
563623
564624 // Set socket option `curve_secretkey` from 32-octet binary
625 // Available from libzmq 4.0.0.
565626 CZMQ_EXPORT void
566627 zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey);
567628
568629 // Get socket option `curve_serverkey`.
630 // Available from libzmq 4.0.0.
569631 // Caller owns return value and must destroy it when done.
570632 CZMQ_EXPORT char *
571633 zsock_curve_serverkey (void *self);
572634
573635 // Set socket option `curve_serverkey`.
636 // Available from libzmq 4.0.0.
574637 CZMQ_EXPORT void
575638 zsock_set_curve_serverkey (void *self, const char *curve_serverkey);
576639
577640 // Set socket option `curve_serverkey` from 32-octet binary
641 // Available from libzmq 4.0.0.
578642 CZMQ_EXPORT void
579643 zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey);
580644
581645 // Get socket option `gssapi_server`.
646 // Available from libzmq 4.0.0.
582647 // Caller owns return value and must destroy it when done.
583648 CZMQ_EXPORT int
584649 zsock_gssapi_server (void *self);
585650
586651 // Set socket option `gssapi_server`.
652 // Available from libzmq 4.0.0.
587653 CZMQ_EXPORT void
588654 zsock_set_gssapi_server (void *self, int gssapi_server);
589655
590656 // Get socket option `gssapi_plaintext`.
657 // Available from libzmq 4.0.0.
591658 // Caller owns return value and must destroy it when done.
592659 CZMQ_EXPORT int
593660 zsock_gssapi_plaintext (void *self);
594661
595662 // Set socket option `gssapi_plaintext`.
663 // Available from libzmq 4.0.0.
596664 CZMQ_EXPORT void
597665 zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext);
598666
599667 // Get socket option `gssapi_principal`.
668 // Available from libzmq 4.0.0.
600669 // Caller owns return value and must destroy it when done.
601670 CZMQ_EXPORT char *
602671 zsock_gssapi_principal (void *self);
603672
604673 // Set socket option `gssapi_principal`.
674 // Available from libzmq 4.0.0.
605675 CZMQ_EXPORT void
606676 zsock_set_gssapi_principal (void *self, const char *gssapi_principal);
607677
608678 // Get socket option `gssapi_service_principal`.
679 // Available from libzmq 4.0.0.
609680 // Caller owns return value and must destroy it when done.
610681 CZMQ_EXPORT char *
611682 zsock_gssapi_service_principal (void *self);
612683
613684 // Set socket option `gssapi_service_principal`.
685 // Available from libzmq 4.0.0.
614686 CZMQ_EXPORT void
615687 zsock_set_gssapi_service_principal (void *self, const char *gssapi_service_principal);
616688
617 // Get socket option `ipv6`.
689 // Get socket option `ipv6`.
690 // Available from libzmq 4.0.0.
618691 // Caller owns return value and must destroy it when done.
619692 CZMQ_EXPORT int
620693 zsock_ipv6 (void *self);
621694
622 // Set socket option `ipv6`.
695 // Set socket option `ipv6`.
696 // Available from libzmq 4.0.0.
623697 CZMQ_EXPORT void
624698 zsock_set_ipv6 (void *self, int ipv6);
625699
626700 // Get socket option `immediate`.
701 // Available from libzmq 4.0.0.
627702 // Caller owns return value and must destroy it when done.
628703 CZMQ_EXPORT int
629704 zsock_immediate (void *self);
630705
631706 // Set socket option `immediate`.
707 // Available from libzmq 4.0.0.
632708 CZMQ_EXPORT void
633709 zsock_set_immediate (void *self, int immediate);
634710
635 // Set socket option `router_raw`.
636 CZMQ_EXPORT void
637 zsock_set_router_raw (void *self, int router_raw);
638
639 // Get socket option `ipv4only`.
640 // Caller owns return value and must destroy it when done.
641 CZMQ_EXPORT int
642 zsock_ipv4only (void *self);
643
644 // Set socket option `ipv4only`.
645 CZMQ_EXPORT void
646 zsock_set_ipv4only (void *self, int ipv4only);
647
648 // Set socket option `delay_attach_on_connect`.
649 CZMQ_EXPORT void
650 zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect);
651
652 // Get socket option `type`.
711 // Get socket option `type`.
712 // Available from libzmq 3.0.0.
653713 // Caller owns return value and must destroy it when done.
654714 CZMQ_EXPORT int
655715 zsock_type (void *self);
656716
657 // Get socket option `sndhwm`.
717 // Get socket option `sndhwm`.
718 // Available from libzmq 3.0.0.
658719 // Caller owns return value and must destroy it when done.
659720 CZMQ_EXPORT int
660721 zsock_sndhwm (void *self);
661722
662 // Set socket option `sndhwm`.
723 // Set socket option `sndhwm`.
724 // Available from libzmq 3.0.0.
663725 CZMQ_EXPORT void
664726 zsock_set_sndhwm (void *self, int sndhwm);
665727
666 // Get socket option `rcvhwm`.
728 // Get socket option `rcvhwm`.
729 // Available from libzmq 3.0.0.
667730 // Caller owns return value and must destroy it when done.
668731 CZMQ_EXPORT int
669732 zsock_rcvhwm (void *self);
670733
671 // Set socket option `rcvhwm`.
734 // Set socket option `rcvhwm`.
735 // Available from libzmq 3.0.0.
672736 CZMQ_EXPORT void
673737 zsock_set_rcvhwm (void *self, int rcvhwm);
674738
675739 // Get socket option `affinity`.
740 // Available from libzmq 3.0.0.
676741 // Caller owns return value and must destroy it when done.
677742 CZMQ_EXPORT int
678743 zsock_affinity (void *self);
679744
680745 // Set socket option `affinity`.
746 // Available from libzmq 3.0.0.
681747 CZMQ_EXPORT void
682748 zsock_set_affinity (void *self, int affinity);
683749
684750 // Set socket option `subscribe`.
751 // Available from libzmq 3.0.0.
685752 CZMQ_EXPORT void
686753 zsock_set_subscribe (void *self, const char *subscribe);
687754
688755 // Set socket option `unsubscribe`.
756 // Available from libzmq 3.0.0.
689757 CZMQ_EXPORT void
690758 zsock_set_unsubscribe (void *self, const char *unsubscribe);
691759
692760 // Get socket option `identity`.
761 // Available from libzmq 3.0.0.
693762 // Caller owns return value and must destroy it when done.
694763 CZMQ_EXPORT char *
695764 zsock_identity (void *self);
696765
697766 // Set socket option `identity`.
767 // Available from libzmq 3.0.0.
698768 CZMQ_EXPORT void
699769 zsock_set_identity (void *self, const char *identity);
700770
701 // Get socket option `rate`.
771 // Get socket option `rate`.
772 // Available from libzmq 3.0.0.
702773 // Caller owns return value and must destroy it when done.
703774 CZMQ_EXPORT int
704775 zsock_rate (void *self);
705776
706 // Set socket option `rate`.
777 // Set socket option `rate`.
778 // Available from libzmq 3.0.0.
707779 CZMQ_EXPORT void
708780 zsock_set_rate (void *self, int rate);
709781
710782 // Get socket option `recovery_ivl`.
783 // Available from libzmq 3.0.0.
711784 // Caller owns return value and must destroy it when done.
712785 CZMQ_EXPORT int
713786 zsock_recovery_ivl (void *self);
714787
715788 // Set socket option `recovery_ivl`.
789 // Available from libzmq 3.0.0.
716790 CZMQ_EXPORT void
717791 zsock_set_recovery_ivl (void *self, int recovery_ivl);
718792
719 // Get socket option `sndbuf`.
793 // Get socket option `sndbuf`.
794 // Available from libzmq 3.0.0.
720795 // Caller owns return value and must destroy it when done.
721796 CZMQ_EXPORT int
722797 zsock_sndbuf (void *self);
723798
724 // Set socket option `sndbuf`.
799 // Set socket option `sndbuf`.
800 // Available from libzmq 3.0.0.
725801 CZMQ_EXPORT void
726802 zsock_set_sndbuf (void *self, int sndbuf);
727803
728 // Get socket option `rcvbuf`.
804 // Get socket option `rcvbuf`.
805 // Available from libzmq 3.0.0.
729806 // Caller owns return value and must destroy it when done.
730807 CZMQ_EXPORT int
731808 zsock_rcvbuf (void *self);
732809
733 // Set socket option `rcvbuf`.
810 // Set socket option `rcvbuf`.
811 // Available from libzmq 3.0.0.
734812 CZMQ_EXPORT void
735813 zsock_set_rcvbuf (void *self, int rcvbuf);
736814
737 // Get socket option `linger`.
815 // Get socket option `linger`.
816 // Available from libzmq 3.0.0.
738817 // Caller owns return value and must destroy it when done.
739818 CZMQ_EXPORT int
740819 zsock_linger (void *self);
741820
742 // Set socket option `linger`.
821 // Set socket option `linger`.
822 // Available from libzmq 3.0.0.
743823 CZMQ_EXPORT void
744824 zsock_set_linger (void *self, int linger);
745825
746826 // Get socket option `reconnect_ivl`.
827 // Available from libzmq 3.0.0.
747828 // Caller owns return value and must destroy it when done.
748829 CZMQ_EXPORT int
749830 zsock_reconnect_ivl (void *self);
750831
751832 // Set socket option `reconnect_ivl`.
833 // Available from libzmq 3.0.0.
752834 CZMQ_EXPORT void
753835 zsock_set_reconnect_ivl (void *self, int reconnect_ivl);
754836
755837 // Get socket option `reconnect_ivl_max`.
838 // Available from libzmq 3.0.0.
756839 // Caller owns return value and must destroy it when done.
757840 CZMQ_EXPORT int
758841 zsock_reconnect_ivl_max (void *self);
759842
760843 // Set socket option `reconnect_ivl_max`.
844 // Available from libzmq 3.0.0.
761845 CZMQ_EXPORT void
762846 zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max);
763847
764848 // Get socket option `backlog`.
849 // Available from libzmq 3.0.0.
765850 // Caller owns return value and must destroy it when done.
766851 CZMQ_EXPORT int
767852 zsock_backlog (void *self);
768853
769854 // Set socket option `backlog`.
855 // Available from libzmq 3.0.0.
770856 CZMQ_EXPORT void
771857 zsock_set_backlog (void *self, int backlog);
772858
773859 // Get socket option `maxmsgsize`.
860 // Available from libzmq 3.0.0.
774861 // Caller owns return value and must destroy it when done.
775862 CZMQ_EXPORT int
776863 zsock_maxmsgsize (void *self);
777864
778865 // Set socket option `maxmsgsize`.
866 // Available from libzmq 3.0.0.
779867 CZMQ_EXPORT void
780868 zsock_set_maxmsgsize (void *self, int maxmsgsize);
781869
782870 // Get socket option `multicast_hops`.
871 // Available from libzmq 3.0.0.
783872 // Caller owns return value and must destroy it when done.
784873 CZMQ_EXPORT int
785874 zsock_multicast_hops (void *self);
786875
787876 // Set socket option `multicast_hops`.
877 // Available from libzmq 3.0.0.
788878 CZMQ_EXPORT void
789879 zsock_set_multicast_hops (void *self, int multicast_hops);
790880
791881 // Get socket option `rcvtimeo`.
882 // Available from libzmq 3.0.0.
792883 // Caller owns return value and must destroy it when done.
793884 CZMQ_EXPORT int
794885 zsock_rcvtimeo (void *self);
795886
796887 // Set socket option `rcvtimeo`.
888 // Available from libzmq 3.0.0.
797889 CZMQ_EXPORT void
798890 zsock_set_rcvtimeo (void *self, int rcvtimeo);
799891
800892 // Get socket option `sndtimeo`.
893 // Available from libzmq 3.0.0.
801894 // Caller owns return value and must destroy it when done.
802895 CZMQ_EXPORT int
803896 zsock_sndtimeo (void *self);
804897
805898 // Set socket option `sndtimeo`.
899 // Available from libzmq 3.0.0.
806900 CZMQ_EXPORT void
807901 zsock_set_sndtimeo (void *self, int sndtimeo);
808902
809903 // Set socket option `xpub_verbose`.
904 // Available from libzmq 3.0.0.
810905 CZMQ_EXPORT void
811906 zsock_set_xpub_verbose (void *self, int xpub_verbose);
812907
813908 // Get socket option `tcp_keepalive`.
909 // Available from libzmq 3.0.0.
814910 // Caller owns return value and must destroy it when done.
815911 CZMQ_EXPORT int
816912 zsock_tcp_keepalive (void *self);
817913
818914 // Set socket option `tcp_keepalive`.
915 // Available from libzmq 3.0.0.
819916 CZMQ_EXPORT void
820917 zsock_set_tcp_keepalive (void *self, int tcp_keepalive);
821918
822919 // Get socket option `tcp_keepalive_idle`.
920 // Available from libzmq 3.0.0.
823921 // Caller owns return value and must destroy it when done.
824922 CZMQ_EXPORT int
825923 zsock_tcp_keepalive_idle (void *self);
826924
827925 // Set socket option `tcp_keepalive_idle`.
926 // Available from libzmq 3.0.0.
828927 CZMQ_EXPORT void
829928 zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle);
830929
831930 // Get socket option `tcp_keepalive_cnt`.
931 // Available from libzmq 3.0.0.
832932 // Caller owns return value and must destroy it when done.
833933 CZMQ_EXPORT int
834934 zsock_tcp_keepalive_cnt (void *self);
835935
836936 // Set socket option `tcp_keepalive_cnt`.
937 // Available from libzmq 3.0.0.
837938 CZMQ_EXPORT void
838939 zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt);
839940
840941 // Get socket option `tcp_keepalive_intvl`.
942 // Available from libzmq 3.0.0.
841943 // Caller owns return value and must destroy it when done.
842944 CZMQ_EXPORT int
843945 zsock_tcp_keepalive_intvl (void *self);
844946
845947 // Set socket option `tcp_keepalive_intvl`.
948 // Available from libzmq 3.0.0.
846949 CZMQ_EXPORT void
847950 zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl);
848951
849952 // Get socket option `tcp_accept_filter`.
953 // Available from libzmq 3.0.0.
850954 // Caller owns return value and must destroy it when done.
851955 CZMQ_EXPORT char *
852956 zsock_tcp_accept_filter (void *self);
853957
854958 // Set socket option `tcp_accept_filter`.
959 // Available from libzmq 3.0.0.
855960 CZMQ_EXPORT void
856961 zsock_set_tcp_accept_filter (void *self, const char *tcp_accept_filter);
857962
858963 // Get socket option `rcvmore`.
964 // Available from libzmq 3.0.0.
859965 // Caller owns return value and must destroy it when done.
860966 CZMQ_EXPORT int
861967 zsock_rcvmore (void *self);
862968
863 // Get socket option `fd`.
969 // Get socket option `fd`.
970 // Available from libzmq 3.0.0.
864971 // Caller owns return value and must destroy it when done.
865972 CZMQ_EXPORT SOCKET
866973 zsock_fd (void *self);
867974
868 // Get socket option `events`.
975 // Get socket option `events`.
976 // Available from libzmq 3.0.0.
869977 // Caller owns return value and must destroy it when done.
870978 CZMQ_EXPORT int
871979 zsock_events (void *self);
872980
873981 // Get socket option `last_endpoint`.
982 // Available from libzmq 3.0.0.
874983 // Caller owns return value and must destroy it when done.
875984 CZMQ_EXPORT char *
876985 zsock_last_endpoint (void *self);
986
987 // Set socket option `router_raw`.
988 // Available from libzmq 3.0.0.
989 CZMQ_EXPORT void
990 zsock_set_router_raw (void *self, int router_raw);
991
992 // Get socket option `ipv4only`.
993 // Available from libzmq 3.0.0.
994 // Caller owns return value and must destroy it when done.
995 CZMQ_EXPORT int
996 zsock_ipv4only (void *self);
997
998 // Set socket option `ipv4only`.
999 // Available from libzmq 3.0.0.
1000 CZMQ_EXPORT void
1001 zsock_set_ipv4only (void *self, int ipv4only);
1002
1003 // Set socket option `delay_attach_on_connect`.
1004 // Available from libzmq 3.0.0.
1005 CZMQ_EXPORT void
1006 zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect);
8771007
8781008 // Self test of this class.
8791009 CZMQ_EXPORT void
0 # pthread requires special checks and flags to be added
1 find_package(Threads)
2 if(THREADS_HAVE_PTHREAD_ARG)
3 target_compile_options(PUBLIC czmq "-pthread")
4 endif()
5 if(CMAKE_THREAD_LIBS_INIT)
6 target_link_libraries(czmq "${CMAKE_THREAD_LIBS_INIT}")
7 endif()
8
9 # at least C99 is required for zdir which uses ‘for’ loop initial declarations
10 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
11
8080 src/zauth.c \
8181 src/zbeacon.c \
8282 src/zgossip.c \
83 src/zgossip_engine.inc \
8384 src/zmonitor.c \
8485 src/zproxy.c \
8586 src/zrex.c \
(No changes)
173173 #define PACKAGE_NAME "czmq"
174174
175175 /* Define to the full name and version of this package. */
176 #define PACKAGE_STRING "czmq 4.0.1"
176 #define PACKAGE_STRING "czmq 4.0.2"
177177
178178 /* Define to the one symbol short name of this package. */
179179 #define PACKAGE_TARNAME "czmq"
182182 #define PACKAGE_URL ""
183183
184184 /* Define to the version of this package. */
185 #define PACKAGE_VERSION "4.0.1"
185 #define PACKAGE_VERSION "4.0.2"
186186
187187 /* CZMQ major version */
188188 #define PACKAGE_VERSION_MAJOR 4
191191 #define PACKAGE_VERSION_MINOR 0
192192
193193 /* CZMQ patchlevel */
194 #define PACKAGE_VERSION_PATCH 1
194 #define PACKAGE_VERSION_PATCH 2
195195
196196 /* Define as the return type of signal handlers (`int' or `void'). */
197197 #define RETSIGTYPE void
203203 #define TIME_WITH_SYS_TIME 1
204204
205205 /* Version number of package */
206 #define VERSION "4.0.1"
206 #define VERSION "4.0.2"
207207
208208 /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
209209 significant byte first (like Motorola and SPARC, unlike Intel). */
273273 assert (msg);
274274 zmsg_addstr (msg, peername);
275275 zmsg_append (msg, &frame);
276 zmsg_send (&msg, self->pipe);
276 if (zmsg_send (&msg, self->pipe) < 0)
277 zmsg_destroy (&msg);
277278 }
278279 else
279280 zframe_destroy (&frame);
905905 srandom ((unsigned) time (NULL));
906906 for (iteration = 0; iteration < 25000; iteration++) {
907907 testnbr = randof (testmax);
908 assert (testnbr != testmax);
909 assert (testnbr < testmax);
908910 if (testset [testnbr].exists) {
909911 item = (char *) zhash_lookup (hash, testset [testnbr].name);
910912 assert (item);
4747 size_t cache_size; // Current size of cache
4848 uint32_t routing_id; // Routing ID for server sockets
4949 };
50
51 #ifndef CZMQ_BUILD_DRAFT_API
52 CZMQ_PRIVATE zsock_t *
53 zsock_new_server_checked (const char *endpoint, const char *filename, size_t line_nbr);
54
55 CZMQ_PRIVATE zsock_t *
56 zsock_new_client_checked (const char *endpoint, const char *filename, size_t line_nbr);
57
58 CZMQ_PRIVATE zsock_t *
59 zsock_new_radio_checked (const char *endpoint, const char *filename, size_t line_nbr);
60
61 CZMQ_PRIVATE zsock_t *
62 zsock_new_dish_checked (const char *endpoint, const char *filename, size_t line_nbr);
63
64 CZMQ_PRIVATE zsock_t *
65 zsock_new_gather_checked (const char *endpoint, const char *filename, size_t line_nbr);
66
67 CZMQ_PRIVATE zsock_t *
68 zsock_new_scatter_checked (const char *endpoint, const char *filename, size_t line_nbr);
69 #endif // CZMQ_BUILD_DRAFT_API
5070
5171
5272 // --------------------------------------------------------------------------
16491669 {
16501670 assert (self);
16511671 zmsg_t *msg = zmsg_new_signal (status);
1652 return zmsg_send (&msg, self);
1672 if (zmsg_send (&msg, self) < 0) {
1673 zmsg_destroy (&msg);
1674 return -1;
1675 }
1676 else
1677 return 0;
16531678 }
16541679
16551680
19051930 // Test zsock_send/recv pictures
19061931 uint8_t number1 = 123;
19071932 uint16_t number2 = 123 * 123;
1908 uint32_t number4 = 123 * 123 * 123;
1909 uint64_t number4_MAX = UINT32_MAX;
1910 uint64_t number8 = 123 * 123 * 123 * 123;
1933 uint32_t number4 = 123 * 123;
1934 number4 *= 123;
1935 uint32_t number4_MAX = UINT32_MAX;
1936 uint64_t number8 = 123 * 123;
1937 number8 *= 123;
1938 number8 *= 123;
19111939 uint64_t number8_MAX = UINT64_MAX;
19121940
19131941 zchunk_t *chunk = zchunk_new ("HELLO", 5);
19401968 byte *data;
19411969 size_t size;
19421970 char *pointer;
1943 number8_MAX = number8 = number4 = number2 = number1 = 0;
1971 number8_MAX = number8 = number4_MAX = number4 = number2 = number1 = 0ULL;
19441972 rc = zsock_recv (reader, "i124488zsbcfUhp",
19451973 &integer, &number1, &number2, &number4, &number4_MAX,
19461974 &number8, &number8_MAX, &string, &data, &size, &chunk,
1818 =========================================================================
1919 */
2020
21 #if (ZMQ_VERSION_MAJOR == 4)
21 #if (ZMQ_VERSION_MAJOR >= 4)
22 # if (ZMQ_VERSION_MINOR >= 2)
2223 // --------------------------------------------------------------------------
2324 // Set socket ZMQ_HEARTBEAT_IVL value
2425 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2829 {
2930 assert (self);
3031 # if defined (ZMQ_HEARTBEAT_IVL)
32 int major, minor, patch;
33 zmq_version (&major, &minor, &patch);
34 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
35 zsys_error ("zsock heartbeat_ivl option not supported by libzmq version %d.%d.%d, "
36 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
37 return;
38 }
3139 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_HEARTBEAT_IVL, &heartbeat_ivl, sizeof (int));
3240 assert (rc == 0 || zmq_errno () == ETERM);
3341 # endif
4351 {
4452 assert (self);
4553 # if defined (ZMQ_HEARTBEAT_IVL)
54 int major, minor, patch;
55 zmq_version (&major, &minor, &patch);
56 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
57 zsys_error ("zsock heartbeat_ivl option not supported by libzmq version %d.%d.%d, "
58 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
59 return 0;
60 }
4661 int heartbeat_ivl;
4762 size_t option_len = sizeof (int);
4863 zmq_getsockopt (zsock_resolve (self), ZMQ_HEARTBEAT_IVL, &heartbeat_ivl, &option_len);
6176 {
6277 assert (self);
6378 # if defined (ZMQ_HEARTBEAT_TTL)
79 int major, minor, patch;
80 zmq_version (&major, &minor, &patch);
81 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
82 zsys_error ("zsock heartbeat_ttl option not supported by libzmq version %d.%d.%d, "
83 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
84 return;
85 }
6486 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_HEARTBEAT_TTL, &heartbeat_ttl, sizeof (int));
6587 assert (rc == 0 || zmq_errno () == ETERM);
6688 # endif
7698 {
7799 assert (self);
78100 # if defined (ZMQ_HEARTBEAT_TTL)
101 int major, minor, patch;
102 zmq_version (&major, &minor, &patch);
103 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
104 zsys_error ("zsock heartbeat_ttl option not supported by libzmq version %d.%d.%d, "
105 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
106 return 0;
107 }
79108 int heartbeat_ttl;
80109 size_t option_len = sizeof (int);
81110 zmq_getsockopt (zsock_resolve (self), ZMQ_HEARTBEAT_TTL, &heartbeat_ttl, &option_len);
94123 {
95124 assert (self);
96125 # if defined (ZMQ_HEARTBEAT_TIMEOUT)
126 int major, minor, patch;
127 zmq_version (&major, &minor, &patch);
128 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
129 zsys_error ("zsock heartbeat_timeout option not supported by libzmq version %d.%d.%d, "
130 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
131 return;
132 }
97133 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_HEARTBEAT_TIMEOUT, &heartbeat_timeout, sizeof (int));
98134 assert (rc == 0 || zmq_errno () == ETERM);
99135 # endif
109145 {
110146 assert (self);
111147 # if defined (ZMQ_HEARTBEAT_TIMEOUT)
148 int major, minor, patch;
149 zmq_version (&major, &minor, &patch);
150 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
151 zsys_error ("zsock heartbeat_timeout option not supported by libzmq version %d.%d.%d, "
152 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
153 return 0;
154 }
112155 int heartbeat_timeout;
113156 size_t option_len = sizeof (int);
114157 zmq_getsockopt (zsock_resolve (self), ZMQ_HEARTBEAT_TIMEOUT, &heartbeat_timeout, &option_len);
127170 {
128171 assert (self);
129172 # if defined (ZMQ_USE_FD)
173 int major, minor, patch;
174 zmq_version (&major, &minor, &patch);
175 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
176 zsys_error ("zsock use_fd option not supported by libzmq version %d.%d.%d, "
177 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
178 return;
179 }
130180 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_USE_FD, &use_fd, sizeof (int));
131181 assert (rc == 0 || zmq_errno () == ETERM);
132182 # endif
142192 {
143193 assert (self);
144194 # if defined (ZMQ_USE_FD)
195 int major, minor, patch;
196 zmq_version (&major, &minor, &patch);
197 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
198 zsys_error ("zsock use_fd option not supported by libzmq version %d.%d.%d, "
199 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
200 return 0;
201 }
145202 int use_fd;
146203 size_t option_len = sizeof (int);
147204 zmq_getsockopt (zsock_resolve (self), ZMQ_USE_FD, &use_fd, &option_len);
160217 {
161218 assert (self);
162219 # if defined (ZMQ_XPUB_MANUAL)
220 int major, minor, patch;
221 zmq_version (&major, &minor, &patch);
222 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
223 zsys_error ("zsock xpub_manual option not supported by libzmq version %d.%d.%d, "
224 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
225 return;
226 }
163227 if (zsock_type (self) != ZMQ_XPUB) {
164228 printf ("ZMQ_XPUB_MANUAL is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
165229 assert (false);
179243 {
180244 assert (self);
181245 # if defined (ZMQ_XPUB_WELCOME_MSG)
246 int major, minor, patch;
247 zmq_version (&major, &minor, &patch);
248 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
249 zsys_error ("zsock xpub_welcome_msg option not supported by libzmq version %d.%d.%d, "
250 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
251 return;
252 }
182253 if (zsock_type (self) != ZMQ_XPUB) {
183254 printf ("ZMQ_XPUB_WELCOME_MSG is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
184255 assert (false);
198269 {
199270 assert (self);
200271 # if defined (ZMQ_STREAM_NOTIFY)
272 int major, minor, patch;
273 zmq_version (&major, &minor, &patch);
274 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
275 zsys_error ("zsock stream_notify option not supported by libzmq version %d.%d.%d, "
276 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
277 return;
278 }
201279 if (zsock_type (self) != ZMQ_STREAM) {
202280 printf ("ZMQ_STREAM_NOTIFY is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
203281 assert (false);
217295 {
218296 assert (self);
219297 # if defined (ZMQ_INVERT_MATCHING)
298 int major, minor, patch;
299 zmq_version (&major, &minor, &patch);
300 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
301 zsys_error ("zsock invert_matching option not supported by libzmq version %d.%d.%d, "
302 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
303 return;
304 }
220305 if (zsock_type (self) != ZMQ_XPUB
221306 && zsock_type (self) != ZMQ_PUB
222307 && zsock_type (self) != ZMQ_SUB) {
238323 {
239324 assert (self);
240325 # if defined (ZMQ_INVERT_MATCHING)
326 int major, minor, patch;
327 zmq_version (&major, &minor, &patch);
328 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
329 zsys_error ("zsock invert_matching option not supported by libzmq version %d.%d.%d, "
330 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
331 return 0;
332 }
241333 int invert_matching;
242334 size_t option_len = sizeof (int);
243335 zmq_getsockopt (zsock_resolve (self), ZMQ_INVERT_MATCHING, &invert_matching, &option_len);
256348 {
257349 assert (self);
258350 # if defined (ZMQ_XPUB_VERBOSER)
351 int major, minor, patch;
352 zmq_version (&major, &minor, &patch);
353 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
354 zsys_error ("zsock xpub_verboser option not supported by libzmq version %d.%d.%d, "
355 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
356 return;
357 }
259358 if (zsock_type (self) != ZMQ_XPUB) {
260359 printf ("ZMQ_XPUB_VERBOSER is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
261360 assert (false);
275374 {
276375 assert (self);
277376 # if defined (ZMQ_CONNECT_TIMEOUT)
377 int major, minor, patch;
378 zmq_version (&major, &minor, &patch);
379 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
380 zsys_error ("zsock connect_timeout option not supported by libzmq version %d.%d.%d, "
381 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
382 return;
383 }
278384 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CONNECT_TIMEOUT, &connect_timeout, sizeof (int));
279385 assert (rc == 0 || zmq_errno () == ETERM);
280386 # endif
290396 {
291397 assert (self);
292398 # if defined (ZMQ_CONNECT_TIMEOUT)
399 int major, minor, patch;
400 zmq_version (&major, &minor, &patch);
401 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
402 zsys_error ("zsock connect_timeout option not supported by libzmq version %d.%d.%d, "
403 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
404 return 0;
405 }
293406 int connect_timeout;
294407 size_t option_len = sizeof (int);
295408 zmq_getsockopt (zsock_resolve (self), ZMQ_CONNECT_TIMEOUT, &connect_timeout, &option_len);
308421 {
309422 assert (self);
310423 # if defined (ZMQ_TCP_MAXRT)
424 int major, minor, patch;
425 zmq_version (&major, &minor, &patch);
426 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
427 zsys_error ("zsock tcp_maxrt option not supported by libzmq version %d.%d.%d, "
428 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
429 return;
430 }
311431 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_MAXRT, &tcp_maxrt, sizeof (int));
312432 assert (rc == 0 || zmq_errno () == ETERM);
313433 # endif
323443 {
324444 assert (self);
325445 # if defined (ZMQ_TCP_MAXRT)
446 int major, minor, patch;
447 zmq_version (&major, &minor, &patch);
448 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
449 zsys_error ("zsock tcp_maxrt option not supported by libzmq version %d.%d.%d, "
450 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
451 return 0;
452 }
326453 int tcp_maxrt;
327454 size_t option_len = sizeof (int);
328455 zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_MAXRT, &tcp_maxrt, &option_len);
341468 {
342469 assert (self);
343470 # if defined (ZMQ_THREAD_SAFE)
471 int major, minor, patch;
472 zmq_version (&major, &minor, &patch);
473 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
474 zsys_error ("zsock thread_safe option not supported by libzmq version %d.%d.%d, "
475 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
476 return 0;
477 }
344478 int thread_safe;
345479 size_t option_len = sizeof (int);
346480 zmq_getsockopt (zsock_resolve (self), ZMQ_THREAD_SAFE, &thread_safe, &option_len);
359493 {
360494 assert (self);
361495 # if defined (ZMQ_MULTICAST_MAXTPDU)
496 int major, minor, patch;
497 zmq_version (&major, &minor, &patch);
498 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
499 zsys_error ("zsock multicast_maxtpdu option not supported by libzmq version %d.%d.%d, "
500 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
501 return;
502 }
362503 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MULTICAST_MAXTPDU, &multicast_maxtpdu, sizeof (int));
363504 assert (rc == 0 || zmq_errno () == ETERM);
364505 # endif
374515 {
375516 assert (self);
376517 # if defined (ZMQ_MULTICAST_MAXTPDU)
518 int major, minor, patch;
519 zmq_version (&major, &minor, &patch);
520 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
521 zsys_error ("zsock multicast_maxtpdu option not supported by libzmq version %d.%d.%d, "
522 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
523 return 0;
524 }
377525 int multicast_maxtpdu;
378526 size_t option_len = sizeof (int);
379527 zmq_getsockopt (zsock_resolve (self), ZMQ_MULTICAST_MAXTPDU, &multicast_maxtpdu, &option_len);
392540 {
393541 assert (self);
394542 # if defined (ZMQ_VMCI_BUFFER_SIZE)
543 int major, minor, patch;
544 zmq_version (&major, &minor, &patch);
545 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
546 zsys_error ("zsock vmci_buffer_size option not supported by libzmq version %d.%d.%d, "
547 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
548 return;
549 }
395550 uint64_t value = vmci_buffer_size;
396551 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_VMCI_BUFFER_SIZE, &value, sizeof (uint64_t));
397552 assert (rc == 0 || zmq_errno () == ETERM);
408563 {
409564 assert (self);
410565 # if defined (ZMQ_VMCI_BUFFER_SIZE)
566 int major, minor, patch;
567 zmq_version (&major, &minor, &patch);
568 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
569 zsys_error ("zsock vmci_buffer_size option not supported by libzmq version %d.%d.%d, "
570 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
571 return 0;
572 }
411573 uint64_t vmci_buffer_size;
412574 size_t option_len = sizeof (uint64_t);
413575 zmq_getsockopt (zsock_resolve (self), ZMQ_VMCI_BUFFER_SIZE, &vmci_buffer_size, &option_len);
426588 {
427589 assert (self);
428590 # if defined (ZMQ_VMCI_BUFFER_MIN_SIZE)
591 int major, minor, patch;
592 zmq_version (&major, &minor, &patch);
593 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
594 zsys_error ("zsock vmci_buffer_min_size option not supported by libzmq version %d.%d.%d, "
595 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
596 return;
597 }
429598 uint64_t value = vmci_buffer_min_size;
430599 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_VMCI_BUFFER_MIN_SIZE, &value, sizeof (uint64_t));
431600 assert (rc == 0 || zmq_errno () == ETERM);
442611 {
443612 assert (self);
444613 # if defined (ZMQ_VMCI_BUFFER_MIN_SIZE)
614 int major, minor, patch;
615 zmq_version (&major, &minor, &patch);
616 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
617 zsys_error ("zsock vmci_buffer_min_size option not supported by libzmq version %d.%d.%d, "
618 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
619 return 0;
620 }
445621 uint64_t vmci_buffer_min_size;
446622 size_t option_len = sizeof (uint64_t);
447623 zmq_getsockopt (zsock_resolve (self), ZMQ_VMCI_BUFFER_MIN_SIZE, &vmci_buffer_min_size, &option_len);
460636 {
461637 assert (self);
462638 # if defined (ZMQ_VMCI_BUFFER_MAX_SIZE)
639 int major, minor, patch;
640 zmq_version (&major, &minor, &patch);
641 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
642 zsys_error ("zsock vmci_buffer_max_size option not supported by libzmq version %d.%d.%d, "
643 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
644 return;
645 }
463646 uint64_t value = vmci_buffer_max_size;
464647 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_VMCI_BUFFER_MAX_SIZE, &value, sizeof (uint64_t));
465648 assert (rc == 0 || zmq_errno () == ETERM);
476659 {
477660 assert (self);
478661 # if defined (ZMQ_VMCI_BUFFER_MAX_SIZE)
662 int major, minor, patch;
663 zmq_version (&major, &minor, &patch);
664 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
665 zsys_error ("zsock vmci_buffer_max_size option not supported by libzmq version %d.%d.%d, "
666 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
667 return 0;
668 }
479669 uint64_t vmci_buffer_max_size;
480670 size_t option_len = sizeof (uint64_t);
481671 zmq_getsockopt (zsock_resolve (self), ZMQ_VMCI_BUFFER_MAX_SIZE, &vmci_buffer_max_size, &option_len);
494684 {
495685 assert (self);
496686 # if defined (ZMQ_VMCI_CONNECT_TIMEOUT)
687 int major, minor, patch;
688 zmq_version (&major, &minor, &patch);
689 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
690 zsys_error ("zsock vmci_connect_timeout option not supported by libzmq version %d.%d.%d, "
691 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
692 return;
693 }
497694 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_VMCI_CONNECT_TIMEOUT, &vmci_connect_timeout, sizeof (int));
498695 assert (rc == 0 || zmq_errno () == ETERM);
499696 # endif
509706 {
510707 assert (self);
511708 # if defined (ZMQ_VMCI_CONNECT_TIMEOUT)
709 int major, minor, patch;
710 zmq_version (&major, &minor, &patch);
711 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) {
712 zsys_error ("zsock vmci_connect_timeout option not supported by libzmq version %d.%d.%d, "
713 "run with libzmq >= 4.2.0\n", major, minor, patch, NULL);
714 return 0;
715 }
512716 int vmci_connect_timeout;
513717 size_t option_len = sizeof (int);
514718 zmq_getsockopt (zsock_resolve (self), ZMQ_VMCI_CONNECT_TIMEOUT, &vmci_connect_timeout, &option_len);
518722 # endif
519723 }
520724
725 # endif
726 #endif
727
728 #if (ZMQ_VERSION_MAJOR >= 4)
729 # if (ZMQ_VERSION_MINOR >= 1)
521730 // --------------------------------------------------------------------------
522731 // Set socket ZMQ_TOS value
523732 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
527736 {
528737 assert (self);
529738 # if defined (ZMQ_TOS)
739 int major, minor, patch;
740 zmq_version (&major, &minor, &patch);
741 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) {
742 zsys_error ("zsock tos option not supported by libzmq version %d.%d.%d, "
743 "run with libzmq >= 4.1.0\n", major, minor, patch, NULL);
744 return;
745 }
530746 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TOS, &tos, sizeof (int));
531747 assert (rc == 0 || zmq_errno () == ETERM);
532748 # endif
542758 {
543759 assert (self);
544760 # if defined (ZMQ_TOS)
761 int major, minor, patch;
762 zmq_version (&major, &minor, &patch);
763 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) {
764 zsys_error ("zsock tos option not supported by libzmq version %d.%d.%d, "
765 "run with libzmq >= 4.1.0\n", major, minor, patch, NULL);
766 return 0;
767 }
545768 int tos;
546769 size_t option_len = sizeof (int);
547770 zmq_getsockopt (zsock_resolve (self), ZMQ_TOS, &tos, &option_len);
560783 {
561784 assert (self);
562785 # if defined (ZMQ_ROUTER_HANDOVER)
786 int major, minor, patch;
787 zmq_version (&major, &minor, &patch);
788 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) {
789 zsys_error ("zsock router_handover option not supported by libzmq version %d.%d.%d, "
790 "run with libzmq >= 4.1.0\n", major, minor, patch, NULL);
791 return;
792 }
563793 if (zsock_type (self) != ZMQ_ROUTER) {
564794 printf ("ZMQ_ROUTER_HANDOVER is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
565795 assert (false);
579809 {
580810 assert (self);
581811 # if defined (ZMQ_CONNECT_RID)
812 int major, minor, patch;
813 zmq_version (&major, &minor, &patch);
814 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) {
815 zsys_error ("zsock connect_rid option not supported by libzmq version %d.%d.%d, "
816 "run with libzmq >= 4.1.0\n", major, minor, patch, NULL);
817 return;
818 }
582819 if (zsock_type (self) != ZMQ_ROUTER
583820 && zsock_type (self) != ZMQ_STREAM) {
584821 printf ("ZMQ_CONNECT_RID is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
598835 zsock_set_connect_rid_bin (void *self, const byte *connect_rid)
599836 {
600837 # if defined (ZMQ_CONNECT_RID)
838 int major, minor, patch;
839 zmq_version (&major, &minor, &patch);
840 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) {
841 zsys_error ("zsock connect_rid option not supported by libzmq version %d.%d.%d, "
842 "run with libzmq >= 4.1.0\n", major, minor, patch, NULL);
843 return;
844 }
601845 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CONNECT_RID, connect_rid, 32);
602846 assert (rc == 0 || zmq_errno () == ETERM);
603847 # endif
613857 {
614858 assert (self);
615859 # if defined (ZMQ_HANDSHAKE_IVL)
860 int major, minor, patch;
861 zmq_version (&major, &minor, &patch);
862 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) {
863 zsys_error ("zsock handshake_ivl option not supported by libzmq version %d.%d.%d, "
864 "run with libzmq >= 4.1.0\n", major, minor, patch, NULL);
865 return;
866 }
616867 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_HANDSHAKE_IVL, &handshake_ivl, sizeof (int));
617868 assert (rc == 0 || zmq_errno () == ETERM);
618869 # endif
628879 {
629880 assert (self);
630881 # if defined (ZMQ_HANDSHAKE_IVL)
882 int major, minor, patch;
883 zmq_version (&major, &minor, &patch);
884 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) {
885 zsys_error ("zsock handshake_ivl option not supported by libzmq version %d.%d.%d, "
886 "run with libzmq >= 4.1.0\n", major, minor, patch, NULL);
887 return 0;
888 }
631889 int handshake_ivl;
632890 size_t option_len = sizeof (int);
633891 zmq_getsockopt (zsock_resolve (self), ZMQ_HANDSHAKE_IVL, &handshake_ivl, &option_len);
646904 {
647905 assert (self);
648906 # if defined (ZMQ_SOCKS_PROXY)
907 int major, minor, patch;
908 zmq_version (&major, &minor, &patch);
909 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) {
910 zsys_error ("zsock socks_proxy option not supported by libzmq version %d.%d.%d, "
911 "run with libzmq >= 4.1.0\n", major, minor, patch, NULL);
912 return;
913 }
649914 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SOCKS_PROXY, socks_proxy, strlen (socks_proxy));
650915 assert (rc == 0 || zmq_errno () == ETERM);
651916 # endif
661926 {
662927 assert (self);
663928 # if defined (ZMQ_SOCKS_PROXY)
929 int major, minor, patch;
930 zmq_version (&major, &minor, &patch);
931 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) {
932 zsys_error ("zsock socks_proxy option not supported by libzmq version %d.%d.%d, "
933 "run with libzmq >= 4.1.0\n", major, minor, patch, NULL);
934 return 0;
935 }
664936 size_t option_len = 255;
665937 char *socks_proxy = (char *) zmalloc (option_len);
666938 zmq_getsockopt (zsock_resolve (self), ZMQ_SOCKS_PROXY, socks_proxy, &option_len);
679951 {
680952 assert (self);
681953 # if defined (ZMQ_XPUB_NODROP)
954 int major, minor, patch;
955 zmq_version (&major, &minor, &patch);
956 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) {
957 zsys_error ("zsock xpub_nodrop option not supported by libzmq version %d.%d.%d, "
958 "run with libzmq >= 4.1.0\n", major, minor, patch, NULL);
959 return;
960 }
682961 if (zsock_type (self) != ZMQ_XPUB
683962 && zsock_type (self) != ZMQ_PUB) {
684963 printf ("ZMQ_XPUB_NODROP is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
690969 }
691970
692971
972 # endif
973 #endif
974
975 #if (ZMQ_VERSION_MAJOR >= 4)
693976 // --------------------------------------------------------------------------
694977 // Set socket ZMQ_ROUTER_MANDATORY value
695978 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
699982 {
700983 assert (self);
701984 # if defined (ZMQ_ROUTER_MANDATORY)
985 int major, minor, patch;
986 zmq_version (&major, &minor, &patch);
987 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
988 zsys_error ("zsock router_mandatory option not supported by libzmq version %d.%d.%d, "
989 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
990 return;
991 }
702992 if (zsock_type (self) != ZMQ_ROUTER) {
703993 printf ("ZMQ_ROUTER_MANDATORY is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
704994 assert (false);
7181008 {
7191009 assert (self);
7201010 # if defined (ZMQ_PROBE_ROUTER)
1011 int major, minor, patch;
1012 zmq_version (&major, &minor, &patch);
1013 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1014 zsys_error ("zsock probe_router option not supported by libzmq version %d.%d.%d, "
1015 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1016 return;
1017 }
7211018 if (zsock_type (self) != ZMQ_ROUTER
7221019 && zsock_type (self) != ZMQ_DEALER
7231020 && zsock_type (self) != ZMQ_REQ) {
7391036 {
7401037 assert (self);
7411038 # if defined (ZMQ_REQ_RELAXED)
1039 int major, minor, patch;
1040 zmq_version (&major, &minor, &patch);
1041 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1042 zsys_error ("zsock req_relaxed option not supported by libzmq version %d.%d.%d, "
1043 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1044 return;
1045 }
7421046 if (zsock_type (self) != ZMQ_REQ) {
7431047 printf ("ZMQ_REQ_RELAXED is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
7441048 assert (false);
7581062 {
7591063 assert (self);
7601064 # if defined (ZMQ_REQ_CORRELATE)
1065 int major, minor, patch;
1066 zmq_version (&major, &minor, &patch);
1067 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1068 zsys_error ("zsock req_correlate option not supported by libzmq version %d.%d.%d, "
1069 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1070 return;
1071 }
7611072 if (zsock_type (self) != ZMQ_REQ) {
7621073 printf ("ZMQ_REQ_CORRELATE is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
7631074 assert (false);
7771088 {
7781089 assert (self);
7791090 # if defined (ZMQ_CONFLATE)
1091 int major, minor, patch;
1092 zmq_version (&major, &minor, &patch);
1093 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1094 zsys_error ("zsock conflate option not supported by libzmq version %d.%d.%d, "
1095 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1096 return;
1097 }
7801098 if (zsock_type (self) != ZMQ_PUSH
7811099 && zsock_type (self) != ZMQ_PULL
7821100 && zsock_type (self) != ZMQ_PUB
8001118 {
8011119 assert (self);
8021120 # if defined (ZMQ_ZAP_DOMAIN)
1121 int major, minor, patch;
1122 zmq_version (&major, &minor, &patch);
1123 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1124 zsys_error ("zsock zap_domain option not supported by libzmq version %d.%d.%d, "
1125 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1126 return;
1127 }
8031128 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_ZAP_DOMAIN, zap_domain, strlen (zap_domain));
8041129 assert (rc == 0 || zmq_errno () == ETERM);
8051130 # endif
8151140 {
8161141 assert (self);
8171142 # if defined (ZMQ_ZAP_DOMAIN)
1143 int major, minor, patch;
1144 zmq_version (&major, &minor, &patch);
1145 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1146 zsys_error ("zsock zap_domain option not supported by libzmq version %d.%d.%d, "
1147 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1148 return 0;
1149 }
8181150 size_t option_len = 255;
8191151 char *zap_domain = (char *) zmalloc (option_len);
8201152 zmq_getsockopt (zsock_resolve (self), ZMQ_ZAP_DOMAIN, zap_domain, &option_len);
8331165 {
8341166 assert (self);
8351167 # if defined (ZMQ_MECHANISM)
1168 int major, minor, patch;
1169 zmq_version (&major, &minor, &patch);
1170 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1171 zsys_error ("zsock mechanism option not supported by libzmq version %d.%d.%d, "
1172 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1173 return 0;
1174 }
8361175 int mechanism;
8371176 size_t option_len = sizeof (int);
8381177 zmq_getsockopt (zsock_resolve (self), ZMQ_MECHANISM, &mechanism, &option_len);
8511190 {
8521191 assert (self);
8531192 # if defined (ZMQ_PLAIN_SERVER)
1193 int major, minor, patch;
1194 zmq_version (&major, &minor, &patch);
1195 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1196 zsys_error ("zsock plain_server option not supported by libzmq version %d.%d.%d, "
1197 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1198 return;
1199 }
8541200 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_PLAIN_SERVER, &plain_server, sizeof (int));
8551201 assert (rc == 0 || zmq_errno () == ETERM);
8561202 # endif
8661212 {
8671213 assert (self);
8681214 # if defined (ZMQ_PLAIN_SERVER)
1215 int major, minor, patch;
1216 zmq_version (&major, &minor, &patch);
1217 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1218 zsys_error ("zsock plain_server option not supported by libzmq version %d.%d.%d, "
1219 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1220 return 0;
1221 }
8691222 int plain_server;
8701223 size_t option_len = sizeof (int);
8711224 zmq_getsockopt (zsock_resolve (self), ZMQ_PLAIN_SERVER, &plain_server, &option_len);
8841237 {
8851238 assert (self);
8861239 # if defined (ZMQ_PLAIN_USERNAME)
1240 int major, minor, patch;
1241 zmq_version (&major, &minor, &patch);
1242 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1243 zsys_error ("zsock plain_username option not supported by libzmq version %d.%d.%d, "
1244 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1245 return;
1246 }
8871247 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_PLAIN_USERNAME, plain_username, strlen (plain_username));
8881248 assert (rc == 0 || zmq_errno () == ETERM);
8891249 # endif
8991259 {
9001260 assert (self);
9011261 # if defined (ZMQ_PLAIN_USERNAME)
1262 int major, minor, patch;
1263 zmq_version (&major, &minor, &patch);
1264 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1265 zsys_error ("zsock plain_username option not supported by libzmq version %d.%d.%d, "
1266 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1267 return 0;
1268 }
9021269 size_t option_len = 255;
9031270 char *plain_username = (char *) zmalloc (option_len);
9041271 zmq_getsockopt (zsock_resolve (self), ZMQ_PLAIN_USERNAME, plain_username, &option_len);
9171284 {
9181285 assert (self);
9191286 # if defined (ZMQ_PLAIN_PASSWORD)
1287 int major, minor, patch;
1288 zmq_version (&major, &minor, &patch);
1289 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1290 zsys_error ("zsock plain_password option not supported by libzmq version %d.%d.%d, "
1291 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1292 return;
1293 }
9201294 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_PLAIN_PASSWORD, plain_password, strlen (plain_password));
9211295 assert (rc == 0 || zmq_errno () == ETERM);
9221296 # endif
9321306 {
9331307 assert (self);
9341308 # if defined (ZMQ_PLAIN_PASSWORD)
1309 int major, minor, patch;
1310 zmq_version (&major, &minor, &patch);
1311 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1312 zsys_error ("zsock plain_password option not supported by libzmq version %d.%d.%d, "
1313 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1314 return 0;
1315 }
9351316 size_t option_len = 255;
9361317 char *plain_password = (char *) zmalloc (option_len);
9371318 zmq_getsockopt (zsock_resolve (self), ZMQ_PLAIN_PASSWORD, plain_password, &option_len);
9501331 {
9511332 assert (self);
9521333 # if defined (ZMQ_CURVE_SERVER)
1334 int major, minor, patch;
1335 zmq_version (&major, &minor, &patch);
1336 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1337 zsys_error ("zsock curve_server option not supported by libzmq version %d.%d.%d, "
1338 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1339 return;
1340 }
9531341 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_SERVER, &curve_server, sizeof (int));
9541342 assert (rc == 0 || zmq_errno () == ETERM);
9551343 # endif
9651353 {
9661354 assert (self);
9671355 # if defined (ZMQ_CURVE_SERVER)
1356 int major, minor, patch;
1357 zmq_version (&major, &minor, &patch);
1358 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1359 zsys_error ("zsock curve_server option not supported by libzmq version %d.%d.%d, "
1360 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1361 return 0;
1362 }
9681363 int curve_server;
9691364 size_t option_len = sizeof (int);
9701365 zmq_getsockopt (zsock_resolve (self), ZMQ_CURVE_SERVER, &curve_server, &option_len);
9831378 {
9841379 assert (self);
9851380 # if defined (ZMQ_CURVE_PUBLICKEY)
1381 int major, minor, patch;
1382 zmq_version (&major, &minor, &patch);
1383 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1384 zsys_error ("zsock curve_publickey option not supported by libzmq version %d.%d.%d, "
1385 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1386 return;
1387 }
9861388 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_PUBLICKEY, curve_publickey, strlen (curve_publickey));
9871389 assert (rc == 0 || zmq_errno () == ETERM);
9881390 # endif
9971399 zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey)
9981400 {
9991401 # if defined (ZMQ_CURVE_PUBLICKEY)
1402 int major, minor, patch;
1403 zmq_version (&major, &minor, &patch);
1404 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1405 zsys_error ("zsock curve_publickey option not supported by libzmq version %d.%d.%d, "
1406 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1407 return;
1408 }
10001409 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_PUBLICKEY, curve_publickey, 32);
10011410 assert (rc == 0 || zmq_errno () == ETERM);
10021411 # endif
10121421 {
10131422 assert (self);
10141423 # if defined (ZMQ_CURVE_PUBLICKEY)
1424 int major, minor, patch;
1425 zmq_version (&major, &minor, &patch);
1426 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1427 zsys_error ("zsock curve_publickey option not supported by libzmq version %d.%d.%d, "
1428 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1429 return 0;
1430 }
10151431 size_t option_len = 40 + 1; // Z85 key + terminator
10161432 char *curve_publickey = (char *) zmalloc (option_len);
10171433 zmq_getsockopt (zsock_resolve (self), ZMQ_CURVE_PUBLICKEY, curve_publickey, &option_len);
10301446 {
10311447 assert (self);
10321448 # if defined (ZMQ_CURVE_SECRETKEY)
1449 int major, minor, patch;
1450 zmq_version (&major, &minor, &patch);
1451 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1452 zsys_error ("zsock curve_secretkey option not supported by libzmq version %d.%d.%d, "
1453 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1454 return;
1455 }
10331456 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_SECRETKEY, curve_secretkey, strlen (curve_secretkey));
10341457 assert (rc == 0 || zmq_errno () == ETERM);
10351458 # endif
10441467 zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey)
10451468 {
10461469 # if defined (ZMQ_CURVE_SECRETKEY)
1470 int major, minor, patch;
1471 zmq_version (&major, &minor, &patch);
1472 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1473 zsys_error ("zsock curve_secretkey option not supported by libzmq version %d.%d.%d, "
1474 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1475 return;
1476 }
10471477 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_SECRETKEY, curve_secretkey, 32);
10481478 assert (rc == 0 || zmq_errno () == ETERM);
10491479 # endif
10591489 {
10601490 assert (self);
10611491 # if defined (ZMQ_CURVE_SECRETKEY)
1492 int major, minor, patch;
1493 zmq_version (&major, &minor, &patch);
1494 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1495 zsys_error ("zsock curve_secretkey option not supported by libzmq version %d.%d.%d, "
1496 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1497 return 0;
1498 }
10621499 size_t option_len = 40 + 1; // Z85 key + terminator
10631500 char *curve_secretkey = (char *) zmalloc (option_len);
10641501 zmq_getsockopt (zsock_resolve (self), ZMQ_CURVE_SECRETKEY, curve_secretkey, &option_len);
10771514 {
10781515 assert (self);
10791516 # if defined (ZMQ_CURVE_SERVERKEY)
1517 int major, minor, patch;
1518 zmq_version (&major, &minor, &patch);
1519 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1520 zsys_error ("zsock curve_serverkey option not supported by libzmq version %d.%d.%d, "
1521 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1522 return;
1523 }
10801524 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_SERVERKEY, curve_serverkey, strlen (curve_serverkey));
10811525 assert (rc == 0 || zmq_errno () == ETERM);
10821526 # endif
10911535 zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey)
10921536 {
10931537 # if defined (ZMQ_CURVE_SERVERKEY)
1538 int major, minor, patch;
1539 zmq_version (&major, &minor, &patch);
1540 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1541 zsys_error ("zsock curve_serverkey option not supported by libzmq version %d.%d.%d, "
1542 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1543 return;
1544 }
10941545 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_SERVERKEY, curve_serverkey, 32);
10951546 assert (rc == 0 || zmq_errno () == ETERM);
10961547 # endif
11061557 {
11071558 assert (self);
11081559 # if defined (ZMQ_CURVE_SERVERKEY)
1560 int major, minor, patch;
1561 zmq_version (&major, &minor, &patch);
1562 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1563 zsys_error ("zsock curve_serverkey option not supported by libzmq version %d.%d.%d, "
1564 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1565 return 0;
1566 }
11091567 size_t option_len = 40 + 1; // Z85 key + terminator
11101568 char *curve_serverkey = (char *) zmalloc (option_len);
11111569 zmq_getsockopt (zsock_resolve (self), ZMQ_CURVE_SERVERKEY, curve_serverkey, &option_len);
11241582 {
11251583 assert (self);
11261584 # if defined (ZMQ_GSSAPI_SERVER)
1585 int major, minor, patch;
1586 zmq_version (&major, &minor, &patch);
1587 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1588 zsys_error ("zsock gssapi_server option not supported by libzmq version %d.%d.%d, "
1589 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1590 return;
1591 }
11271592 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_GSSAPI_SERVER, &gssapi_server, sizeof (int));
11281593 assert (rc == 0 || zmq_errno () == ETERM);
11291594 # endif
11391604 {
11401605 assert (self);
11411606 # if defined (ZMQ_GSSAPI_SERVER)
1607 int major, minor, patch;
1608 zmq_version (&major, &minor, &patch);
1609 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1610 zsys_error ("zsock gssapi_server option not supported by libzmq version %d.%d.%d, "
1611 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1612 return 0;
1613 }
11421614 int gssapi_server;
11431615 size_t option_len = sizeof (int);
11441616 zmq_getsockopt (zsock_resolve (self), ZMQ_GSSAPI_SERVER, &gssapi_server, &option_len);
11571629 {
11581630 assert (self);
11591631 # if defined (ZMQ_GSSAPI_PLAINTEXT)
1632 int major, minor, patch;
1633 zmq_version (&major, &minor, &patch);
1634 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1635 zsys_error ("zsock gssapi_plaintext option not supported by libzmq version %d.%d.%d, "
1636 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1637 return;
1638 }
11601639 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_GSSAPI_PLAINTEXT, &gssapi_plaintext, sizeof (int));
11611640 assert (rc == 0 || zmq_errno () == ETERM);
11621641 # endif
11721651 {
11731652 assert (self);
11741653 # if defined (ZMQ_GSSAPI_PLAINTEXT)
1654 int major, minor, patch;
1655 zmq_version (&major, &minor, &patch);
1656 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1657 zsys_error ("zsock gssapi_plaintext option not supported by libzmq version %d.%d.%d, "
1658 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1659 return 0;
1660 }
11751661 int gssapi_plaintext;
11761662 size_t option_len = sizeof (int);
11771663 zmq_getsockopt (zsock_resolve (self), ZMQ_GSSAPI_PLAINTEXT, &gssapi_plaintext, &option_len);
11901676 {
11911677 assert (self);
11921678 # if defined (ZMQ_GSSAPI_PRINCIPAL)
1679 int major, minor, patch;
1680 zmq_version (&major, &minor, &patch);
1681 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1682 zsys_error ("zsock gssapi_principal option not supported by libzmq version %d.%d.%d, "
1683 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1684 return;
1685 }
11931686 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_GSSAPI_PRINCIPAL, gssapi_principal, strlen (gssapi_principal));
11941687 assert (rc == 0 || zmq_errno () == ETERM);
11951688 # endif
12051698 {
12061699 assert (self);
12071700 # if defined (ZMQ_GSSAPI_PRINCIPAL)
1701 int major, minor, patch;
1702 zmq_version (&major, &minor, &patch);
1703 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1704 zsys_error ("zsock gssapi_principal option not supported by libzmq version %d.%d.%d, "
1705 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1706 return 0;
1707 }
12081708 size_t option_len = 255;
12091709 char *gssapi_principal = (char *) zmalloc (option_len);
12101710 zmq_getsockopt (zsock_resolve (self), ZMQ_GSSAPI_PRINCIPAL, gssapi_principal, &option_len);
12231723 {
12241724 assert (self);
12251725 # if defined (ZMQ_GSSAPI_SERVICE_PRINCIPAL)
1726 int major, minor, patch;
1727 zmq_version (&major, &minor, &patch);
1728 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1729 zsys_error ("zsock gssapi_service_principal option not supported by libzmq version %d.%d.%d, "
1730 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1731 return;
1732 }
12261733 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_GSSAPI_SERVICE_PRINCIPAL, gssapi_service_principal, strlen (gssapi_service_principal));
12271734 assert (rc == 0 || zmq_errno () == ETERM);
12281735 # endif
12381745 {
12391746 assert (self);
12401747 # if defined (ZMQ_GSSAPI_SERVICE_PRINCIPAL)
1748 int major, minor, patch;
1749 zmq_version (&major, &minor, &patch);
1750 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1751 zsys_error ("zsock gssapi_service_principal option not supported by libzmq version %d.%d.%d, "
1752 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1753 return 0;
1754 }
12411755 size_t option_len = 255;
12421756 char *gssapi_service_principal = (char *) zmalloc (option_len);
12431757 zmq_getsockopt (zsock_resolve (self), ZMQ_GSSAPI_SERVICE_PRINCIPAL, gssapi_service_principal, &option_len);
12561770 {
12571771 assert (self);
12581772 # if defined (ZMQ_IPV6)
1773 int major, minor, patch;
1774 zmq_version (&major, &minor, &patch);
1775 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1776 zsys_error ("zsock ipv6 option not supported by libzmq version %d.%d.%d, "
1777 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1778 return;
1779 }
12591780 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IPV6, &ipv6, sizeof (int));
12601781 assert (rc == 0 || zmq_errno () == ETERM);
12611782 # endif
12711792 {
12721793 assert (self);
12731794 # if defined (ZMQ_IPV6)
1795 int major, minor, patch;
1796 zmq_version (&major, &minor, &patch);
1797 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1798 zsys_error ("zsock ipv6 option not supported by libzmq version %d.%d.%d, "
1799 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1800 return 0;
1801 }
12741802 int ipv6;
12751803 size_t option_len = sizeof (int);
12761804 zmq_getsockopt (zsock_resolve (self), ZMQ_IPV6, &ipv6, &option_len);
12891817 {
12901818 assert (self);
12911819 # if defined (ZMQ_IMMEDIATE)
1820 int major, minor, patch;
1821 zmq_version (&major, &minor, &patch);
1822 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1823 zsys_error ("zsock immediate option not supported by libzmq version %d.%d.%d, "
1824 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1825 return;
1826 }
12921827 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IMMEDIATE, &immediate, sizeof (int));
12931828 assert (rc == 0 || zmq_errno () == ETERM);
12941829 # endif
13041839 {
13051840 assert (self);
13061841 # if defined (ZMQ_IMMEDIATE)
1842 int major, minor, patch;
1843 zmq_version (&major, &minor, &patch);
1844 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) {
1845 zsys_error ("zsock immediate option not supported by libzmq version %d.%d.%d, "
1846 "run with libzmq >= 4.0.0\n", major, minor, patch, NULL);
1847 return 0;
1848 }
13071849 int immediate;
13081850 size_t option_len = sizeof (int);
13091851 zmq_getsockopt (zsock_resolve (self), ZMQ_IMMEDIATE, &immediate, &option_len);
13131855 # endif
13141856 }
13151857
1316 // --------------------------------------------------------------------------
1317 // Set socket ZMQ_ROUTER_RAW value
1318 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
1319
1320 void
1321 zsock_set_router_raw (void *self, int router_raw)
1322 {
1323 assert (self);
1324 # if defined (ZMQ_ROUTER_RAW)
1325 if (zsock_type (self) != ZMQ_ROUTER) {
1326 printf ("ZMQ_ROUTER_RAW is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
1327 assert (false);
1328 }
1329 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_ROUTER_RAW, &router_raw, sizeof (int));
1330 assert (rc == 0 || zmq_errno () == ETERM);
1331 # endif
1332 }
1333
1334
1335 // --------------------------------------------------------------------------
1336 // Set socket ZMQ_IPV4ONLY value
1337 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
1338
1339 void
1340 zsock_set_ipv4only (void *self, int ipv4only)
1341 {
1342 assert (self);
1343 # if defined (ZMQ_IPV4ONLY)
1344 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IPV4ONLY, &ipv4only, sizeof (int));
1345 assert (rc == 0 || zmq_errno () == ETERM);
1346 # endif
1347 }
1348
1349
1350 // --------------------------------------------------------------------------
1351 // Return socket ZMQ_IPV4ONLY value
1352 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
1353
1354 int
1355 zsock_ipv4only (void *self)
1356 {
1357 assert (self);
1358 # if defined (ZMQ_IPV4ONLY)
1359 int ipv4only;
1360 size_t option_len = sizeof (int);
1361 zmq_getsockopt (zsock_resolve (self), ZMQ_IPV4ONLY, &ipv4only, &option_len);
1362 return ipv4only;
1363 # else
1364 return 0;
1365 # endif
1366 }
1367
1368 // --------------------------------------------------------------------------
1369 // Set socket ZMQ_DELAY_ATTACH_ON_CONNECT value
1370 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
1371
1372 void
1373 zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect)
1374 {
1375 assert (self);
1376 # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT)
1377 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_DELAY_ATTACH_ON_CONNECT, &delay_attach_on_connect, sizeof (int));
1378 assert (rc == 0 || zmq_errno () == ETERM);
1379 # endif
1380 }
1381
1382
1858 #endif
1859
1860 #if (ZMQ_VERSION_MAJOR >= 3)
13831861 // --------------------------------------------------------------------------
13841862 // Return socket ZMQ_TYPE value
13851863 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
13891867 {
13901868 assert (self);
13911869 # if defined (ZMQ_TYPE)
1870 int major, minor, patch;
1871 zmq_version (&major, &minor, &patch);
1872 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
1873 zsys_error ("zsock type option not supported by libzmq version %d.%d.%d, "
1874 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
1875 return 0;
1876 }
13921877 int type;
13931878 size_t option_len = sizeof (int);
13941879 zmq_getsockopt (zsock_resolve (self), ZMQ_TYPE, &type, &option_len);
14071892 {
14081893 assert (self);
14091894 # if defined (ZMQ_SNDHWM)
1895 int major, minor, patch;
1896 zmq_version (&major, &minor, &patch);
1897 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
1898 zsys_error ("zsock sndhwm option not supported by libzmq version %d.%d.%d, "
1899 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
1900 return;
1901 }
14101902 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDHWM, &sndhwm, sizeof (int));
14111903 assert (rc == 0 || zmq_errno () == ETERM);
14121904 # endif
14221914 {
14231915 assert (self);
14241916 # if defined (ZMQ_SNDHWM)
1917 int major, minor, patch;
1918 zmq_version (&major, &minor, &patch);
1919 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
1920 zsys_error ("zsock sndhwm option not supported by libzmq version %d.%d.%d, "
1921 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
1922 return 0;
1923 }
14251924 int sndhwm;
14261925 size_t option_len = sizeof (int);
14271926 zmq_getsockopt (zsock_resolve (self), ZMQ_SNDHWM, &sndhwm, &option_len);
14401939 {
14411940 assert (self);
14421941 # if defined (ZMQ_RCVHWM)
1942 int major, minor, patch;
1943 zmq_version (&major, &minor, &patch);
1944 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
1945 zsys_error ("zsock rcvhwm option not supported by libzmq version %d.%d.%d, "
1946 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
1947 return;
1948 }
14431949 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVHWM, &rcvhwm, sizeof (int));
14441950 assert (rc == 0 || zmq_errno () == ETERM);
14451951 # endif
14551961 {
14561962 assert (self);
14571963 # if defined (ZMQ_RCVHWM)
1964 int major, minor, patch;
1965 zmq_version (&major, &minor, &patch);
1966 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
1967 zsys_error ("zsock rcvhwm option not supported by libzmq version %d.%d.%d, "
1968 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
1969 return 0;
1970 }
14581971 int rcvhwm;
14591972 size_t option_len = sizeof (int);
14601973 zmq_getsockopt (zsock_resolve (self), ZMQ_RCVHWM, &rcvhwm, &option_len);
14731986 {
14741987 assert (self);
14751988 # if defined (ZMQ_AFFINITY)
1989 int major, minor, patch;
1990 zmq_version (&major, &minor, &patch);
1991 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
1992 zsys_error ("zsock affinity option not supported by libzmq version %d.%d.%d, "
1993 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
1994 return;
1995 }
14761996 uint64_t value = affinity;
14771997 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_AFFINITY, &value, sizeof (uint64_t));
14781998 assert (rc == 0 || zmq_errno () == ETERM);
14892009 {
14902010 assert (self);
14912011 # if defined (ZMQ_AFFINITY)
2012 int major, minor, patch;
2013 zmq_version (&major, &minor, &patch);
2014 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2015 zsys_error ("zsock affinity option not supported by libzmq version %d.%d.%d, "
2016 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2017 return 0;
2018 }
14922019 uint64_t affinity;
14932020 size_t option_len = sizeof (uint64_t);
14942021 zmq_getsockopt (zsock_resolve (self), ZMQ_AFFINITY, &affinity, &option_len);
15072034 {
15082035 assert (self);
15092036 # if defined (ZMQ_SUBSCRIBE)
2037 int major, minor, patch;
2038 zmq_version (&major, &minor, &patch);
2039 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2040 zsys_error ("zsock subscribe option not supported by libzmq version %d.%d.%d, "
2041 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2042 return;
2043 }
15102044 if (zsock_type (self) != ZMQ_SUB) {
15112045 printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
15122046 assert (false);
15262060 {
15272061 assert (self);
15282062 # if defined (ZMQ_UNSUBSCRIBE)
2063 int major, minor, patch;
2064 zmq_version (&major, &minor, &patch);
2065 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2066 zsys_error ("zsock unsubscribe option not supported by libzmq version %d.%d.%d, "
2067 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2068 return;
2069 }
15292070 if (zsock_type (self) != ZMQ_SUB) {
15302071 printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
15312072 assert (false);
15452086 {
15462087 assert (self);
15472088 # if defined (ZMQ_IDENTITY)
2089 int major, minor, patch;
2090 zmq_version (&major, &minor, &patch);
2091 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2092 zsys_error ("zsock identity option not supported by libzmq version %d.%d.%d, "
2093 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2094 return;
2095 }
15482096 if (zsock_type (self) != ZMQ_REQ
15492097 && zsock_type (self) != ZMQ_REP
15502098 && zsock_type (self) != ZMQ_DEALER
15672115 {
15682116 assert (self);
15692117 # if defined (ZMQ_IDENTITY)
2118 int major, minor, patch;
2119 zmq_version (&major, &minor, &patch);
2120 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2121 zsys_error ("zsock identity option not supported by libzmq version %d.%d.%d, "
2122 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2123 return 0;
2124 }
15702125 size_t option_len = 255;
15712126 char *identity = (char *) zmalloc (option_len);
15722127 zmq_getsockopt (zsock_resolve (self), ZMQ_IDENTITY, identity, &option_len);
15852140 {
15862141 assert (self);
15872142 # if defined (ZMQ_RATE)
2143 int major, minor, patch;
2144 zmq_version (&major, &minor, &patch);
2145 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2146 zsys_error ("zsock rate option not supported by libzmq version %d.%d.%d, "
2147 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2148 return;
2149 }
15882150 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RATE, &rate, sizeof (int));
15892151 assert (rc == 0 || zmq_errno () == ETERM);
15902152 # endif
16002162 {
16012163 assert (self);
16022164 # if defined (ZMQ_RATE)
2165 int major, minor, patch;
2166 zmq_version (&major, &minor, &patch);
2167 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2168 zsys_error ("zsock rate option not supported by libzmq version %d.%d.%d, "
2169 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2170 return 0;
2171 }
16032172 int rate;
16042173 size_t option_len = sizeof (int);
16052174 zmq_getsockopt (zsock_resolve (self), ZMQ_RATE, &rate, &option_len);
16182187 {
16192188 assert (self);
16202189 # if defined (ZMQ_RECOVERY_IVL)
2190 int major, minor, patch;
2191 zmq_version (&major, &minor, &patch);
2192 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2193 zsys_error ("zsock recovery_ivl option not supported by libzmq version %d.%d.%d, "
2194 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2195 return;
2196 }
16212197 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &recovery_ivl, sizeof (int));
16222198 assert (rc == 0 || zmq_errno () == ETERM);
16232199 # endif
16332209 {
16342210 assert (self);
16352211 # if defined (ZMQ_RECOVERY_IVL)
2212 int major, minor, patch;
2213 zmq_version (&major, &minor, &patch);
2214 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2215 zsys_error ("zsock recovery_ivl option not supported by libzmq version %d.%d.%d, "
2216 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2217 return 0;
2218 }
16362219 int recovery_ivl;
16372220 size_t option_len = sizeof (int);
16382221 zmq_getsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len);
16512234 {
16522235 assert (self);
16532236 # if defined (ZMQ_SNDBUF)
2237 int major, minor, patch;
2238 zmq_version (&major, &minor, &patch);
2239 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2240 zsys_error ("zsock sndbuf option not supported by libzmq version %d.%d.%d, "
2241 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2242 return;
2243 }
16542244 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDBUF, &sndbuf, sizeof (int));
16552245 assert (rc == 0 || zmq_errno () == ETERM);
16562246 # endif
16662256 {
16672257 assert (self);
16682258 # if defined (ZMQ_SNDBUF)
2259 int major, minor, patch;
2260 zmq_version (&major, &minor, &patch);
2261 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2262 zsys_error ("zsock sndbuf option not supported by libzmq version %d.%d.%d, "
2263 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2264 return 0;
2265 }
16692266 int sndbuf;
16702267 size_t option_len = sizeof (int);
16712268 zmq_getsockopt (zsock_resolve (self), ZMQ_SNDBUF, &sndbuf, &option_len);
16842281 {
16852282 assert (self);
16862283 # if defined (ZMQ_RCVBUF)
2284 int major, minor, patch;
2285 zmq_version (&major, &minor, &patch);
2286 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2287 zsys_error ("zsock rcvbuf option not supported by libzmq version %d.%d.%d, "
2288 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2289 return;
2290 }
16872291 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVBUF, &rcvbuf, sizeof (int));
16882292 assert (rc == 0 || zmq_errno () == ETERM);
16892293 # endif
16992303 {
17002304 assert (self);
17012305 # if defined (ZMQ_RCVBUF)
2306 int major, minor, patch;
2307 zmq_version (&major, &minor, &patch);
2308 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2309 zsys_error ("zsock rcvbuf option not supported by libzmq version %d.%d.%d, "
2310 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2311 return 0;
2312 }
17022313 int rcvbuf;
17032314 size_t option_len = sizeof (int);
17042315 zmq_getsockopt (zsock_resolve (self), ZMQ_RCVBUF, &rcvbuf, &option_len);
17172328 {
17182329 assert (self);
17192330 # if defined (ZMQ_LINGER)
2331 int major, minor, patch;
2332 zmq_version (&major, &minor, &patch);
2333 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2334 zsys_error ("zsock linger option not supported by libzmq version %d.%d.%d, "
2335 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2336 return;
2337 }
17202338 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, sizeof (int));
17212339 assert (rc == 0 || zmq_errno () == ETERM);
17222340 # endif
17322350 {
17332351 assert (self);
17342352 # if defined (ZMQ_LINGER)
2353 int major, minor, patch;
2354 zmq_version (&major, &minor, &patch);
2355 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2356 zsys_error ("zsock linger option not supported by libzmq version %d.%d.%d, "
2357 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2358 return 0;
2359 }
17352360 int linger;
17362361 size_t option_len = sizeof (int);
17372362 zmq_getsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, &option_len);
17502375 {
17512376 assert (self);
17522377 # if defined (ZMQ_RECONNECT_IVL)
2378 int major, minor, patch;
2379 zmq_version (&major, &minor, &patch);
2380 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2381 zsys_error ("zsock reconnect_ivl option not supported by libzmq version %d.%d.%d, "
2382 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2383 return;
2384 }
17532385 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, sizeof (int));
17542386 assert (rc == 0 || zmq_errno () == ETERM);
17552387 # endif
17652397 {
17662398 assert (self);
17672399 # if defined (ZMQ_RECONNECT_IVL)
2400 int major, minor, patch;
2401 zmq_version (&major, &minor, &patch);
2402 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2403 zsys_error ("zsock reconnect_ivl option not supported by libzmq version %d.%d.%d, "
2404 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2405 return 0;
2406 }
17682407 int reconnect_ivl;
17692408 size_t option_len = sizeof (int);
17702409 zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, &option_len);
17832422 {
17842423 assert (self);
17852424 # if defined (ZMQ_RECONNECT_IVL_MAX)
2425 int major, minor, patch;
2426 zmq_version (&major, &minor, &patch);
2427 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2428 zsys_error ("zsock reconnect_ivl_max option not supported by libzmq version %d.%d.%d, "
2429 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2430 return;
2431 }
17862432 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, sizeof (int));
17872433 assert (rc == 0 || zmq_errno () == ETERM);
17882434 # endif
17982444 {
17992445 assert (self);
18002446 # if defined (ZMQ_RECONNECT_IVL_MAX)
2447 int major, minor, patch;
2448 zmq_version (&major, &minor, &patch);
2449 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2450 zsys_error ("zsock reconnect_ivl_max option not supported by libzmq version %d.%d.%d, "
2451 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2452 return 0;
2453 }
18012454 int reconnect_ivl_max;
18022455 size_t option_len = sizeof (int);
18032456 zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, &option_len);
18162469 {
18172470 assert (self);
18182471 # if defined (ZMQ_BACKLOG)
2472 int major, minor, patch;
2473 zmq_version (&major, &minor, &patch);
2474 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2475 zsys_error ("zsock backlog option not supported by libzmq version %d.%d.%d, "
2476 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2477 return;
2478 }
18192479 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, sizeof (int));
18202480 assert (rc == 0 || zmq_errno () == ETERM);
18212481 # endif
18312491 {
18322492 assert (self);
18332493 # if defined (ZMQ_BACKLOG)
2494 int major, minor, patch;
2495 zmq_version (&major, &minor, &patch);
2496 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2497 zsys_error ("zsock backlog option not supported by libzmq version %d.%d.%d, "
2498 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2499 return 0;
2500 }
18342501 int backlog;
18352502 size_t option_len = sizeof (int);
18362503 zmq_getsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, &option_len);
18492516 {
18502517 assert (self);
18512518 # if defined (ZMQ_MAXMSGSIZE)
2519 int major, minor, patch;
2520 zmq_version (&major, &minor, &patch);
2521 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2522 zsys_error ("zsock maxmsgsize option not supported by libzmq version %d.%d.%d, "
2523 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2524 return;
2525 }
18522526 int64_t value = maxmsgsize;
18532527 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MAXMSGSIZE, &value, sizeof (int64_t));
18542528 assert (rc == 0 || zmq_errno () == ETERM);
18652539 {
18662540 assert (self);
18672541 # if defined (ZMQ_MAXMSGSIZE)
2542 int major, minor, patch;
2543 zmq_version (&major, &minor, &patch);
2544 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2545 zsys_error ("zsock maxmsgsize option not supported by libzmq version %d.%d.%d, "
2546 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2547 return 0;
2548 }
18682549 int64_t maxmsgsize;
18692550 size_t option_len = sizeof (int64_t);
18702551 zmq_getsockopt (zsock_resolve (self), ZMQ_MAXMSGSIZE, &maxmsgsize, &option_len);
18832564 {
18842565 assert (self);
18852566 # if defined (ZMQ_MULTICAST_HOPS)
2567 int major, minor, patch;
2568 zmq_version (&major, &minor, &patch);
2569 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2570 zsys_error ("zsock multicast_hops option not supported by libzmq version %d.%d.%d, "
2571 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2572 return;
2573 }
18862574 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MULTICAST_HOPS, &multicast_hops, sizeof (int));
18872575 assert (rc == 0 || zmq_errno () == ETERM);
18882576 # endif
18982586 {
18992587 assert (self);
19002588 # if defined (ZMQ_MULTICAST_HOPS)
2589 int major, minor, patch;
2590 zmq_version (&major, &minor, &patch);
2591 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2592 zsys_error ("zsock multicast_hops option not supported by libzmq version %d.%d.%d, "
2593 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2594 return 0;
2595 }
19012596 int multicast_hops;
19022597 size_t option_len = sizeof (int);
19032598 zmq_getsockopt (zsock_resolve (self), ZMQ_MULTICAST_HOPS, &multicast_hops, &option_len);
19162611 {
19172612 assert (self);
19182613 # if defined (ZMQ_RCVTIMEO)
2614 int major, minor, patch;
2615 zmq_version (&major, &minor, &patch);
2616 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2617 zsys_error ("zsock rcvtimeo option not supported by libzmq version %d.%d.%d, "
2618 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2619 return;
2620 }
19192621 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int));
19202622 assert (rc == 0 || zmq_errno () == ETERM);
19212623 # endif
19312633 {
19322634 assert (self);
19332635 # if defined (ZMQ_RCVTIMEO)
2636 int major, minor, patch;
2637 zmq_version (&major, &minor, &patch);
2638 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2639 zsys_error ("zsock rcvtimeo option not supported by libzmq version %d.%d.%d, "
2640 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2641 return 0;
2642 }
19342643 int rcvtimeo;
19352644 size_t option_len = sizeof (int);
19362645 zmq_getsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, &option_len);
19492658 {
19502659 assert (self);
19512660 # if defined (ZMQ_SNDTIMEO)
2661 int major, minor, patch;
2662 zmq_version (&major, &minor, &patch);
2663 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2664 zsys_error ("zsock sndtimeo option not supported by libzmq version %d.%d.%d, "
2665 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2666 return;
2667 }
19522668 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, sizeof (int));
19532669 assert (rc == 0 || zmq_errno () == ETERM);
19542670 # endif
19642680 {
19652681 assert (self);
19662682 # if defined (ZMQ_SNDTIMEO)
2683 int major, minor, patch;
2684 zmq_version (&major, &minor, &patch);
2685 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2686 zsys_error ("zsock sndtimeo option not supported by libzmq version %d.%d.%d, "
2687 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2688 return 0;
2689 }
19672690 int sndtimeo;
19682691 size_t option_len = sizeof (int);
19692692 zmq_getsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, &option_len);
19822705 {
19832706 assert (self);
19842707 # if defined (ZMQ_XPUB_VERBOSE)
2708 int major, minor, patch;
2709 zmq_version (&major, &minor, &patch);
2710 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2711 zsys_error ("zsock xpub_verbose option not supported by libzmq version %d.%d.%d, "
2712 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2713 return;
2714 }
19852715 if (zsock_type (self) != ZMQ_XPUB) {
19862716 printf ("ZMQ_XPUB_VERBOSE is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
19872717 assert (false);
20012731 {
20022732 assert (self);
20032733 # if defined (ZMQ_TCP_KEEPALIVE)
2734 int major, minor, patch;
2735 zmq_version (&major, &minor, &patch);
2736 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2737 zsys_error ("zsock tcp_keepalive option not supported by libzmq version %d.%d.%d, "
2738 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2739 return;
2740 }
20042741 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE, &tcp_keepalive, sizeof (int));
20052742 assert (rc == 0 || zmq_errno () == ETERM);
20062743 # endif
20162753 {
20172754 assert (self);
20182755 # if defined (ZMQ_TCP_KEEPALIVE)
2756 int major, minor, patch;
2757 zmq_version (&major, &minor, &patch);
2758 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2759 zsys_error ("zsock tcp_keepalive option not supported by libzmq version %d.%d.%d, "
2760 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2761 return 0;
2762 }
20192763 int tcp_keepalive;
20202764 size_t option_len = sizeof (int);
20212765 zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE, &tcp_keepalive, &option_len);
20342778 {
20352779 assert (self);
20362780 # if defined (ZMQ_TCP_KEEPALIVE_IDLE)
2781 int major, minor, patch;
2782 zmq_version (&major, &minor, &patch);
2783 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2784 zsys_error ("zsock tcp_keepalive_idle option not supported by libzmq version %d.%d.%d, "
2785 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2786 return;
2787 }
20372788 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, sizeof (int));
20382789 assert (rc == 0 || zmq_errno () == ETERM);
20392790 # endif
20492800 {
20502801 assert (self);
20512802 # if defined (ZMQ_TCP_KEEPALIVE_IDLE)
2803 int major, minor, patch;
2804 zmq_version (&major, &minor, &patch);
2805 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2806 zsys_error ("zsock tcp_keepalive_idle option not supported by libzmq version %d.%d.%d, "
2807 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2808 return 0;
2809 }
20522810 int tcp_keepalive_idle;
20532811 size_t option_len = sizeof (int);
20542812 zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, &option_len);
20672825 {
20682826 assert (self);
20692827 # if defined (ZMQ_TCP_KEEPALIVE_CNT)
2828 int major, minor, patch;
2829 zmq_version (&major, &minor, &patch);
2830 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2831 zsys_error ("zsock tcp_keepalive_cnt option not supported by libzmq version %d.%d.%d, "
2832 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2833 return;
2834 }
20702835 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, sizeof (int));
20712836 assert (rc == 0 || zmq_errno () == ETERM);
20722837 # endif
20822847 {
20832848 assert (self);
20842849 # if defined (ZMQ_TCP_KEEPALIVE_CNT)
2850 int major, minor, patch;
2851 zmq_version (&major, &minor, &patch);
2852 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2853 zsys_error ("zsock tcp_keepalive_cnt option not supported by libzmq version %d.%d.%d, "
2854 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2855 return 0;
2856 }
20852857 int tcp_keepalive_cnt;
20862858 size_t option_len = sizeof (int);
20872859 zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, &option_len);
21002872 {
21012873 assert (self);
21022874 # if defined (ZMQ_TCP_KEEPALIVE_INTVL)
2875 int major, minor, patch;
2876 zmq_version (&major, &minor, &patch);
2877 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2878 zsys_error ("zsock tcp_keepalive_intvl option not supported by libzmq version %d.%d.%d, "
2879 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2880 return;
2881 }
21032882 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, sizeof (int));
21042883 assert (rc == 0 || zmq_errno () == ETERM);
21052884 # endif
21152894 {
21162895 assert (self);
21172896 # if defined (ZMQ_TCP_KEEPALIVE_INTVL)
2897 int major, minor, patch;
2898 zmq_version (&major, &minor, &patch);
2899 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2900 zsys_error ("zsock tcp_keepalive_intvl option not supported by libzmq version %d.%d.%d, "
2901 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2902 return 0;
2903 }
21182904 int tcp_keepalive_intvl;
21192905 size_t option_len = sizeof (int);
21202906 zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, &option_len);
21332919 {
21342920 assert (self);
21352921 # if defined (ZMQ_TCP_ACCEPT_FILTER)
2922 int major, minor, patch;
2923 zmq_version (&major, &minor, &patch);
2924 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2925 zsys_error ("zsock tcp_accept_filter option not supported by libzmq version %d.%d.%d, "
2926 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2927 return;
2928 }
21362929 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, strlen (tcp_accept_filter));
21372930 assert (rc == 0 || zmq_errno () == ETERM);
21382931 # endif
21482941 {
21492942 assert (self);
21502943 # if defined (ZMQ_TCP_ACCEPT_FILTER)
2944 int major, minor, patch;
2945 zmq_version (&major, &minor, &patch);
2946 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2947 zsys_error ("zsock tcp_accept_filter option not supported by libzmq version %d.%d.%d, "
2948 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2949 return 0;
2950 }
21512951 size_t option_len = 255;
21522952 char *tcp_accept_filter = (char *) zmalloc (option_len);
21532953 zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, &option_len);
21662966 {
21672967 assert (self);
21682968 # if defined (ZMQ_RCVMORE)
2969 int major, minor, patch;
2970 zmq_version (&major, &minor, &patch);
2971 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2972 zsys_error ("zsock rcvmore option not supported by libzmq version %d.%d.%d, "
2973 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2974 return 0;
2975 }
21692976 int rcvmore;
21702977 size_t option_len = sizeof (int);
21712978 zmq_getsockopt (zsock_resolve (self), ZMQ_RCVMORE, &rcvmore, &option_len);
21842991 {
21852992 assert (self);
21862993 # if defined (ZMQ_FD)
2994 int major, minor, patch;
2995 zmq_version (&major, &minor, &patch);
2996 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
2997 zsys_error ("zsock fd option not supported by libzmq version %d.%d.%d, "
2998 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
2999 return 0;
3000 }
21873001 SOCKET fd;
21883002 size_t option_len = sizeof (SOCKET);
21893003 zmq_getsockopt (zsock_resolve (self), ZMQ_FD, &fd, &option_len);
22023016 {
22033017 assert (self);
22043018 # if defined (ZMQ_EVENTS)
3019 int major, minor, patch;
3020 zmq_version (&major, &minor, &patch);
3021 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
3022 zsys_error ("zsock events option not supported by libzmq version %d.%d.%d, "
3023 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
3024 return 0;
3025 }
22053026 int events;
22063027 size_t option_len = sizeof (int);
22073028 zmq_getsockopt (zsock_resolve (self), ZMQ_EVENTS, &events, &option_len);
22203041 {
22213042 assert (self);
22223043 # if defined (ZMQ_LAST_ENDPOINT)
3044 int major, minor, patch;
3045 zmq_version (&major, &minor, &patch);
3046 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
3047 zsys_error ("zsock last_endpoint option not supported by libzmq version %d.%d.%d, "
3048 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
3049 return 0;
3050 }
22233051 size_t option_len = 255;
22243052 char *last_endpoint = (char *) zmalloc (option_len);
22253053 zmq_getsockopt (zsock_resolve (self), ZMQ_LAST_ENDPOINT, last_endpoint, &option_len);
22293057 # endif
22303058 }
22313059
2232 #endif
2233
2234 #if (ZMQ_VERSION_MAJOR == 3)
22353060 // --------------------------------------------------------------------------
22363061 // Set socket ZMQ_ROUTER_RAW value
22373062 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
22413066 {
22423067 assert (self);
22433068 # if defined (ZMQ_ROUTER_RAW)
3069 int major, minor, patch;
3070 zmq_version (&major, &minor, &patch);
3071 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
3072 zsys_error ("zsock router_raw option not supported by libzmq version %d.%d.%d, "
3073 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
3074 return;
3075 }
22443076 if (zsock_type (self) != ZMQ_ROUTER) {
22453077 printf ("ZMQ_ROUTER_RAW is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
22463078 assert (false);
22603092 {
22613093 assert (self);
22623094 # if defined (ZMQ_IPV4ONLY)
3095 int major, minor, patch;
3096 zmq_version (&major, &minor, &patch);
3097 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
3098 zsys_error ("zsock ipv4only option not supported by libzmq version %d.%d.%d, "
3099 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
3100 return;
3101 }
22633102 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IPV4ONLY, &ipv4only, sizeof (int));
22643103 assert (rc == 0 || zmq_errno () == ETERM);
22653104 # endif
22753114 {
22763115 assert (self);
22773116 # if defined (ZMQ_IPV4ONLY)
3117 int major, minor, patch;
3118 zmq_version (&major, &minor, &patch);
3119 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
3120 zsys_error ("zsock ipv4only option not supported by libzmq version %d.%d.%d, "
3121 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
3122 return 0;
3123 }
22783124 int ipv4only;
22793125 size_t option_len = sizeof (int);
22803126 zmq_getsockopt (zsock_resolve (self), ZMQ_IPV4ONLY, &ipv4only, &option_len);
22933139 {
22943140 assert (self);
22953141 # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT)
3142 int major, minor, patch;
3143 zmq_version (&major, &minor, &patch);
3144 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) {
3145 zsys_error ("zsock delay_attach_on_connect option not supported by libzmq version %d.%d.%d, "
3146 "run with libzmq >= 3.0.0\n", major, minor, patch, NULL);
3147 return;
3148 }
22963149 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_DELAY_ATTACH_ON_CONNECT, &delay_attach_on_connect, sizeof (int));
22973150 assert (rc == 0 || zmq_errno () == ETERM);
22983151 # endif
22993152 }
23003153
23013154
3155 #endif
3156
3157 #if (ZMQ_VERSION_MAJOR >= 2) && (ZMQ_VERSION_MAJOR < 3)
3158 // --------------------------------------------------------------------------
3159 // Set socket ZMQ_HWM value
3160 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3161
3162 void
3163 zsock_set_hwm (void *self, int hwm)
3164 {
3165 assert (self);
3166 # if defined (ZMQ_HWM)
3167 int major, minor, patch;
3168 zmq_version (&major, &minor, &patch);
3169 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3170 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3171 zsys_error ("zsock hwm option not supported by libzmq version %d.%d.%d, "
3172 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3173 return;
3174 }
3175 uint64_t value = hwm;
3176 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_HWM, &value, sizeof (uint64_t));
3177 assert (rc == 0 || zmq_errno () == ETERM);
3178 # endif
3179 }
3180
3181
3182 // --------------------------------------------------------------------------
3183 // Return socket ZMQ_HWM value
3184 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3185
3186 int
3187 zsock_hwm (void *self)
3188 {
3189 assert (self);
3190 # if defined (ZMQ_HWM)
3191 int major, minor, patch;
3192 zmq_version (&major, &minor, &patch);
3193 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3194 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3195 zsys_error ("zsock hwm option not supported by libzmq version %d.%d.%d, "
3196 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3197 return 0;
3198 }
3199 uint64_t hwm;
3200 size_t option_len = sizeof (uint64_t);
3201 zmq_getsockopt (zsock_resolve (self), ZMQ_HWM, &hwm, &option_len);
3202 return (int) hwm;
3203 # else
3204 return 0;
3205 # endif
3206 }
3207
3208 // --------------------------------------------------------------------------
3209 // Set socket ZMQ_SWAP value
3210 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3211
3212 void
3213 zsock_set_swap (void *self, int swap)
3214 {
3215 assert (self);
3216 # if defined (ZMQ_SWAP)
3217 int major, minor, patch;
3218 zmq_version (&major, &minor, &patch);
3219 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3220 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3221 zsys_error ("zsock swap option not supported by libzmq version %d.%d.%d, "
3222 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3223 return;
3224 }
3225 int64_t value = swap;
3226 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SWAP, &value, sizeof (int64_t));
3227 assert (rc == 0 || zmq_errno () == ETERM);
3228 # endif
3229 }
3230
3231
3232 // --------------------------------------------------------------------------
3233 // Return socket ZMQ_SWAP value
3234 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3235
3236 int
3237 zsock_swap (void *self)
3238 {
3239 assert (self);
3240 # if defined (ZMQ_SWAP)
3241 int major, minor, patch;
3242 zmq_version (&major, &minor, &patch);
3243 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3244 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3245 zsys_error ("zsock swap option not supported by libzmq version %d.%d.%d, "
3246 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3247 return 0;
3248 }
3249 int64_t swap;
3250 size_t option_len = sizeof (int64_t);
3251 zmq_getsockopt (zsock_resolve (self), ZMQ_SWAP, &swap, &option_len);
3252 return (int) swap;
3253 # else
3254 return 0;
3255 # endif
3256 }
3257
3258 // --------------------------------------------------------------------------
3259 // Set socket ZMQ_AFFINITY value
3260 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3261
3262 void
3263 zsock_set_affinity (void *self, int affinity)
3264 {
3265 assert (self);
3266 # if defined (ZMQ_AFFINITY)
3267 int major, minor, patch;
3268 zmq_version (&major, &minor, &patch);
3269 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3270 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3271 zsys_error ("zsock affinity option not supported by libzmq version %d.%d.%d, "
3272 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3273 return;
3274 }
3275 uint64_t value = affinity;
3276 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_AFFINITY, &value, sizeof (uint64_t));
3277 assert (rc == 0 || zmq_errno () == ETERM);
3278 # endif
3279 }
3280
3281
3282 // --------------------------------------------------------------------------
3283 // Return socket ZMQ_AFFINITY value
3284 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3285
3286 int
3287 zsock_affinity (void *self)
3288 {
3289 assert (self);
3290 # if defined (ZMQ_AFFINITY)
3291 int major, minor, patch;
3292 zmq_version (&major, &minor, &patch);
3293 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3294 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3295 zsys_error ("zsock affinity option not supported by libzmq version %d.%d.%d, "
3296 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3297 return 0;
3298 }
3299 uint64_t affinity;
3300 size_t option_len = sizeof (uint64_t);
3301 zmq_getsockopt (zsock_resolve (self), ZMQ_AFFINITY, &affinity, &option_len);
3302 return (int) affinity;
3303 # else
3304 return 0;
3305 # endif
3306 }
3307
3308 // --------------------------------------------------------------------------
3309 // Set socket ZMQ_IDENTITY value
3310 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3311
3312 void
3313 zsock_set_identity (void *self, const char * identity)
3314 {
3315 assert (self);
3316 # if defined (ZMQ_IDENTITY)
3317 int major, minor, patch;
3318 zmq_version (&major, &minor, &patch);
3319 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3320 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3321 zsys_error ("zsock identity option not supported by libzmq version %d.%d.%d, "
3322 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3323 return;
3324 }
3325 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IDENTITY, identity, strlen (identity));
3326 assert (rc == 0 || zmq_errno () == ETERM);
3327 # endif
3328 }
3329
3330
3331 // --------------------------------------------------------------------------
3332 // Return socket ZMQ_IDENTITY value
3333 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3334
3335 char *
3336 zsock_identity (void *self)
3337 {
3338 assert (self);
3339 # if defined (ZMQ_IDENTITY)
3340 int major, minor, patch;
3341 zmq_version (&major, &minor, &patch);
3342 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3343 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3344 zsys_error ("zsock identity option not supported by libzmq version %d.%d.%d, "
3345 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3346 return 0;
3347 }
3348 size_t option_len = 255;
3349 char *identity = (char *) zmalloc (option_len);
3350 zmq_getsockopt (zsock_resolve (self), ZMQ_IDENTITY, identity, &option_len);
3351 return (char *) identity;
3352 # else
3353 return NULL;
3354 # endif
3355 }
3356
3357 // --------------------------------------------------------------------------
3358 // Set socket ZMQ_RATE value
3359 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3360
3361 void
3362 zsock_set_rate (void *self, int rate)
3363 {
3364 assert (self);
3365 # if defined (ZMQ_RATE)
3366 int major, minor, patch;
3367 zmq_version (&major, &minor, &patch);
3368 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3369 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3370 zsys_error ("zsock rate option not supported by libzmq version %d.%d.%d, "
3371 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3372 return;
3373 }
3374 int64_t value = rate;
3375 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RATE, &value, sizeof (int64_t));
3376 assert (rc == 0 || zmq_errno () == ETERM);
3377 # endif
3378 }
3379
3380
3381 // --------------------------------------------------------------------------
3382 // Return socket ZMQ_RATE value
3383 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3384
3385 int
3386 zsock_rate (void *self)
3387 {
3388 assert (self);
3389 # if defined (ZMQ_RATE)
3390 int major, minor, patch;
3391 zmq_version (&major, &minor, &patch);
3392 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3393 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3394 zsys_error ("zsock rate option not supported by libzmq version %d.%d.%d, "
3395 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3396 return 0;
3397 }
3398 int64_t rate;
3399 size_t option_len = sizeof (int64_t);
3400 zmq_getsockopt (zsock_resolve (self), ZMQ_RATE, &rate, &option_len);
3401 return (int) rate;
3402 # else
3403 return 0;
3404 # endif
3405 }
3406
3407 // --------------------------------------------------------------------------
3408 // Set socket ZMQ_RECOVERY_IVL value
3409 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3410
3411 void
3412 zsock_set_recovery_ivl (void *self, int recovery_ivl)
3413 {
3414 assert (self);
3415 # if defined (ZMQ_RECOVERY_IVL)
3416 int major, minor, patch;
3417 zmq_version (&major, &minor, &patch);
3418 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3419 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3420 zsys_error ("zsock recovery_ivl option not supported by libzmq version %d.%d.%d, "
3421 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3422 return;
3423 }
3424 int64_t value = recovery_ivl;
3425 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &value, sizeof (int64_t));
3426 assert (rc == 0 || zmq_errno () == ETERM);
3427 # endif
3428 }
3429
3430
3431 // --------------------------------------------------------------------------
3432 // Return socket ZMQ_RECOVERY_IVL value
3433 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3434
3435 int
3436 zsock_recovery_ivl (void *self)
3437 {
3438 assert (self);
3439 # if defined (ZMQ_RECOVERY_IVL)
3440 int major, minor, patch;
3441 zmq_version (&major, &minor, &patch);
3442 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3443 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3444 zsys_error ("zsock recovery_ivl option not supported by libzmq version %d.%d.%d, "
3445 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3446 return 0;
3447 }
3448 int64_t recovery_ivl;
3449 size_t option_len = sizeof (int64_t);
3450 zmq_getsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len);
3451 return (int) recovery_ivl;
3452 # else
3453 return 0;
3454 # endif
3455 }
3456
3457 // --------------------------------------------------------------------------
3458 // Set socket ZMQ_RECOVERY_IVL_MSEC value
3459 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3460
3461 void
3462 zsock_set_recovery_ivl_msec (void *self, int recovery_ivl_msec)
3463 {
3464 assert (self);
3465 # if defined (ZMQ_RECOVERY_IVL_MSEC)
3466 int major, minor, patch;
3467 zmq_version (&major, &minor, &patch);
3468 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3469 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3470 zsys_error ("zsock recovery_ivl_msec option not supported by libzmq version %d.%d.%d, "
3471 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3472 return;
3473 }
3474 int64_t value = recovery_ivl_msec;
3475 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL_MSEC, &value, sizeof (int64_t));
3476 assert (rc == 0 || zmq_errno () == ETERM);
3477 # endif
3478 }
3479
3480
3481 // --------------------------------------------------------------------------
3482 // Return socket ZMQ_RECOVERY_IVL_MSEC value
3483 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3484
3485 int
3486 zsock_recovery_ivl_msec (void *self)
3487 {
3488 assert (self);
3489 # if defined (ZMQ_RECOVERY_IVL_MSEC)
3490 int major, minor, patch;
3491 zmq_version (&major, &minor, &patch);
3492 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3493 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3494 zsys_error ("zsock recovery_ivl_msec option not supported by libzmq version %d.%d.%d, "
3495 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3496 return 0;
3497 }
3498 int64_t recovery_ivl_msec;
3499 size_t option_len = sizeof (int64_t);
3500 zmq_getsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL_MSEC, &recovery_ivl_msec, &option_len);
3501 return (int) recovery_ivl_msec;
3502 # else
3503 return 0;
3504 # endif
3505 }
3506
3507 // --------------------------------------------------------------------------
3508 // Set socket ZMQ_MCAST_LOOP value
3509 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3510
3511 void
3512 zsock_set_mcast_loop (void *self, int mcast_loop)
3513 {
3514 assert (self);
3515 # if defined (ZMQ_MCAST_LOOP)
3516 int major, minor, patch;
3517 zmq_version (&major, &minor, &patch);
3518 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3519 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3520 zsys_error ("zsock mcast_loop option not supported by libzmq version %d.%d.%d, "
3521 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3522 return;
3523 }
3524 int64_t value = mcast_loop;
3525 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MCAST_LOOP, &value, sizeof (int64_t));
3526 assert (rc == 0 || zmq_errno () == ETERM);
3527 # endif
3528 }
3529
3530
3531 // --------------------------------------------------------------------------
3532 // Return socket ZMQ_MCAST_LOOP value
3533 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3534
3535 int
3536 zsock_mcast_loop (void *self)
3537 {
3538 assert (self);
3539 # if defined (ZMQ_MCAST_LOOP)
3540 int major, minor, patch;
3541 zmq_version (&major, &minor, &patch);
3542 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3543 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3544 zsys_error ("zsock mcast_loop option not supported by libzmq version %d.%d.%d, "
3545 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3546 return 0;
3547 }
3548 int64_t mcast_loop;
3549 size_t option_len = sizeof (int64_t);
3550 zmq_getsockopt (zsock_resolve (self), ZMQ_MCAST_LOOP, &mcast_loop, &option_len);
3551 return (int) mcast_loop;
3552 # else
3553 return 0;
3554 # endif
3555 }
3556
3557 // --------------------------------------------------------------------------
3558 // Set socket ZMQ_RCVTIMEO value
3559 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3560
3561 void
3562 zsock_set_rcvtimeo (void *self, int rcvtimeo)
3563 {
3564 assert (self);
3565 # if defined (ZMQ_RCVTIMEO)
3566 int major, minor, patch;
3567 zmq_version (&major, &minor, &patch);
3568 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 2, 0)
3569 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3570 zsys_error ("zsock rcvtimeo option not supported by libzmq version %d.%d.%d, "
3571 "run with libzmq >= 2.2.0 and < 3.0.0\n", major, minor, patch, NULL);
3572 return;
3573 }
3574 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int));
3575 assert (rc == 0 || zmq_errno () == ETERM);
3576 # endif
3577 }
3578
3579
3580 // --------------------------------------------------------------------------
3581 // Return socket ZMQ_RCVTIMEO value
3582 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3583
3584 int
3585 zsock_rcvtimeo (void *self)
3586 {
3587 assert (self);
3588 # if defined (ZMQ_RCVTIMEO)
3589 int major, minor, patch;
3590 zmq_version (&major, &minor, &patch);
3591 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 2, 0)
3592 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3593 zsys_error ("zsock rcvtimeo option not supported by libzmq version %d.%d.%d, "
3594 "run with libzmq >= 2.2.0 and < 3.0.0\n", major, minor, patch, NULL);
3595 return 0;
3596 }
3597 int rcvtimeo;
3598 size_t option_len = sizeof (int);
3599 zmq_getsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, &option_len);
3600 return rcvtimeo;
3601 # else
3602 return 0;
3603 # endif
3604 }
3605
3606 // --------------------------------------------------------------------------
3607 // Set socket ZMQ_SNDTIMEO value
3608 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3609
3610 void
3611 zsock_set_sndtimeo (void *self, int sndtimeo)
3612 {
3613 assert (self);
3614 # if defined (ZMQ_SNDTIMEO)
3615 int major, minor, patch;
3616 zmq_version (&major, &minor, &patch);
3617 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 2, 0)
3618 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3619 zsys_error ("zsock sndtimeo option not supported by libzmq version %d.%d.%d, "
3620 "run with libzmq >= 2.2.0 and < 3.0.0\n", major, minor, patch, NULL);
3621 return;
3622 }
3623 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, sizeof (int));
3624 assert (rc == 0 || zmq_errno () == ETERM);
3625 # endif
3626 }
3627
3628
3629 // --------------------------------------------------------------------------
3630 // Return socket ZMQ_SNDTIMEO value
3631 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3632
3633 int
3634 zsock_sndtimeo (void *self)
3635 {
3636 assert (self);
3637 # if defined (ZMQ_SNDTIMEO)
3638 int major, minor, patch;
3639 zmq_version (&major, &minor, &patch);
3640 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 2, 0)
3641 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3642 zsys_error ("zsock sndtimeo option not supported by libzmq version %d.%d.%d, "
3643 "run with libzmq >= 2.2.0 and < 3.0.0\n", major, minor, patch, NULL);
3644 return 0;
3645 }
3646 int sndtimeo;
3647 size_t option_len = sizeof (int);
3648 zmq_getsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, &option_len);
3649 return sndtimeo;
3650 # else
3651 return 0;
3652 # endif
3653 }
3654
3655 // --------------------------------------------------------------------------
3656 // Set socket ZMQ_SNDBUF value
3657 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3658
3659 void
3660 zsock_set_sndbuf (void *self, int sndbuf)
3661 {
3662 assert (self);
3663 # if defined (ZMQ_SNDBUF)
3664 int major, minor, patch;
3665 zmq_version (&major, &minor, &patch);
3666 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3667 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3668 zsys_error ("zsock sndbuf option not supported by libzmq version %d.%d.%d, "
3669 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3670 return;
3671 }
3672 uint64_t value = sndbuf;
3673 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDBUF, &value, sizeof (uint64_t));
3674 assert (rc == 0 || zmq_errno () == ETERM);
3675 # endif
3676 }
3677
3678
3679 // --------------------------------------------------------------------------
3680 // Return socket ZMQ_SNDBUF value
3681 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3682
3683 int
3684 zsock_sndbuf (void *self)
3685 {
3686 assert (self);
3687 # if defined (ZMQ_SNDBUF)
3688 int major, minor, patch;
3689 zmq_version (&major, &minor, &patch);
3690 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3691 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3692 zsys_error ("zsock sndbuf option not supported by libzmq version %d.%d.%d, "
3693 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3694 return 0;
3695 }
3696 uint64_t sndbuf;
3697 size_t option_len = sizeof (uint64_t);
3698 zmq_getsockopt (zsock_resolve (self), ZMQ_SNDBUF, &sndbuf, &option_len);
3699 return (int) sndbuf;
3700 # else
3701 return 0;
3702 # endif
3703 }
3704
3705 // --------------------------------------------------------------------------
3706 // Set socket ZMQ_RCVBUF value
3707 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3708
3709 void
3710 zsock_set_rcvbuf (void *self, int rcvbuf)
3711 {
3712 assert (self);
3713 # if defined (ZMQ_RCVBUF)
3714 int major, minor, patch;
3715 zmq_version (&major, &minor, &patch);
3716 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3717 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3718 zsys_error ("zsock rcvbuf option not supported by libzmq version %d.%d.%d, "
3719 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3720 return;
3721 }
3722 uint64_t value = rcvbuf;
3723 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVBUF, &value, sizeof (uint64_t));
3724 assert (rc == 0 || zmq_errno () == ETERM);
3725 # endif
3726 }
3727
3728
3729 // --------------------------------------------------------------------------
3730 // Return socket ZMQ_RCVBUF value
3731 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3732
3733 int
3734 zsock_rcvbuf (void *self)
3735 {
3736 assert (self);
3737 # if defined (ZMQ_RCVBUF)
3738 int major, minor, patch;
3739 zmq_version (&major, &minor, &patch);
3740 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3741 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3742 zsys_error ("zsock rcvbuf option not supported by libzmq version %d.%d.%d, "
3743 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3744 return 0;
3745 }
3746 uint64_t rcvbuf;
3747 size_t option_len = sizeof (uint64_t);
3748 zmq_getsockopt (zsock_resolve (self), ZMQ_RCVBUF, &rcvbuf, &option_len);
3749 return (int) rcvbuf;
3750 # else
3751 return 0;
3752 # endif
3753 }
3754
3755 // --------------------------------------------------------------------------
3756 // Set socket ZMQ_LINGER value
3757 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3758
3759 void
3760 zsock_set_linger (void *self, int linger)
3761 {
3762 assert (self);
3763 # if defined (ZMQ_LINGER)
3764 int major, minor, patch;
3765 zmq_version (&major, &minor, &patch);
3766 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3767 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3768 zsys_error ("zsock linger option not supported by libzmq version %d.%d.%d, "
3769 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3770 return;
3771 }
3772 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, sizeof (int));
3773 assert (rc == 0 || zmq_errno () == ETERM);
3774 # endif
3775 }
3776
3777
3778 // --------------------------------------------------------------------------
3779 // Return socket ZMQ_LINGER value
3780 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3781
3782 int
3783 zsock_linger (void *self)
3784 {
3785 assert (self);
3786 # if defined (ZMQ_LINGER)
3787 int major, minor, patch;
3788 zmq_version (&major, &minor, &patch);
3789 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3790 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3791 zsys_error ("zsock linger option not supported by libzmq version %d.%d.%d, "
3792 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3793 return 0;
3794 }
3795 int linger;
3796 size_t option_len = sizeof (int);
3797 zmq_getsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, &option_len);
3798 return linger;
3799 # else
3800 return 0;
3801 # endif
3802 }
3803
3804 // --------------------------------------------------------------------------
3805 // Set socket ZMQ_RECONNECT_IVL value
3806 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3807
3808 void
3809 zsock_set_reconnect_ivl (void *self, int reconnect_ivl)
3810 {
3811 assert (self);
3812 # if defined (ZMQ_RECONNECT_IVL)
3813 int major, minor, patch;
3814 zmq_version (&major, &minor, &patch);
3815 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3816 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3817 zsys_error ("zsock reconnect_ivl option not supported by libzmq version %d.%d.%d, "
3818 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3819 return;
3820 }
3821 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, sizeof (int));
3822 assert (rc == 0 || zmq_errno () == ETERM);
3823 # endif
3824 }
3825
3826
3827 // --------------------------------------------------------------------------
3828 // Return socket ZMQ_RECONNECT_IVL value
3829 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3830
3831 int
3832 zsock_reconnect_ivl (void *self)
3833 {
3834 assert (self);
3835 # if defined (ZMQ_RECONNECT_IVL)
3836 int major, minor, patch;
3837 zmq_version (&major, &minor, &patch);
3838 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3839 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3840 zsys_error ("zsock reconnect_ivl option not supported by libzmq version %d.%d.%d, "
3841 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3842 return 0;
3843 }
3844 int reconnect_ivl;
3845 size_t option_len = sizeof (int);
3846 zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, &option_len);
3847 return reconnect_ivl;
3848 # else
3849 return 0;
3850 # endif
3851 }
3852
3853 // --------------------------------------------------------------------------
3854 // Set socket ZMQ_RECONNECT_IVL_MAX value
3855 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3856
3857 void
3858 zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max)
3859 {
3860 assert (self);
3861 # if defined (ZMQ_RECONNECT_IVL_MAX)
3862 int major, minor, patch;
3863 zmq_version (&major, &minor, &patch);
3864 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3865 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3866 zsys_error ("zsock reconnect_ivl_max option not supported by libzmq version %d.%d.%d, "
3867 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3868 return;
3869 }
3870 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, sizeof (int));
3871 assert (rc == 0 || zmq_errno () == ETERM);
3872 # endif
3873 }
3874
3875
3876 // --------------------------------------------------------------------------
3877 // Return socket ZMQ_RECONNECT_IVL_MAX value
3878 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3879
3880 int
3881 zsock_reconnect_ivl_max (void *self)
3882 {
3883 assert (self);
3884 # if defined (ZMQ_RECONNECT_IVL_MAX)
3885 int major, minor, patch;
3886 zmq_version (&major, &minor, &patch);
3887 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3888 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3889 zsys_error ("zsock reconnect_ivl_max option not supported by libzmq version %d.%d.%d, "
3890 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3891 return 0;
3892 }
3893 int reconnect_ivl_max;
3894 size_t option_len = sizeof (int);
3895 zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, &option_len);
3896 return reconnect_ivl_max;
3897 # else
3898 return 0;
3899 # endif
3900 }
3901
3902 // --------------------------------------------------------------------------
3903 // Set socket ZMQ_BACKLOG value
3904 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3905
3906 void
3907 zsock_set_backlog (void *self, int backlog)
3908 {
3909 assert (self);
3910 # if defined (ZMQ_BACKLOG)
3911 int major, minor, patch;
3912 zmq_version (&major, &minor, &patch);
3913 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3914 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3915 zsys_error ("zsock backlog option not supported by libzmq version %d.%d.%d, "
3916 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3917 return;
3918 }
3919 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, sizeof (int));
3920 assert (rc == 0 || zmq_errno () == ETERM);
3921 # endif
3922 }
3923
3924
3925 // --------------------------------------------------------------------------
3926 // Return socket ZMQ_BACKLOG value
3927 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3928
3929 int
3930 zsock_backlog (void *self)
3931 {
3932 assert (self);
3933 # if defined (ZMQ_BACKLOG)
3934 int major, minor, patch;
3935 zmq_version (&major, &minor, &patch);
3936 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3937 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3938 zsys_error ("zsock backlog option not supported by libzmq version %d.%d.%d, "
3939 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3940 return 0;
3941 }
3942 int backlog;
3943 size_t option_len = sizeof (int);
3944 zmq_getsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, &option_len);
3945 return backlog;
3946 # else
3947 return 0;
3948 # endif
3949 }
3950
3951 // --------------------------------------------------------------------------
3952 // Set socket ZMQ_SUBSCRIBE value
3953 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3954
3955 void
3956 zsock_set_subscribe (void *self, const char * subscribe)
3957 {
3958 assert (self);
3959 # if defined (ZMQ_SUBSCRIBE)
3960 int major, minor, patch;
3961 zmq_version (&major, &minor, &patch);
3962 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3963 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3964 zsys_error ("zsock subscribe option not supported by libzmq version %d.%d.%d, "
3965 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3966 return;
3967 }
3968 if (zsock_type (self) != ZMQ_SUB) {
3969 printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
3970 assert (false);
3971 }
3972 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SUBSCRIBE, subscribe, strlen (subscribe));
3973 assert (rc == 0 || zmq_errno () == ETERM);
3974 # endif
3975 }
3976
3977
3978 // --------------------------------------------------------------------------
3979 // Set socket ZMQ_UNSUBSCRIBE value
3980 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3981
3982 void
3983 zsock_set_unsubscribe (void *self, const char * unsubscribe)
3984 {
3985 assert (self);
3986 # if defined (ZMQ_UNSUBSCRIBE)
3987 int major, minor, patch;
3988 zmq_version (&major, &minor, &patch);
3989 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
3990 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
3991 zsys_error ("zsock unsubscribe option not supported by libzmq version %d.%d.%d, "
3992 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
3993 return;
3994 }
3995 if (zsock_type (self) != ZMQ_SUB) {
3996 printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
3997 assert (false);
3998 }
3999 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_UNSUBSCRIBE, unsubscribe, strlen (unsubscribe));
4000 assert (rc == 0 || zmq_errno () == ETERM);
4001 # endif
4002 }
4003
4004
23024005 // --------------------------------------------------------------------------
23034006 // Return socket ZMQ_TYPE value
23044007 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
23084011 {
23094012 assert (self);
23104013 # if defined (ZMQ_TYPE)
4014 int major, minor, patch;
4015 zmq_version (&major, &minor, &patch);
4016 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
4017 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
4018 zsys_error ("zsock type option not supported by libzmq version %d.%d.%d, "
4019 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
4020 return 0;
4021 }
23114022 int type;
23124023 size_t option_len = sizeof (int);
23134024 zmq_getsockopt (zsock_resolve (self), ZMQ_TYPE, &type, &option_len);
23184029 }
23194030
23204031 // --------------------------------------------------------------------------
2321 // Set socket ZMQ_SNDHWM value
2322 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2323
2324 void
2325 zsock_set_sndhwm (void *self, int sndhwm)
2326 {
2327 assert (self);
2328 # if defined (ZMQ_SNDHWM)
2329 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDHWM, &sndhwm, sizeof (int));
2330 assert (rc == 0 || zmq_errno () == ETERM);
2331 # endif
2332 }
2333
2334
2335 // --------------------------------------------------------------------------
2336 // Return socket ZMQ_SNDHWM value
2337 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2338
2339 int
2340 zsock_sndhwm (void *self)
2341 {
2342 assert (self);
2343 # if defined (ZMQ_SNDHWM)
2344 int sndhwm;
2345 size_t option_len = sizeof (int);
2346 zmq_getsockopt (zsock_resolve (self), ZMQ_SNDHWM, &sndhwm, &option_len);
2347 return sndhwm;
2348 # else
2349 return 0;
2350 # endif
2351 }
2352
2353 // --------------------------------------------------------------------------
2354 // Set socket ZMQ_RCVHWM value
2355 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2356
2357 void
2358 zsock_set_rcvhwm (void *self, int rcvhwm)
2359 {
2360 assert (self);
2361 # if defined (ZMQ_RCVHWM)
2362 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVHWM, &rcvhwm, sizeof (int));
2363 assert (rc == 0 || zmq_errno () == ETERM);
2364 # endif
2365 }
2366
2367
2368 // --------------------------------------------------------------------------
2369 // Return socket ZMQ_RCVHWM value
2370 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2371
2372 int
2373 zsock_rcvhwm (void *self)
2374 {
2375 assert (self);
2376 # if defined (ZMQ_RCVHWM)
2377 int rcvhwm;
2378 size_t option_len = sizeof (int);
2379 zmq_getsockopt (zsock_resolve (self), ZMQ_RCVHWM, &rcvhwm, &option_len);
2380 return rcvhwm;
2381 # else
2382 return 0;
2383 # endif
2384 }
2385
2386 // --------------------------------------------------------------------------
2387 // Set socket ZMQ_AFFINITY value
2388 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2389
2390 void
2391 zsock_set_affinity (void *self, int affinity)
2392 {
2393 assert (self);
2394 # if defined (ZMQ_AFFINITY)
2395 uint64_t value = affinity;
2396 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_AFFINITY, &value, sizeof (uint64_t));
2397 assert (rc == 0 || zmq_errno () == ETERM);
2398 # endif
2399 }
2400
2401
2402 // --------------------------------------------------------------------------
2403 // Return socket ZMQ_AFFINITY value
2404 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2405
2406 int
2407 zsock_affinity (void *self)
2408 {
2409 assert (self);
2410 # if defined (ZMQ_AFFINITY)
2411 uint64_t affinity;
2412 size_t option_len = sizeof (uint64_t);
2413 zmq_getsockopt (zsock_resolve (self), ZMQ_AFFINITY, &affinity, &option_len);
2414 return (int) affinity;
2415 # else
2416 return 0;
2417 # endif
2418 }
2419
2420 // --------------------------------------------------------------------------
2421 // Set socket ZMQ_SUBSCRIBE value
2422 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2423
2424 void
2425 zsock_set_subscribe (void *self, const char * subscribe)
2426 {
2427 assert (self);
2428 # if defined (ZMQ_SUBSCRIBE)
2429 if (zsock_type (self) != ZMQ_SUB) {
2430 printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
2431 assert (false);
2432 }
2433 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SUBSCRIBE, subscribe, strlen (subscribe));
2434 assert (rc == 0 || zmq_errno () == ETERM);
2435 # endif
2436 }
2437
2438
2439 // --------------------------------------------------------------------------
2440 // Set socket ZMQ_UNSUBSCRIBE value
2441 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2442
2443 void
2444 zsock_set_unsubscribe (void *self, const char * unsubscribe)
2445 {
2446 assert (self);
2447 # if defined (ZMQ_UNSUBSCRIBE)
2448 if (zsock_type (self) != ZMQ_SUB) {
2449 printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
2450 assert (false);
2451 }
2452 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_UNSUBSCRIBE, unsubscribe, strlen (unsubscribe));
2453 assert (rc == 0 || zmq_errno () == ETERM);
2454 # endif
2455 }
2456
2457
2458 // --------------------------------------------------------------------------
2459 // Set socket ZMQ_IDENTITY value
2460 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2461
2462 void
2463 zsock_set_identity (void *self, const char * identity)
2464 {
2465 assert (self);
2466 # if defined (ZMQ_IDENTITY)
2467 if (zsock_type (self) != ZMQ_REQ
2468 && zsock_type (self) != ZMQ_REP
2469 && zsock_type (self) != ZMQ_DEALER
2470 && zsock_type (self) != ZMQ_ROUTER) {
2471 printf ("ZMQ_IDENTITY is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
2472 assert (false);
2473 }
2474 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IDENTITY, identity, strlen (identity));
2475 assert (rc == 0 || zmq_errno () == ETERM);
2476 # endif
2477 }
2478
2479
2480 // --------------------------------------------------------------------------
2481 // Return socket ZMQ_IDENTITY value
2482 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2483
2484 char *
2485 zsock_identity (void *self)
2486 {
2487 assert (self);
2488 # if defined (ZMQ_IDENTITY)
2489 size_t option_len = 255;
2490 char *identity = (char *) zmalloc (option_len);
2491 zmq_getsockopt (zsock_resolve (self), ZMQ_IDENTITY, identity, &option_len);
2492 return (char *) identity;
2493 # else
2494 return NULL;
2495 # endif
2496 }
2497
2498 // --------------------------------------------------------------------------
2499 // Set socket ZMQ_RATE value
2500 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2501
2502 void
2503 zsock_set_rate (void *self, int rate)
2504 {
2505 assert (self);
2506 # if defined (ZMQ_RATE)
2507 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RATE, &rate, sizeof (int));
2508 assert (rc == 0 || zmq_errno () == ETERM);
2509 # endif
2510 }
2511
2512
2513 // --------------------------------------------------------------------------
2514 // Return socket ZMQ_RATE value
2515 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2516
2517 int
2518 zsock_rate (void *self)
2519 {
2520 assert (self);
2521 # if defined (ZMQ_RATE)
2522 int rate;
2523 size_t option_len = sizeof (int);
2524 zmq_getsockopt (zsock_resolve (self), ZMQ_RATE, &rate, &option_len);
2525 return rate;
2526 # else
2527 return 0;
2528 # endif
2529 }
2530
2531 // --------------------------------------------------------------------------
2532 // Set socket ZMQ_RECOVERY_IVL value
2533 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2534
2535 void
2536 zsock_set_recovery_ivl (void *self, int recovery_ivl)
2537 {
2538 assert (self);
2539 # if defined (ZMQ_RECOVERY_IVL)
2540 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &recovery_ivl, sizeof (int));
2541 assert (rc == 0 || zmq_errno () == ETERM);
2542 # endif
2543 }
2544
2545
2546 // --------------------------------------------------------------------------
2547 // Return socket ZMQ_RECOVERY_IVL value
2548 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2549
2550 int
2551 zsock_recovery_ivl (void *self)
2552 {
2553 assert (self);
2554 # if defined (ZMQ_RECOVERY_IVL)
2555 int recovery_ivl;
2556 size_t option_len = sizeof (int);
2557 zmq_getsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len);
2558 return recovery_ivl;
2559 # else
2560 return 0;
2561 # endif
2562 }
2563
2564 // --------------------------------------------------------------------------
2565 // Set socket ZMQ_SNDBUF value
2566 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2567
2568 void
2569 zsock_set_sndbuf (void *self, int sndbuf)
2570 {
2571 assert (self);
2572 # if defined (ZMQ_SNDBUF)
2573 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDBUF, &sndbuf, sizeof (int));
2574 assert (rc == 0 || zmq_errno () == ETERM);
2575 # endif
2576 }
2577
2578
2579 // --------------------------------------------------------------------------
2580 // Return socket ZMQ_SNDBUF value
2581 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2582
2583 int
2584 zsock_sndbuf (void *self)
2585 {
2586 assert (self);
2587 # if defined (ZMQ_SNDBUF)
2588 int sndbuf;
2589 size_t option_len = sizeof (int);
2590 zmq_getsockopt (zsock_resolve (self), ZMQ_SNDBUF, &sndbuf, &option_len);
2591 return sndbuf;
2592 # else
2593 return 0;
2594 # endif
2595 }
2596
2597 // --------------------------------------------------------------------------
2598 // Set socket ZMQ_RCVBUF value
2599 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2600
2601 void
2602 zsock_set_rcvbuf (void *self, int rcvbuf)
2603 {
2604 assert (self);
2605 # if defined (ZMQ_RCVBUF)
2606 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVBUF, &rcvbuf, sizeof (int));
2607 assert (rc == 0 || zmq_errno () == ETERM);
2608 # endif
2609 }
2610
2611
2612 // --------------------------------------------------------------------------
2613 // Return socket ZMQ_RCVBUF value
2614 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2615
2616 int
2617 zsock_rcvbuf (void *self)
2618 {
2619 assert (self);
2620 # if defined (ZMQ_RCVBUF)
2621 int rcvbuf;
2622 size_t option_len = sizeof (int);
2623 zmq_getsockopt (zsock_resolve (self), ZMQ_RCVBUF, &rcvbuf, &option_len);
2624 return rcvbuf;
2625 # else
2626 return 0;
2627 # endif
2628 }
2629
2630 // --------------------------------------------------------------------------
2631 // Set socket ZMQ_LINGER value
2632 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2633
2634 void
2635 zsock_set_linger (void *self, int linger)
2636 {
2637 assert (self);
2638 # if defined (ZMQ_LINGER)
2639 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, sizeof (int));
2640 assert (rc == 0 || zmq_errno () == ETERM);
2641 # endif
2642 }
2643
2644
2645 // --------------------------------------------------------------------------
2646 // Return socket ZMQ_LINGER value
2647 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2648
2649 int
2650 zsock_linger (void *self)
2651 {
2652 assert (self);
2653 # if defined (ZMQ_LINGER)
2654 int linger;
2655 size_t option_len = sizeof (int);
2656 zmq_getsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, &option_len);
2657 return linger;
2658 # else
2659 return 0;
2660 # endif
2661 }
2662
2663 // --------------------------------------------------------------------------
2664 // Set socket ZMQ_RECONNECT_IVL value
2665 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2666
2667 void
2668 zsock_set_reconnect_ivl (void *self, int reconnect_ivl)
2669 {
2670 assert (self);
2671 # if defined (ZMQ_RECONNECT_IVL)
2672 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, sizeof (int));
2673 assert (rc == 0 || zmq_errno () == ETERM);
2674 # endif
2675 }
2676
2677
2678 // --------------------------------------------------------------------------
2679 // Return socket ZMQ_RECONNECT_IVL value
2680 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2681
2682 int
2683 zsock_reconnect_ivl (void *self)
2684 {
2685 assert (self);
2686 # if defined (ZMQ_RECONNECT_IVL)
2687 int reconnect_ivl;
2688 size_t option_len = sizeof (int);
2689 zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, &option_len);
2690 return reconnect_ivl;
2691 # else
2692 return 0;
2693 # endif
2694 }
2695
2696 // --------------------------------------------------------------------------
2697 // Set socket ZMQ_RECONNECT_IVL_MAX value
2698 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2699
2700 void
2701 zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max)
2702 {
2703 assert (self);
2704 # if defined (ZMQ_RECONNECT_IVL_MAX)
2705 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, sizeof (int));
2706 assert (rc == 0 || zmq_errno () == ETERM);
2707 # endif
2708 }
2709
2710
2711 // --------------------------------------------------------------------------
2712 // Return socket ZMQ_RECONNECT_IVL_MAX value
2713 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2714
2715 int
2716 zsock_reconnect_ivl_max (void *self)
2717 {
2718 assert (self);
2719 # if defined (ZMQ_RECONNECT_IVL_MAX)
2720 int reconnect_ivl_max;
2721 size_t option_len = sizeof (int);
2722 zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, &option_len);
2723 return reconnect_ivl_max;
2724 # else
2725 return 0;
2726 # endif
2727 }
2728
2729 // --------------------------------------------------------------------------
2730 // Set socket ZMQ_BACKLOG value
2731 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2732
2733 void
2734 zsock_set_backlog (void *self, int backlog)
2735 {
2736 assert (self);
2737 # if defined (ZMQ_BACKLOG)
2738 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, sizeof (int));
2739 assert (rc == 0 || zmq_errno () == ETERM);
2740 # endif
2741 }
2742
2743
2744 // --------------------------------------------------------------------------
2745 // Return socket ZMQ_BACKLOG value
2746 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2747
2748 int
2749 zsock_backlog (void *self)
2750 {
2751 assert (self);
2752 # if defined (ZMQ_BACKLOG)
2753 int backlog;
2754 size_t option_len = sizeof (int);
2755 zmq_getsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, &option_len);
2756 return backlog;
2757 # else
2758 return 0;
2759 # endif
2760 }
2761
2762 // --------------------------------------------------------------------------
2763 // Set socket ZMQ_MAXMSGSIZE value
2764 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2765
2766 void
2767 zsock_set_maxmsgsize (void *self, int maxmsgsize)
2768 {
2769 assert (self);
2770 # if defined (ZMQ_MAXMSGSIZE)
2771 int64_t value = maxmsgsize;
2772 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MAXMSGSIZE, &value, sizeof (int64_t));
2773 assert (rc == 0 || zmq_errno () == ETERM);
2774 # endif
2775 }
2776
2777
2778 // --------------------------------------------------------------------------
2779 // Return socket ZMQ_MAXMSGSIZE value
2780 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2781
2782 int
2783 zsock_maxmsgsize (void *self)
2784 {
2785 assert (self);
2786 # if defined (ZMQ_MAXMSGSIZE)
2787 int64_t maxmsgsize;
4032 // Return socket ZMQ_RCVMORE value
4033 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
4034
4035 int
4036 zsock_rcvmore (void *self)
4037 {
4038 assert (self);
4039 # if defined (ZMQ_RCVMORE)
4040 int major, minor, patch;
4041 zmq_version (&major, &minor, &patch);
4042 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
4043 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
4044 zsys_error ("zsock rcvmore option not supported by libzmq version %d.%d.%d, "
4045 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
4046 return 0;
4047 }
4048 int64_t rcvmore;
27884049 size_t option_len = sizeof (int64_t);
2789 zmq_getsockopt (zsock_resolve (self), ZMQ_MAXMSGSIZE, &maxmsgsize, &option_len);
2790 return (int) maxmsgsize;
2791 # else
2792 return 0;
2793 # endif
2794 }
2795
2796 // --------------------------------------------------------------------------
2797 // Set socket ZMQ_MULTICAST_HOPS value
2798 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2799
2800 void
2801 zsock_set_multicast_hops (void *self, int multicast_hops)
2802 {
2803 assert (self);
2804 # if defined (ZMQ_MULTICAST_HOPS)
2805 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MULTICAST_HOPS, &multicast_hops, sizeof (int));
2806 assert (rc == 0 || zmq_errno () == ETERM);
2807 # endif
2808 }
2809
2810
2811 // --------------------------------------------------------------------------
2812 // Return socket ZMQ_MULTICAST_HOPS value
2813 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2814
2815 int
2816 zsock_multicast_hops (void *self)
2817 {
2818 assert (self);
2819 # if defined (ZMQ_MULTICAST_HOPS)
2820 int multicast_hops;
2821 size_t option_len = sizeof (int);
2822 zmq_getsockopt (zsock_resolve (self), ZMQ_MULTICAST_HOPS, &multicast_hops, &option_len);
2823 return multicast_hops;
2824 # else
2825 return 0;
2826 # endif
2827 }
2828
2829 // --------------------------------------------------------------------------
2830 // Set socket ZMQ_RCVTIMEO value
2831 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2832
2833 void
2834 zsock_set_rcvtimeo (void *self, int rcvtimeo)
2835 {
2836 assert (self);
2837 # if defined (ZMQ_RCVTIMEO)
2838 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int));
2839 assert (rc == 0 || zmq_errno () == ETERM);
2840 # endif
2841 }
2842
2843
2844 // --------------------------------------------------------------------------
2845 // Return socket ZMQ_RCVTIMEO value
2846 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2847
2848 int
2849 zsock_rcvtimeo (void *self)
2850 {
2851 assert (self);
2852 # if defined (ZMQ_RCVTIMEO)
2853 int rcvtimeo;
2854 size_t option_len = sizeof (int);
2855 zmq_getsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, &option_len);
2856 return rcvtimeo;
2857 # else
2858 return 0;
2859 # endif
2860 }
2861
2862 // --------------------------------------------------------------------------
2863 // Set socket ZMQ_SNDTIMEO value
2864 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2865
2866 void
2867 zsock_set_sndtimeo (void *self, int sndtimeo)
2868 {
2869 assert (self);
2870 # if defined (ZMQ_SNDTIMEO)
2871 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, sizeof (int));
2872 assert (rc == 0 || zmq_errno () == ETERM);
2873 # endif
2874 }
2875
2876
2877 // --------------------------------------------------------------------------
2878 // Return socket ZMQ_SNDTIMEO value
2879 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2880
2881 int
2882 zsock_sndtimeo (void *self)
2883 {
2884 assert (self);
2885 # if defined (ZMQ_SNDTIMEO)
2886 int sndtimeo;
2887 size_t option_len = sizeof (int);
2888 zmq_getsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, &option_len);
2889 return sndtimeo;
2890 # else
2891 return 0;
2892 # endif
2893 }
2894
2895 // --------------------------------------------------------------------------
2896 // Set socket ZMQ_XPUB_VERBOSE value
2897 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2898
2899 void
2900 zsock_set_xpub_verbose (void *self, int xpub_verbose)
2901 {
2902 assert (self);
2903 # if defined (ZMQ_XPUB_VERBOSE)
2904 if (zsock_type (self) != ZMQ_XPUB) {
2905 printf ("ZMQ_XPUB_VERBOSE is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
2906 assert (false);
2907 }
2908 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_XPUB_VERBOSE, &xpub_verbose, sizeof (int));
2909 assert (rc == 0 || zmq_errno () == ETERM);
2910 # endif
2911 }
2912
2913
2914 // --------------------------------------------------------------------------
2915 // Set socket ZMQ_TCP_KEEPALIVE value
2916 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2917
2918 void
2919 zsock_set_tcp_keepalive (void *self, int tcp_keepalive)
2920 {
2921 assert (self);
2922 # if defined (ZMQ_TCP_KEEPALIVE)
2923 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE, &tcp_keepalive, sizeof (int));
2924 assert (rc == 0 || zmq_errno () == ETERM);
2925 # endif
2926 }
2927
2928
2929 // --------------------------------------------------------------------------
2930 // Return socket ZMQ_TCP_KEEPALIVE value
2931 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2932
2933 int
2934 zsock_tcp_keepalive (void *self)
2935 {
2936 assert (self);
2937 # if defined (ZMQ_TCP_KEEPALIVE)
2938 int tcp_keepalive;
2939 size_t option_len = sizeof (int);
2940 zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE, &tcp_keepalive, &option_len);
2941 return tcp_keepalive;
2942 # else
2943 return 0;
2944 # endif
2945 }
2946
2947 // --------------------------------------------------------------------------
2948 // Set socket ZMQ_TCP_KEEPALIVE_IDLE value
2949 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2950
2951 void
2952 zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle)
2953 {
2954 assert (self);
2955 # if defined (ZMQ_TCP_KEEPALIVE_IDLE)
2956 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, sizeof (int));
2957 assert (rc == 0 || zmq_errno () == ETERM);
2958 # endif
2959 }
2960
2961
2962 // --------------------------------------------------------------------------
2963 // Return socket ZMQ_TCP_KEEPALIVE_IDLE value
2964 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2965
2966 int
2967 zsock_tcp_keepalive_idle (void *self)
2968 {
2969 assert (self);
2970 # if defined (ZMQ_TCP_KEEPALIVE_IDLE)
2971 int tcp_keepalive_idle;
2972 size_t option_len = sizeof (int);
2973 zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, &option_len);
2974 return tcp_keepalive_idle;
2975 # else
2976 return 0;
2977 # endif
2978 }
2979
2980 // --------------------------------------------------------------------------
2981 // Set socket ZMQ_TCP_KEEPALIVE_CNT value
2982 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2983
2984 void
2985 zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt)
2986 {
2987 assert (self);
2988 # if defined (ZMQ_TCP_KEEPALIVE_CNT)
2989 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, sizeof (int));
2990 assert (rc == 0 || zmq_errno () == ETERM);
2991 # endif
2992 }
2993
2994
2995 // --------------------------------------------------------------------------
2996 // Return socket ZMQ_TCP_KEEPALIVE_CNT value
2997 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
2998
2999 int
3000 zsock_tcp_keepalive_cnt (void *self)
3001 {
3002 assert (self);
3003 # if defined (ZMQ_TCP_KEEPALIVE_CNT)
3004 int tcp_keepalive_cnt;
3005 size_t option_len = sizeof (int);
3006 zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, &option_len);
3007 return tcp_keepalive_cnt;
3008 # else
3009 return 0;
3010 # endif
3011 }
3012
3013 // --------------------------------------------------------------------------
3014 // Set socket ZMQ_TCP_KEEPALIVE_INTVL value
3015 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3016
3017 void
3018 zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl)
3019 {
3020 assert (self);
3021 # if defined (ZMQ_TCP_KEEPALIVE_INTVL)
3022 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, sizeof (int));
3023 assert (rc == 0 || zmq_errno () == ETERM);
3024 # endif
3025 }
3026
3027
3028 // --------------------------------------------------------------------------
3029 // Return socket ZMQ_TCP_KEEPALIVE_INTVL value
3030 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3031
3032 int
3033 zsock_tcp_keepalive_intvl (void *self)
3034 {
3035 assert (self);
3036 # if defined (ZMQ_TCP_KEEPALIVE_INTVL)
3037 int tcp_keepalive_intvl;
3038 size_t option_len = sizeof (int);
3039 zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, &option_len);
3040 return tcp_keepalive_intvl;
3041 # else
3042 return 0;
3043 # endif
3044 }
3045
3046 // --------------------------------------------------------------------------
3047 // Set socket ZMQ_TCP_ACCEPT_FILTER value
3048 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3049
3050 void
3051 zsock_set_tcp_accept_filter (void *self, const char * tcp_accept_filter)
3052 {
3053 assert (self);
3054 # if defined (ZMQ_TCP_ACCEPT_FILTER)
3055 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, strlen (tcp_accept_filter));
3056 assert (rc == 0 || zmq_errno () == ETERM);
3057 # endif
3058 }
3059
3060
3061 // --------------------------------------------------------------------------
3062 // Return socket ZMQ_TCP_ACCEPT_FILTER value
3063 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3064
3065 char *
3066 zsock_tcp_accept_filter (void *self)
3067 {
3068 assert (self);
3069 # if defined (ZMQ_TCP_ACCEPT_FILTER)
3070 size_t option_len = 255;
3071 char *tcp_accept_filter = (char *) zmalloc (option_len);
3072 zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, &option_len);
3073 return (char *) tcp_accept_filter;
3074 # else
3075 return NULL;
3076 # endif
3077 }
3078
3079 // --------------------------------------------------------------------------
3080 // Return socket ZMQ_RCVMORE value
3081 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3082
3083 int
3084 zsock_rcvmore (void *self)
3085 {
3086 assert (self);
3087 # if defined (ZMQ_RCVMORE)
3088 int rcvmore;
3089 size_t option_len = sizeof (int);
30904050 zmq_getsockopt (zsock_resolve (self), ZMQ_RCVMORE, &rcvmore, &option_len);
3091 return rcvmore;
4051 return (int) rcvmore;
30924052 # else
30934053 return 0;
30944054 # endif
31034063 {
31044064 assert (self);
31054065 # if defined (ZMQ_FD)
4066 int major, minor, patch;
4067 zmq_version (&major, &minor, &patch);
4068 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
4069 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
4070 zsys_error ("zsock fd option not supported by libzmq version %d.%d.%d, "
4071 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
4072 return 0;
4073 }
31064074 SOCKET fd;
31074075 size_t option_len = sizeof (SOCKET);
31084076 zmq_getsockopt (zsock_resolve (self), ZMQ_FD, &fd, &option_len);
31214089 {
31224090 assert (self);
31234091 # if defined (ZMQ_EVENTS)
3124 int events;
3125 size_t option_len = sizeof (int);
3126 zmq_getsockopt (zsock_resolve (self), ZMQ_EVENTS, &events, &option_len);
3127 return events;
3128 # else
3129 return 0;
3130 # endif
3131 }
3132
3133 // --------------------------------------------------------------------------
3134 // Return socket ZMQ_LAST_ENDPOINT value
3135 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3136
3137 char *
3138 zsock_last_endpoint (void *self)
3139 {
3140 assert (self);
3141 # if defined (ZMQ_LAST_ENDPOINT)
3142 size_t option_len = 255;
3143 char *last_endpoint = (char *) zmalloc (option_len);
3144 zmq_getsockopt (zsock_resolve (self), ZMQ_LAST_ENDPOINT, last_endpoint, &option_len);
3145 return (char *) last_endpoint;
3146 # else
3147 return NULL;
3148 # endif
3149 }
3150
3151 #endif
3152
3153 #if (ZMQ_VERSION_MAJOR == 2)
3154 // --------------------------------------------------------------------------
3155 // Set socket ZMQ_HWM value
3156 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3157
3158 void
3159 zsock_set_hwm (void *self, int hwm)
3160 {
3161 assert (self);
3162 # if defined (ZMQ_HWM)
3163 uint64_t value = hwm;
3164 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_HWM, &value, sizeof (uint64_t));
3165 assert (rc == 0 || zmq_errno () == ETERM);
3166 # endif
3167 }
3168
3169
3170 // --------------------------------------------------------------------------
3171 // Return socket ZMQ_HWM value
3172 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3173
3174 int
3175 zsock_hwm (void *self)
3176 {
3177 assert (self);
3178 # if defined (ZMQ_HWM)
3179 uint64_t hwm;
3180 size_t option_len = sizeof (uint64_t);
3181 zmq_getsockopt (zsock_resolve (self), ZMQ_HWM, &hwm, &option_len);
3182 return (int) hwm;
3183 # else
3184 return 0;
3185 # endif
3186 }
3187
3188 // --------------------------------------------------------------------------
3189 // Set socket ZMQ_SWAP value
3190 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3191
3192 void
3193 zsock_set_swap (void *self, int swap)
3194 {
3195 assert (self);
3196 # if defined (ZMQ_SWAP)
3197 int64_t value = swap;
3198 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SWAP, &value, sizeof (int64_t));
3199 assert (rc == 0 || zmq_errno () == ETERM);
3200 # endif
3201 }
3202
3203
3204 // --------------------------------------------------------------------------
3205 // Return socket ZMQ_SWAP value
3206 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3207
3208 int
3209 zsock_swap (void *self)
3210 {
3211 assert (self);
3212 # if defined (ZMQ_SWAP)
3213 int64_t swap;
3214 size_t option_len = sizeof (int64_t);
3215 zmq_getsockopt (zsock_resolve (self), ZMQ_SWAP, &swap, &option_len);
3216 return (int) swap;
3217 # else
3218 return 0;
3219 # endif
3220 }
3221
3222 // --------------------------------------------------------------------------
3223 // Set socket ZMQ_AFFINITY value
3224 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3225
3226 void
3227 zsock_set_affinity (void *self, int affinity)
3228 {
3229 assert (self);
3230 # if defined (ZMQ_AFFINITY)
3231 uint64_t value = affinity;
3232 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_AFFINITY, &value, sizeof (uint64_t));
3233 assert (rc == 0 || zmq_errno () == ETERM);
3234 # endif
3235 }
3236
3237
3238 // --------------------------------------------------------------------------
3239 // Return socket ZMQ_AFFINITY value
3240 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3241
3242 int
3243 zsock_affinity (void *self)
3244 {
3245 assert (self);
3246 # if defined (ZMQ_AFFINITY)
3247 uint64_t affinity;
3248 size_t option_len = sizeof (uint64_t);
3249 zmq_getsockopt (zsock_resolve (self), ZMQ_AFFINITY, &affinity, &option_len);
3250 return (int) affinity;
3251 # else
3252 return 0;
3253 # endif
3254 }
3255
3256 // --------------------------------------------------------------------------
3257 // Set socket ZMQ_IDENTITY value
3258 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3259
3260 void
3261 zsock_set_identity (void *self, const char * identity)
3262 {
3263 assert (self);
3264 # if defined (ZMQ_IDENTITY)
3265 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IDENTITY, identity, strlen (identity));
3266 assert (rc == 0 || zmq_errno () == ETERM);
3267 # endif
3268 }
3269
3270
3271 // --------------------------------------------------------------------------
3272 // Return socket ZMQ_IDENTITY value
3273 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3274
3275 char *
3276 zsock_identity (void *self)
3277 {
3278 assert (self);
3279 # if defined (ZMQ_IDENTITY)
3280 size_t option_len = 255;
3281 char *identity = (char *) zmalloc (option_len);
3282 zmq_getsockopt (zsock_resolve (self), ZMQ_IDENTITY, identity, &option_len);
3283 return (char *) identity;
3284 # else
3285 return NULL;
3286 # endif
3287 }
3288
3289 // --------------------------------------------------------------------------
3290 // Set socket ZMQ_RATE value
3291 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3292
3293 void
3294 zsock_set_rate (void *self, int rate)
3295 {
3296 assert (self);
3297 # if defined (ZMQ_RATE)
3298 int64_t value = rate;
3299 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RATE, &value, sizeof (int64_t));
3300 assert (rc == 0 || zmq_errno () == ETERM);
3301 # endif
3302 }
3303
3304
3305 // --------------------------------------------------------------------------
3306 // Return socket ZMQ_RATE value
3307 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3308
3309 int
3310 zsock_rate (void *self)
3311 {
3312 assert (self);
3313 # if defined (ZMQ_RATE)
3314 int64_t rate;
3315 size_t option_len = sizeof (int64_t);
3316 zmq_getsockopt (zsock_resolve (self), ZMQ_RATE, &rate, &option_len);
3317 return (int) rate;
3318 # else
3319 return 0;
3320 # endif
3321 }
3322
3323 // --------------------------------------------------------------------------
3324 // Set socket ZMQ_RECOVERY_IVL value
3325 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3326
3327 void
3328 zsock_set_recovery_ivl (void *self, int recovery_ivl)
3329 {
3330 assert (self);
3331 # if defined (ZMQ_RECOVERY_IVL)
3332 int64_t value = recovery_ivl;
3333 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &value, sizeof (int64_t));
3334 assert (rc == 0 || zmq_errno () == ETERM);
3335 # endif
3336 }
3337
3338
3339 // --------------------------------------------------------------------------
3340 // Return socket ZMQ_RECOVERY_IVL value
3341 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3342
3343 int
3344 zsock_recovery_ivl (void *self)
3345 {
3346 assert (self);
3347 # if defined (ZMQ_RECOVERY_IVL)
3348 int64_t recovery_ivl;
3349 size_t option_len = sizeof (int64_t);
3350 zmq_getsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len);
3351 return (int) recovery_ivl;
3352 # else
3353 return 0;
3354 # endif
3355 }
3356
3357 // --------------------------------------------------------------------------
3358 // Set socket ZMQ_RECOVERY_IVL_MSEC value
3359 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3360
3361 void
3362 zsock_set_recovery_ivl_msec (void *self, int recovery_ivl_msec)
3363 {
3364 assert (self);
3365 # if defined (ZMQ_RECOVERY_IVL_MSEC)
3366 int64_t value = recovery_ivl_msec;
3367 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL_MSEC, &value, sizeof (int64_t));
3368 assert (rc == 0 || zmq_errno () == ETERM);
3369 # endif
3370 }
3371
3372
3373 // --------------------------------------------------------------------------
3374 // Return socket ZMQ_RECOVERY_IVL_MSEC value
3375 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3376
3377 int
3378 zsock_recovery_ivl_msec (void *self)
3379 {
3380 assert (self);
3381 # if defined (ZMQ_RECOVERY_IVL_MSEC)
3382 int64_t recovery_ivl_msec;
3383 size_t option_len = sizeof (int64_t);
3384 zmq_getsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL_MSEC, &recovery_ivl_msec, &option_len);
3385 return (int) recovery_ivl_msec;
3386 # else
3387 return 0;
3388 # endif
3389 }
3390
3391 // --------------------------------------------------------------------------
3392 // Set socket ZMQ_MCAST_LOOP value
3393 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3394
3395 void
3396 zsock_set_mcast_loop (void *self, int mcast_loop)
3397 {
3398 assert (self);
3399 # if defined (ZMQ_MCAST_LOOP)
3400 int64_t value = mcast_loop;
3401 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MCAST_LOOP, &value, sizeof (int64_t));
3402 assert (rc == 0 || zmq_errno () == ETERM);
3403 # endif
3404 }
3405
3406
3407 // --------------------------------------------------------------------------
3408 // Return socket ZMQ_MCAST_LOOP value
3409 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3410
3411 int
3412 zsock_mcast_loop (void *self)
3413 {
3414 assert (self);
3415 # if defined (ZMQ_MCAST_LOOP)
3416 int64_t mcast_loop;
3417 size_t option_len = sizeof (int64_t);
3418 zmq_getsockopt (zsock_resolve (self), ZMQ_MCAST_LOOP, &mcast_loop, &option_len);
3419 return (int) mcast_loop;
3420 # else
3421 return 0;
3422 # endif
3423 }
3424
3425 # if (ZMQ_VERSION_MINOR == 2)
3426 // --------------------------------------------------------------------------
3427 // Set socket ZMQ_RCVTIMEO value
3428 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3429
3430 void
3431 zsock_set_rcvtimeo (void *self, int rcvtimeo)
3432 {
3433 assert (self);
3434 # if defined (ZMQ_RCVTIMEO)
3435 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int));
3436 assert (rc == 0 || zmq_errno () == ETERM);
3437 # endif
3438 }
3439
3440
3441 // --------------------------------------------------------------------------
3442 // Return socket ZMQ_RCVTIMEO value
3443 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3444
3445 int
3446 zsock_rcvtimeo (void *self)
3447 {
3448 assert (self);
3449 # if defined (ZMQ_RCVTIMEO)
3450 int rcvtimeo;
3451 size_t option_len = sizeof (int);
3452 zmq_getsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, &option_len);
3453 return rcvtimeo;
3454 # else
3455 return 0;
3456 # endif
3457 }
3458
3459 # endif
3460 # if (ZMQ_VERSION_MINOR == 2)
3461 // --------------------------------------------------------------------------
3462 // Set socket ZMQ_SNDTIMEO value
3463 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3464
3465 void
3466 zsock_set_sndtimeo (void *self, int sndtimeo)
3467 {
3468 assert (self);
3469 # if defined (ZMQ_SNDTIMEO)
3470 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, sizeof (int));
3471 assert (rc == 0 || zmq_errno () == ETERM);
3472 # endif
3473 }
3474
3475
3476 // --------------------------------------------------------------------------
3477 // Return socket ZMQ_SNDTIMEO value
3478 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3479
3480 int
3481 zsock_sndtimeo (void *self)
3482 {
3483 assert (self);
3484 # if defined (ZMQ_SNDTIMEO)
3485 int sndtimeo;
3486 size_t option_len = sizeof (int);
3487 zmq_getsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, &option_len);
3488 return sndtimeo;
3489 # else
3490 return 0;
3491 # endif
3492 }
3493
3494 # endif
3495 // --------------------------------------------------------------------------
3496 // Set socket ZMQ_SNDBUF value
3497 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3498
3499 void
3500 zsock_set_sndbuf (void *self, int sndbuf)
3501 {
3502 assert (self);
3503 # if defined (ZMQ_SNDBUF)
3504 uint64_t value = sndbuf;
3505 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDBUF, &value, sizeof (uint64_t));
3506 assert (rc == 0 || zmq_errno () == ETERM);
3507 # endif
3508 }
3509
3510
3511 // --------------------------------------------------------------------------
3512 // Return socket ZMQ_SNDBUF value
3513 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3514
3515 int
3516 zsock_sndbuf (void *self)
3517 {
3518 assert (self);
3519 # if defined (ZMQ_SNDBUF)
3520 uint64_t sndbuf;
3521 size_t option_len = sizeof (uint64_t);
3522 zmq_getsockopt (zsock_resolve (self), ZMQ_SNDBUF, &sndbuf, &option_len);
3523 return (int) sndbuf;
3524 # else
3525 return 0;
3526 # endif
3527 }
3528
3529 // --------------------------------------------------------------------------
3530 // Set socket ZMQ_RCVBUF value
3531 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3532
3533 void
3534 zsock_set_rcvbuf (void *self, int rcvbuf)
3535 {
3536 assert (self);
3537 # if defined (ZMQ_RCVBUF)
3538 uint64_t value = rcvbuf;
3539 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVBUF, &value, sizeof (uint64_t));
3540 assert (rc == 0 || zmq_errno () == ETERM);
3541 # endif
3542 }
3543
3544
3545 // --------------------------------------------------------------------------
3546 // Return socket ZMQ_RCVBUF value
3547 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3548
3549 int
3550 zsock_rcvbuf (void *self)
3551 {
3552 assert (self);
3553 # if defined (ZMQ_RCVBUF)
3554 uint64_t rcvbuf;
3555 size_t option_len = sizeof (uint64_t);
3556 zmq_getsockopt (zsock_resolve (self), ZMQ_RCVBUF, &rcvbuf, &option_len);
3557 return (int) rcvbuf;
3558 # else
3559 return 0;
3560 # endif
3561 }
3562
3563 // --------------------------------------------------------------------------
3564 // Set socket ZMQ_LINGER value
3565 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3566
3567 void
3568 zsock_set_linger (void *self, int linger)
3569 {
3570 assert (self);
3571 # if defined (ZMQ_LINGER)
3572 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, sizeof (int));
3573 assert (rc == 0 || zmq_errno () == ETERM);
3574 # endif
3575 }
3576
3577
3578 // --------------------------------------------------------------------------
3579 // Return socket ZMQ_LINGER value
3580 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3581
3582 int
3583 zsock_linger (void *self)
3584 {
3585 assert (self);
3586 # if defined (ZMQ_LINGER)
3587 int linger;
3588 size_t option_len = sizeof (int);
3589 zmq_getsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, &option_len);
3590 return linger;
3591 # else
3592 return 0;
3593 # endif
3594 }
3595
3596 // --------------------------------------------------------------------------
3597 // Set socket ZMQ_RECONNECT_IVL value
3598 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3599
3600 void
3601 zsock_set_reconnect_ivl (void *self, int reconnect_ivl)
3602 {
3603 assert (self);
3604 # if defined (ZMQ_RECONNECT_IVL)
3605 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, sizeof (int));
3606 assert (rc == 0 || zmq_errno () == ETERM);
3607 # endif
3608 }
3609
3610
3611 // --------------------------------------------------------------------------
3612 // Return socket ZMQ_RECONNECT_IVL value
3613 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3614
3615 int
3616 zsock_reconnect_ivl (void *self)
3617 {
3618 assert (self);
3619 # if defined (ZMQ_RECONNECT_IVL)
3620 int reconnect_ivl;
3621 size_t option_len = sizeof (int);
3622 zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, &option_len);
3623 return reconnect_ivl;
3624 # else
3625 return 0;
3626 # endif
3627 }
3628
3629 // --------------------------------------------------------------------------
3630 // Set socket ZMQ_RECONNECT_IVL_MAX value
3631 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3632
3633 void
3634 zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max)
3635 {
3636 assert (self);
3637 # if defined (ZMQ_RECONNECT_IVL_MAX)
3638 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, sizeof (int));
3639 assert (rc == 0 || zmq_errno () == ETERM);
3640 # endif
3641 }
3642
3643
3644 // --------------------------------------------------------------------------
3645 // Return socket ZMQ_RECONNECT_IVL_MAX value
3646 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3647
3648 int
3649 zsock_reconnect_ivl_max (void *self)
3650 {
3651 assert (self);
3652 # if defined (ZMQ_RECONNECT_IVL_MAX)
3653 int reconnect_ivl_max;
3654 size_t option_len = sizeof (int);
3655 zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, &option_len);
3656 return reconnect_ivl_max;
3657 # else
3658 return 0;
3659 # endif
3660 }
3661
3662 // --------------------------------------------------------------------------
3663 // Set socket ZMQ_BACKLOG value
3664 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3665
3666 void
3667 zsock_set_backlog (void *self, int backlog)
3668 {
3669 assert (self);
3670 # if defined (ZMQ_BACKLOG)
3671 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, sizeof (int));
3672 assert (rc == 0 || zmq_errno () == ETERM);
3673 # endif
3674 }
3675
3676
3677 // --------------------------------------------------------------------------
3678 // Return socket ZMQ_BACKLOG value
3679 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3680
3681 int
3682 zsock_backlog (void *self)
3683 {
3684 assert (self);
3685 # if defined (ZMQ_BACKLOG)
3686 int backlog;
3687 size_t option_len = sizeof (int);
3688 zmq_getsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, &option_len);
3689 return backlog;
3690 # else
3691 return 0;
3692 # endif
3693 }
3694
3695 // --------------------------------------------------------------------------
3696 // Set socket ZMQ_SUBSCRIBE value
3697 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3698
3699 void
3700 zsock_set_subscribe (void *self, const char * subscribe)
3701 {
3702 assert (self);
3703 # if defined (ZMQ_SUBSCRIBE)
3704 if (zsock_type (self) != ZMQ_SUB) {
3705 printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
3706 assert (false);
3707 }
3708 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SUBSCRIBE, subscribe, strlen (subscribe));
3709 assert (rc == 0 || zmq_errno () == ETERM);
3710 # endif
3711 }
3712
3713
3714 // --------------------------------------------------------------------------
3715 // Set socket ZMQ_UNSUBSCRIBE value
3716 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3717
3718 void
3719 zsock_set_unsubscribe (void *self, const char * unsubscribe)
3720 {
3721 assert (self);
3722 # if defined (ZMQ_UNSUBSCRIBE)
3723 if (zsock_type (self) != ZMQ_SUB) {
3724 printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self)));
3725 assert (false);
3726 }
3727 int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_UNSUBSCRIBE, unsubscribe, strlen (unsubscribe));
3728 assert (rc == 0 || zmq_errno () == ETERM);
3729 # endif
3730 }
3731
3732
3733 // --------------------------------------------------------------------------
3734 // Return socket ZMQ_TYPE value
3735 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3736
3737 int
3738 zsock_type (void *self)
3739 {
3740 assert (self);
3741 # if defined (ZMQ_TYPE)
3742 int type;
3743 size_t option_len = sizeof (int);
3744 zmq_getsockopt (zsock_resolve (self), ZMQ_TYPE, &type, &option_len);
3745 return type;
3746 # else
3747 return 0;
3748 # endif
3749 }
3750
3751 // --------------------------------------------------------------------------
3752 // Return socket ZMQ_RCVMORE value
3753 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3754
3755 int
3756 zsock_rcvmore (void *self)
3757 {
3758 assert (self);
3759 # if defined (ZMQ_RCVMORE)
3760 int64_t rcvmore;
3761 size_t option_len = sizeof (int64_t);
3762 zmq_getsockopt (zsock_resolve (self), ZMQ_RCVMORE, &rcvmore, &option_len);
3763 return (int) rcvmore;
3764 # else
3765 return 0;
3766 # endif
3767 }
3768
3769 // --------------------------------------------------------------------------
3770 // Return socket ZMQ_FD value
3771 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3772
3773 SOCKET
3774 zsock_fd (void *self)
3775 {
3776 assert (self);
3777 # if defined (ZMQ_FD)
3778 SOCKET fd;
3779 size_t option_len = sizeof (SOCKET);
3780 zmq_getsockopt (zsock_resolve (self), ZMQ_FD, &fd, &option_len);
3781 return fd;
3782 # else
3783 return 0;
3784 # endif
3785 }
3786
3787 // --------------------------------------------------------------------------
3788 // Return socket ZMQ_EVENTS value
3789 // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START ***
3790
3791 int
3792 zsock_events (void *self)
3793 {
3794 assert (self);
3795 # if defined (ZMQ_EVENTS)
4092 int major, minor, patch;
4093 zmq_version (&major, &minor, &patch);
4094 if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)
4095 || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) {
4096 zsys_error ("zsock events option not supported by libzmq version %d.%d.%d, "
4097 "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL);
4098 return 0;
4099 }
37964100 uint32_t events;
37974101 size_t option_len = sizeof (uint32_t);
37984102 zmq_getsockopt (zsock_resolve (self), ZMQ_EVENTS, &events, &option_len);
38154119
38164120 // @selftest
38174121 zsock_t *self;
3818 #if (ZMQ_VERSION_MAJOR == 4)
4122 #if (ZMQ_VERSION_MAJOR >= 4)
4123 # if (ZMQ_VERSION_MINOR >= 2)
38194124 # if defined (ZMQ_HEARTBEAT_IVL)
38204125 self = zsock_new (ZMQ_DEALER);
38214126 assert (self);
39104215 zsock_multicast_maxtpdu (self);
39114216 zsock_destroy (&self);
39124217 # endif
4218 # endif
4219 #endif
4220
4221 #if (ZMQ_VERSION_MAJOR >= 4)
4222 # if (ZMQ_VERSION_MINOR >= 1)
39134223 # if defined (ZMQ_TOS)
39144224 self = zsock_new (ZMQ_DEALER);
39154225 assert (self);
39534263 zsock_set_xpub_nodrop (self, 1);
39544264 zsock_destroy (&self);
39554265 # endif
4266 # endif
4267 #endif
4268
4269 #if (ZMQ_VERSION_MAJOR >= 4)
39564270 # if defined (ZMQ_ROUTER_MANDATORY)
39574271 self = zsock_new (ZMQ_ROUTER);
39584272 assert (self);
40404354 zsock_immediate (self);
40414355 zsock_destroy (&self);
40424356 # endif
4043 # if defined (ZMQ_ROUTER_RAW)
4044 self = zsock_new (ZMQ_ROUTER);
4045 assert (self);
4046 zsock_set_router_raw (self, 1);
4047 zsock_destroy (&self);
4048 # endif
4049 # if defined (ZMQ_IPV4ONLY)
4050 self = zsock_new (ZMQ_SUB);
4051 assert (self);
4052 zsock_set_ipv4only (self, 1);
4053 assert (zsock_ipv4only (self) == 1);
4054 zsock_ipv4only (self);
4055 zsock_destroy (&self);
4056 # endif
4057 # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT)
4058 self = zsock_new (ZMQ_PUB);
4059 assert (self);
4060 zsock_set_delay_attach_on_connect (self, 1);
4061 zsock_destroy (&self);
4062 # endif
4357 #endif
4358
4359 #if (ZMQ_VERSION_MAJOR >= 3)
40634360 # if defined (ZMQ_TYPE)
40644361 self = zsock_new (ZMQ_SUB);
40654362 assert (self);
42804577 free (last_endpoint);
42814578 zsock_destroy (&self);
42824579 # endif
4283 #endif
4284
4285 #if (ZMQ_VERSION_MAJOR == 3)
42864580 # if defined (ZMQ_ROUTER_RAW)
42874581 self = zsock_new (ZMQ_ROUTER);
42884582 assert (self);
43034597 zsock_set_delay_attach_on_connect (self, 1);
43044598 zsock_destroy (&self);
43054599 # endif
4306 # if defined (ZMQ_TYPE)
4307 self = zsock_new (ZMQ_SUB);
4308 assert (self);
4309 zsock_type (self);
4310 zsock_destroy (&self);
4311 # endif
4312 # if defined (ZMQ_SNDHWM)
4313 self = zsock_new (ZMQ_PUB);
4314 assert (self);
4315 zsock_set_sndhwm (self, 1);
4316 assert (zsock_sndhwm (self) == 1);
4317 zsock_sndhwm (self);
4318 zsock_destroy (&self);
4319 # endif
4320 # if defined (ZMQ_RCVHWM)
4321 self = zsock_new (ZMQ_SUB);
4322 assert (self);
4323 zsock_set_rcvhwm (self, 1);
4324 assert (zsock_rcvhwm (self) == 1);
4325 zsock_rcvhwm (self);
4600 #endif
4601
4602 #if (ZMQ_VERSION_MAJOR >= 2) && (ZMQ_VERSION_MAJOR < 3)
4603 # if defined (ZMQ_HWM)
4604 self = zsock_new (ZMQ_SUB);
4605 assert (self);
4606 zsock_set_hwm (self, 1);
4607 assert (zsock_hwm (self) == 1);
4608 zsock_hwm (self);
4609 zsock_destroy (&self);
4610 # endif
4611 # if defined (ZMQ_SWAP)
4612 self = zsock_new (ZMQ_SUB);
4613 assert (self);
4614 zsock_set_swap (self, 1);
4615 assert (zsock_swap (self) == 1);
4616 zsock_swap (self);
43264617 zsock_destroy (&self);
43274618 # endif
43284619 # if defined (ZMQ_AFFINITY)
43334624 zsock_affinity (self);
43344625 zsock_destroy (&self);
43354626 # endif
4336 # if defined (ZMQ_SUBSCRIBE)
4337 self = zsock_new (ZMQ_SUB);
4338 assert (self);
4339 zsock_set_subscribe (self, "test");
4340 zsock_destroy (&self);
4341 # endif
4342 # if defined (ZMQ_UNSUBSCRIBE)
4343 self = zsock_new (ZMQ_SUB);
4344 assert (self);
4345 zsock_set_unsubscribe (self, "test");
4346 zsock_destroy (&self);
4347 # endif
43484627 # if defined (ZMQ_IDENTITY)
4349 self = zsock_new (ZMQ_DEALER);
4628 self = zsock_new (ZMQ_SUB);
43504629 assert (self);
43514630 zsock_set_identity (self, "test");
43524631 char *identity = zsock_identity (self);
43704649 zsock_recovery_ivl (self);
43714650 zsock_destroy (&self);
43724651 # endif
4652 # if defined (ZMQ_RECOVERY_IVL_MSEC)
4653 self = zsock_new (ZMQ_SUB);
4654 assert (self);
4655 zsock_set_recovery_ivl_msec (self, 1);
4656 assert (zsock_recovery_ivl_msec (self) == 1);
4657 zsock_recovery_ivl_msec (self);
4658 zsock_destroy (&self);
4659 # endif
4660 # if defined (ZMQ_MCAST_LOOP)
4661 self = zsock_new (ZMQ_SUB);
4662 assert (self);
4663 zsock_set_mcast_loop (self, 1);
4664 assert (zsock_mcast_loop (self) == 1);
4665 zsock_mcast_loop (self);
4666 zsock_destroy (&self);
4667 # endif
4668 # if defined (ZMQ_RCVTIMEO)
4669 self = zsock_new (ZMQ_SUB);
4670 assert (self);
4671 zsock_set_rcvtimeo (self, 1);
4672 assert (zsock_rcvtimeo (self) == 1);
4673 zsock_rcvtimeo (self);
4674 zsock_destroy (&self);
4675 # endif
4676 # if defined (ZMQ_SNDTIMEO)
4677 self = zsock_new (ZMQ_SUB);
4678 assert (self);
4679 zsock_set_sndtimeo (self, 1);
4680 assert (zsock_sndtimeo (self) == 1);
4681 zsock_sndtimeo (self);
4682 zsock_destroy (&self);
4683 # endif
43734684 # if defined (ZMQ_SNDBUF)
4374 self = zsock_new (ZMQ_PUB);
4685 self = zsock_new (ZMQ_SUB);
43754686 assert (self);
43764687 zsock_set_sndbuf (self, 1);
43774688 assert (zsock_sndbuf (self) == 1);
44184729 zsock_backlog (self);
44194730 zsock_destroy (&self);
44204731 # endif
4421 # if defined (ZMQ_MAXMSGSIZE)
4422 self = zsock_new (ZMQ_SUB);
4423 assert (self);
4424 zsock_set_maxmsgsize (self, 1);
4425 assert (zsock_maxmsgsize (self) == 1);
4426 zsock_maxmsgsize (self);
4427 zsock_destroy (&self);
4428 # endif
4429 # if defined (ZMQ_MULTICAST_HOPS)
4430 self = zsock_new (ZMQ_SUB);
4431 assert (self);
4432 zsock_set_multicast_hops (self, 1);
4433 assert (zsock_multicast_hops (self) == 1);
4434 zsock_multicast_hops (self);
4435 zsock_destroy (&self);
4436 # endif
4437 # if defined (ZMQ_RCVTIMEO)
4438 self = zsock_new (ZMQ_SUB);
4439 assert (self);
4440 zsock_set_rcvtimeo (self, 1);
4441 assert (zsock_rcvtimeo (self) == 1);
4442 zsock_rcvtimeo (self);
4443 zsock_destroy (&self);
4444 # endif
4445 # if defined (ZMQ_SNDTIMEO)
4446 self = zsock_new (ZMQ_SUB);
4447 assert (self);
4448 zsock_set_sndtimeo (self, 1);
4449 assert (zsock_sndtimeo (self) == 1);
4450 zsock_sndtimeo (self);
4451 zsock_destroy (&self);
4452 # endif
4453 # if defined (ZMQ_XPUB_VERBOSE)
4454 self = zsock_new (ZMQ_XPUB);
4455 assert (self);
4456 zsock_set_xpub_verbose (self, 1);
4457 zsock_destroy (&self);
4458 # endif
4459 # if defined (ZMQ_TCP_KEEPALIVE)
4460 self = zsock_new (ZMQ_SUB);
4461 assert (self);
4462 zsock_set_tcp_keepalive (self, 1);
4463 assert (zsock_tcp_keepalive (self) == 1);
4464 zsock_tcp_keepalive (self);
4465 zsock_destroy (&self);
4466 # endif
4467 # if defined (ZMQ_TCP_KEEPALIVE_IDLE)
4468 self = zsock_new (ZMQ_SUB);
4469 assert (self);
4470 zsock_set_tcp_keepalive_idle (self, 1);
4471 assert (zsock_tcp_keepalive_idle (self) == 1);
4472 zsock_tcp_keepalive_idle (self);
4473 zsock_destroy (&self);
4474 # endif
4475 # if defined (ZMQ_TCP_KEEPALIVE_CNT)
4476 self = zsock_new (ZMQ_SUB);
4477 assert (self);
4478 zsock_set_tcp_keepalive_cnt (self, 1);
4479 assert (zsock_tcp_keepalive_cnt (self) == 1);
4480 zsock_tcp_keepalive_cnt (self);
4481 zsock_destroy (&self);
4482 # endif
4483 # if defined (ZMQ_TCP_KEEPALIVE_INTVL)
4484 self = zsock_new (ZMQ_SUB);
4485 assert (self);
4486 zsock_set_tcp_keepalive_intvl (self, 1);
4487 assert (zsock_tcp_keepalive_intvl (self) == 1);
4488 zsock_tcp_keepalive_intvl (self);
4489 zsock_destroy (&self);
4490 # endif
4491 # if defined (ZMQ_TCP_ACCEPT_FILTER)
4492 self = zsock_new (ZMQ_SUB);
4493 assert (self);
4494 zsock_set_tcp_accept_filter (self, "127.0.0.1");
4495 char *tcp_accept_filter = zsock_tcp_accept_filter (self);
4496 assert (tcp_accept_filter);
4497 free (tcp_accept_filter);
4732 # if defined (ZMQ_SUBSCRIBE)
4733 self = zsock_new (ZMQ_SUB);
4734 assert (self);
4735 zsock_set_subscribe (self, "test");
4736 zsock_destroy (&self);
4737 # endif
4738 # if defined (ZMQ_UNSUBSCRIBE)
4739 self = zsock_new (ZMQ_SUB);
4740 assert (self);
4741 zsock_set_unsubscribe (self, "test");
4742 zsock_destroy (&self);
4743 # endif
4744 # if defined (ZMQ_TYPE)
4745 self = zsock_new (ZMQ_SUB);
4746 assert (self);
4747 zsock_type (self);
44984748 zsock_destroy (&self);
44994749 # endif
45004750 # if defined (ZMQ_RCVMORE)
45154765 zsock_events (self);
45164766 zsock_destroy (&self);
45174767 # endif
4518 # if defined (ZMQ_LAST_ENDPOINT)
4519 self = zsock_new (ZMQ_SUB);
4520 assert (self);
4521 char *last_endpoint = zsock_last_endpoint (self);
4522 assert (last_endpoint);
4523 free (last_endpoint);
4524 zsock_destroy (&self);
4525 # endif
45264768 #endif
45274769
4528 #if (ZMQ_VERSION_MAJOR == 2)
4529 # if defined (ZMQ_HWM)
4530 self = zsock_new (ZMQ_SUB);
4531 assert (self);
4532 zsock_set_hwm (self, 1);
4533 assert (zsock_hwm (self) == 1);
4534 zsock_hwm (self);
4535 zsock_destroy (&self);
4536 # endif
4537 # if defined (ZMQ_SWAP)
4538 self = zsock_new (ZMQ_SUB);
4539 assert (self);
4540 zsock_set_swap (self, 1);
4541 assert (zsock_swap (self) == 1);
4542 zsock_swap (self);
4543 zsock_destroy (&self);
4544 # endif
4545 # if defined (ZMQ_AFFINITY)
4546 self = zsock_new (ZMQ_SUB);
4547 assert (self);
4548 zsock_set_affinity (self, 1);
4549 assert (zsock_affinity (self) == 1);
4550 zsock_affinity (self);
4551 zsock_destroy (&self);
4552 # endif
4553 # if defined (ZMQ_IDENTITY)
4554 self = zsock_new (ZMQ_SUB);
4555 assert (self);
4556 zsock_set_identity (self, "test");
4557 char *identity = zsock_identity (self);
4558 assert (identity);
4559 free (identity);
4560 zsock_destroy (&self);
4561 # endif
4562 # if defined (ZMQ_RATE)
4563 self = zsock_new (ZMQ_SUB);
4564 assert (self);
4565 zsock_set_rate (self, 1);
4566 assert (zsock_rate (self) == 1);
4567 zsock_rate (self);
4568 zsock_destroy (&self);
4569 # endif
4570 # if defined (ZMQ_RECOVERY_IVL)
4571 self = zsock_new (ZMQ_SUB);
4572 assert (self);
4573 zsock_set_recovery_ivl (self, 1);
4574 assert (zsock_recovery_ivl (self) == 1);
4575 zsock_recovery_ivl (self);
4576 zsock_destroy (&self);
4577 # endif
4578 # if defined (ZMQ_RECOVERY_IVL_MSEC)
4579 self = zsock_new (ZMQ_SUB);
4580 assert (self);
4581 zsock_set_recovery_ivl_msec (self, 1);
4582 assert (zsock_recovery_ivl_msec (self) == 1);
4583 zsock_recovery_ivl_msec (self);
4584 zsock_destroy (&self);
4585 # endif
4586 # if defined (ZMQ_MCAST_LOOP)
4587 self = zsock_new (ZMQ_SUB);
4588 assert (self);
4589 zsock_set_mcast_loop (self, 1);
4590 assert (zsock_mcast_loop (self) == 1);
4591 zsock_mcast_loop (self);
4592 zsock_destroy (&self);
4593 # endif
4594 # if (ZMQ_VERSION_MINOR == 2)
4595 # if defined (ZMQ_RCVTIMEO)
4596 self = zsock_new (ZMQ_SUB);
4597 assert (self);
4598 zsock_set_rcvtimeo (self, 1);
4599 assert (zsock_rcvtimeo (self) == 1);
4600 zsock_rcvtimeo (self);
4601 zsock_destroy (&self);
4602 # endif
4603 # endif
4604 # if (ZMQ_VERSION_MINOR == 2)
4605 # if defined (ZMQ_SNDTIMEO)
4606 self = zsock_new (ZMQ_SUB);
4607 assert (self);
4608 zsock_set_sndtimeo (self, 1);
4609 assert (zsock_sndtimeo (self) == 1);
4610 zsock_sndtimeo (self);
4611 zsock_destroy (&self);
4612 # endif
4613 # endif
4614 # if defined (ZMQ_SNDBUF)
4615 self = zsock_new (ZMQ_SUB);
4616 assert (self);
4617 zsock_set_sndbuf (self, 1);
4618 assert (zsock_sndbuf (self) == 1);
4619 zsock_sndbuf (self);
4620 zsock_destroy (&self);
4621 # endif
4622 # if defined (ZMQ_RCVBUF)
4623 self = zsock_new (ZMQ_SUB);
4624 assert (self);
4625 zsock_set_rcvbuf (self, 1);
4626 assert (zsock_rcvbuf (self) == 1);
4627 zsock_rcvbuf (self);
4628 zsock_destroy (&self);
4629 # endif
4630 # if defined (ZMQ_LINGER)
4631 self = zsock_new (ZMQ_SUB);
4632 assert (self);
4633 zsock_set_linger (self, 1);
4634 assert (zsock_linger (self) == 1);
4635 zsock_linger (self);
4636 zsock_destroy (&self);
4637 # endif
4638 # if defined (ZMQ_RECONNECT_IVL)
4639 self = zsock_new (ZMQ_SUB);
4640 assert (self);
4641 zsock_set_reconnect_ivl (self, 1);
4642 assert (zsock_reconnect_ivl (self) == 1);
4643 zsock_reconnect_ivl (self);
4644 zsock_destroy (&self);
4645 # endif
4646 # if defined (ZMQ_RECONNECT_IVL_MAX)
4647 self = zsock_new (ZMQ_SUB);
4648 assert (self);
4649 zsock_set_reconnect_ivl_max (self, 1);
4650 assert (zsock_reconnect_ivl_max (self) == 1);
4651 zsock_reconnect_ivl_max (self);
4652 zsock_destroy (&self);
4653 # endif
4654 # if defined (ZMQ_BACKLOG)
4655 self = zsock_new (ZMQ_SUB);
4656 assert (self);
4657 zsock_set_backlog (self, 1);
4658 assert (zsock_backlog (self) == 1);
4659 zsock_backlog (self);
4660 zsock_destroy (&self);
4661 # endif
4662 # if defined (ZMQ_SUBSCRIBE)
4663 self = zsock_new (ZMQ_SUB);
4664 assert (self);
4665 zsock_set_subscribe (self, "test");
4666 zsock_destroy (&self);
4667 # endif
4668 # if defined (ZMQ_UNSUBSCRIBE)
4669 self = zsock_new (ZMQ_SUB);
4670 assert (self);
4671 zsock_set_unsubscribe (self, "test");
4672 zsock_destroy (&self);
4673 # endif
4674 # if defined (ZMQ_TYPE)
4675 self = zsock_new (ZMQ_SUB);
4676 assert (self);
4677 zsock_type (self);
4678 zsock_destroy (&self);
4679 # endif
4680 # if defined (ZMQ_RCVMORE)
4681 self = zsock_new (ZMQ_SUB);
4682 assert (self);
4683 zsock_rcvmore (self);
4684 zsock_destroy (&self);
4685 # endif
4686 # if defined (ZMQ_FD)
4687 self = zsock_new (ZMQ_SUB);
4688 assert (self);
4689 zsock_fd (self);
4690 zsock_destroy (&self);
4691 # endif
4692 # if defined (ZMQ_EVENTS)
4693 self = zsock_new (ZMQ_SUB);
4694 assert (self);
4695 zsock_events (self);
4696 zsock_destroy (&self);
4697 # endif
4698 #endif
4699
47004770 // @end
47014771
47024772 printf ("OK\n");
232232 if (zsock_is (dest) && zsock_type (dest) == ZMQ_SERVER)
233233 zmsg_set_routing_id (msg, zsock_routing_id ((zsock_t *) dest));
234234 #endif
235 return zmsg_send (&msg, dest);
235 if (zmsg_send (&msg, dest) < 0) {
236 zmsg_destroy(&msg);
237 return -1;
238 }
239 else
240 return 0;
236241 }
237242
238243
7474 byte buffer [ZUUID_LEN];
7575 uuid_enc_be (&buffer, &uuid);
7676 zuuid_set (self, buffer);
77 #elif defined (__UTYPE_LINUX) || defined (__UTYPE_OSX) || defined (__UTYPE_GNU)
77 #elif defined (__UTYPE_LINUX) || defined (__UTYPE_OSX) || defined (__UTYPE_SUNOS) || defined (__UTYPE_SUNSOLARIS) || defined (__UTYPE_GNU)
7878 uuid_t uuid;
7979 assert (sizeof (uuid) == ZUUID_LEN);
8080 uuid_generate (uuid);
8181 zuuid_set (self, (byte *) uuid);
8282 #else
83 # error "Unknow UNIX TYPE"
83 # error "Unknown UNIX TYPE"
8484 #endif
8585 return self;
8686 }