From 89272e2320d756f2ccbcb6295ba72376179f0564 Mon Sep 17 00:00:00 2001 From: Pieter Hintjens Date: Fri, 20 Sep 2013 18:56:30 +0200 Subject: [PATCH 1/2] Bumped version number for next release, 2.0.1 --- include/czmq.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/czmq.h b/include/czmq.h index 7cd297574..3ca199c92 100644 --- a/include/czmq.h +++ b/include/czmq.h @@ -34,7 +34,7 @@ #define CZMQ_VERSION_MAJOR 2 #define CZMQ_VERSION_MINOR 0 -#define CZMQ_VERSION_PATCH 0 +#define CZMQ_VERSION_PATCH 1 #define CZMQ_MAKE_VERSION(major, minor, patch) \ ((major) * 10000 + (minor) * 100 + (patch)) From 08eeae268d21ba02302aa39a943217d13664fa75 Mon Sep 17 00:00:00 2001 From: Pieter Hintjens Date: Fri, 20 Sep 2013 18:56:59 +0200 Subject: [PATCH 2/2] Updated CZMQ to work with ZeroMQ 4.0 * All socket options as implemented by ZeroMQ/4.0.0 * Removed deprecated zsockopt_set_xxx macros * Added macro capability to scripts/sockopts.gsl to save code duplication --- doc/zcert.txt | 9 +- doc/zcertstore.txt | 8 +- doc/zsys.txt | 16 +- include/zsockopt.h | 249 ++-- model/sockopts.xml | 174 ++- scripts/sockopts.gsl | 66 +- src/zsocket.c | 2 +- src/zsockopt.c | 2843 ++++++++++++++++++++++++++++++------------ 8 files changed, 2294 insertions(+), 1073 deletions(-) diff --git a/doc/zcert.txt b/doc/zcert.txt index d32c03072..6b826b9fc 100644 --- a/doc/zcert.txt +++ b/doc/zcert.txt @@ -47,17 +47,20 @@ CZMQ_EXPORT char * zcert_meta (zcert_t *self, char *name); // Load certificate from file (constructor) +// The filename is treated as a printf format specifier. CZMQ_EXPORT zcert_t * - zcert_load (char *filename); + zcert_load (char *filename, ...); // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret"). +// The filename is treated as a printf format specifier. CZMQ_EXPORT int - zcert_save (zcert_t *self, char *filename); + zcert_save (zcert_t *self, char *filename, ...); // Save public certificate only to file for persistent storage +// The filename is treated as a printf format specifier. CZMQ_EXPORT int - zcert_save_public (zcert_t *self, char *filename); + zcert_save_public (zcert_t *self, char *filename, ...); // Apply certificate to socket, i.e. use for CURVE security on socket. // If certificate was loaded from public file, the secret key will be diff --git a/doc/zcertstore.txt b/doc/zcertstore.txt index 8dab53473..b008c2e29 100644 --- a/doc/zcertstore.txt +++ b/doc/zcertstore.txt @@ -14,10 +14,10 @@ SYNOPSIS // absent, and created later, or modified at any time. The certificate store // is automatically refreshed on any zcertstore_lookup() call. If the // location is specified as NULL, creates a pure-memory store, which you -// can work with by inserting certificates at runtime. - +// can work with by inserting certificates at runtime. The location is +// treated as a printf format. CZMQ_EXPORT zcertstore_t * - zcertstore_new (char *location); + zcertstore_new (char *location, ...); // Destroy a certificate store object in memory. Does not affect anything // stored on disk. @@ -77,7 +77,7 @@ EXAMPLE zsys_dir_create (TESTDIR); // Load certificate store from disk; it will be empty - zcertstore_t *certstore = zcertstore_new (TESTDIR); + zcertstore_t *certstore = zcertstore_new ("%s", TESTDIR); // Create a single new certificate and save to disk zcert_t *cert = zcert_new (); diff --git a/doc/zsys.txt b/doc/zsys.txt index 71780c56a..b388fa070 100644 --- a/doc/zsys.txt +++ b/doc/zsys.txt @@ -55,13 +55,14 @@ CZMQ_EXPORT int CZMQ_EXPORT bool zsys_file_stable (const char *filename); -// Create a file path if it doesn't exit +// Create a file path if it doesn't exist. The file path is treated as a +// printf format. CZMQ_EXPORT int - zsys_dir_create (const char *pathname); + zsys_dir_create (const char *pathname, ...); -// Remove a file path if empty +// Remove a file path if empty; the pathname is treated as printf format. CZMQ_EXPORT int - zsys_dir_delete (const char *pathname); + zsys_dir_delete (const char *pathname, ...); // Set private file creation mode; all files created from here will be // readable/writable by the owner only. @@ -114,6 +115,13 @@ EXAMPLE time_t when = zsys_file_modified ("."); assert (when > 0); + rc = zsys_dir_create ("%s/%s", ".", ".testsys/subdir"); + assert (rc == 0); + when = zsys_file_modified ("./.testsys/subdir"); + assert (when > 0); + rc = zsys_dir_delete ("%s/%s", ".", ".testsys/subdir"); + assert (rc == 0); + char *string = s_vprintf ("%s %02x", "Hello", 16); assert (streq (string, "Hello 10")); free (string); diff --git a/include/zsockopt.h b/include/zsockopt.h index f1f9eb3fc..7f76a449f 100644 --- a/include/zsockopt.h +++ b/include/zsockopt.h @@ -36,8 +36,19 @@ extern "C" { #endif // @interface -#if (ZMQ_VERSION_MAJOR == 3) +#if (ZMQ_VERSION_MAJOR == 4) // Get socket options +CZMQ_EXPORT int zsocket_ipv6 (void *zocket); +CZMQ_EXPORT int zsocket_ipv4only (void *zocket); +CZMQ_EXPORT int zsocket_probe_router (void *zocket); +CZMQ_EXPORT int zsocket_plain_server (void *zocket); +CZMQ_EXPORT char * zsocket_plain_username (void *zocket); +CZMQ_EXPORT char * zsocket_plain_password (void *zocket); +CZMQ_EXPORT int zsocket_curve_server (void *zocket); +CZMQ_EXPORT char * zsocket_curve_publickey (void *zocket); +CZMQ_EXPORT char * zsocket_curve_secretkey (void *zocket); +CZMQ_EXPORT char * zsocket_curve_serverkey (void *zocket); +CZMQ_EXPORT char * zsocket_zap_domain (void *zocket); CZMQ_EXPORT int zsocket_type (void *zocket); CZMQ_EXPORT int zsocket_sndhwm (void *zocket); CZMQ_EXPORT int zsocket_rcvhwm (void *zocket); @@ -55,28 +66,37 @@ CZMQ_EXPORT int zsocket_maxmsgsize (void *zocket); CZMQ_EXPORT int zsocket_multicast_hops (void *zocket); CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket); CZMQ_EXPORT int zsocket_sndtimeo (void *zocket); -CZMQ_EXPORT int zsocket_ipv6 (void *zocket); -CZMQ_EXPORT int zsocket_probe_router (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_idle (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_cnt (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_intvl (void *zocket); CZMQ_EXPORT char * zsocket_tcp_accept_filter (void *zocket); -CZMQ_EXPORT int zsocket_plain_server (void *zocket); -CZMQ_EXPORT char * zsocket_plain_username (void *zocket); -CZMQ_EXPORT char * zsocket_plain_password (void *zocket); -CZMQ_EXPORT int zsocket_curve_server (void *zocket); -CZMQ_EXPORT char * zsocket_curve_publickey (void *zocket); -CZMQ_EXPORT char * zsocket_curve_secretkey (void *zocket); -CZMQ_EXPORT char * zsocket_curve_serverkey (void *zocket); -CZMQ_EXPORT char * zsocket_zap_domain (void *zocket); CZMQ_EXPORT int zsocket_rcvmore (void *zocket); CZMQ_EXPORT int zsocket_fd (void *zocket); CZMQ_EXPORT int zsocket_events (void *zocket); CZMQ_EXPORT char * zsocket_last_endpoint (void *zocket); -CZMQ_EXPORT int zsocket_ipv4only (void *zocket); // Set socket options +CZMQ_EXPORT void zsocket_set_ipv6 (void *zocket, int ipv6); +CZMQ_EXPORT void zsocket_set_immediate (void *zocket, int immediate); +CZMQ_EXPORT void zsocket_set_router_raw (void *zocket, int router_raw); +CZMQ_EXPORT void zsocket_set_ipv4only (void *zocket, int ipv4only); +CZMQ_EXPORT void zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect); +CZMQ_EXPORT void zsocket_set_router_mandatory (void *zocket, int router_mandatory); +CZMQ_EXPORT void zsocket_set_req_relaxed (void *zocket, int req_relaxed); +CZMQ_EXPORT void zsocket_set_req_correlate (void *zocket, int req_correlate); +CZMQ_EXPORT void zsocket_set_conflate (void *zocket, int conflate); +CZMQ_EXPORT void zsocket_set_plain_server (void *zocket, int plain_server); +CZMQ_EXPORT void zsocket_set_plain_username (void *zocket, const char * plain_username); +CZMQ_EXPORT void zsocket_set_plain_password (void *zocket, const char * plain_password); +CZMQ_EXPORT void zsocket_set_curve_server (void *zocket, int curve_server); +CZMQ_EXPORT void zsocket_set_curve_publickey (void *zocket, const char * curve_publickey); +CZMQ_EXPORT void zsocket_set_curve_publickey_bin (void *zocket, const byte *curve_publickey); +CZMQ_EXPORT void zsocket_set_curve_secretkey (void *zocket, const char * curve_secretkey); +CZMQ_EXPORT void zsocket_set_curve_secretkey_bin (void *zocket, const byte *curve_secretkey); +CZMQ_EXPORT void zsocket_set_curve_serverkey (void *zocket, const char * curve_serverkey); +CZMQ_EXPORT void zsocket_set_curve_serverkey_bin (void *zocket, const byte *curve_serverkey); +CZMQ_EXPORT void zsocket_set_zap_domain (void *zocket, const char * zap_domain); CZMQ_EXPORT void zsocket_set_sndhwm (void *zocket, int sndhwm); CZMQ_EXPORT void zsocket_set_rcvhwm (void *zocket, int rcvhwm); CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity); @@ -95,29 +115,80 @@ CZMQ_EXPORT void zsocket_set_maxmsgsize (void *zocket, int maxmsgsize); CZMQ_EXPORT void zsocket_set_multicast_hops (void *zocket, int multicast_hops); CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo); CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo); -CZMQ_EXPORT void zsocket_set_ipv6 (void *zocket, int ipv6); -CZMQ_EXPORT void zsocket_set_immediate (void *zocket, int immediate); -CZMQ_EXPORT void zsocket_set_router_mandatory (void *zocket, int router_mandatory); CZMQ_EXPORT void zsocket_set_xpub_verbose (void *zocket, int xpub_verbose); CZMQ_EXPORT void zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive); CZMQ_EXPORT void zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle); CZMQ_EXPORT void zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt); CZMQ_EXPORT void zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl); CZMQ_EXPORT void zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter); -CZMQ_EXPORT void zsocket_set_plain_server (void *zocket, int plain_server); -CZMQ_EXPORT void zsocket_set_plain_username (void *zocket, const char * plain_username); -CZMQ_EXPORT void zsocket_set_plain_password (void *zocket, const char * plain_password); -CZMQ_EXPORT void zsocket_set_curve_server (void *zocket, int curve_server); -CZMQ_EXPORT void zsocket_set_curve_publickey (void *zocket, const char * curve_publickey); -CZMQ_EXPORT void zsocket_set_curve_publickey_bin (void *zocket, const byte *curve_publickey); -CZMQ_EXPORT void zsocket_set_curve_secretkey (void *zocket, const char * curve_secretkey); -CZMQ_EXPORT void zsocket_set_curve_secretkey_bin (void *zocket, const byte *curve_secretkey); -CZMQ_EXPORT void zsocket_set_curve_serverkey (void *zocket, const char * curve_serverkey); -CZMQ_EXPORT void zsocket_set_curve_serverkey_bin (void *zocket, const byte *curve_serverkey); -CZMQ_EXPORT void zsocket_set_zap_domain (void *zocket, const char * zap_domain); + +// Emulation of widely-used 2.x socket options +CZMQ_EXPORT void zsocket_set_hwm (void *zocket, int hwm); + +// Patch in case we're on older libzmq +#ifndef ZMQ_STREAM +#define ZMQ_STREAM 11 +#endif +#endif + +#if (ZMQ_VERSION_MAJOR == 3) +// Get socket options +CZMQ_EXPORT int zsocket_ipv4only (void *zocket); +CZMQ_EXPORT int zsocket_type (void *zocket); +CZMQ_EXPORT int zsocket_sndhwm (void *zocket); +CZMQ_EXPORT int zsocket_rcvhwm (void *zocket); +CZMQ_EXPORT int zsocket_affinity (void *zocket); +CZMQ_EXPORT char * zsocket_identity (void *zocket); +CZMQ_EXPORT int zsocket_rate (void *zocket); +CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket); +CZMQ_EXPORT int zsocket_sndbuf (void *zocket); +CZMQ_EXPORT int zsocket_rcvbuf (void *zocket); +CZMQ_EXPORT int zsocket_linger (void *zocket); +CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket); +CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket); +CZMQ_EXPORT int zsocket_backlog (void *zocket); +CZMQ_EXPORT int zsocket_maxmsgsize (void *zocket); +CZMQ_EXPORT int zsocket_multicast_hops (void *zocket); +CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket); +CZMQ_EXPORT int zsocket_sndtimeo (void *zocket); +CZMQ_EXPORT int zsocket_tcp_keepalive (void *zocket); +CZMQ_EXPORT int zsocket_tcp_keepalive_idle (void *zocket); +CZMQ_EXPORT int zsocket_tcp_keepalive_cnt (void *zocket); +CZMQ_EXPORT int zsocket_tcp_keepalive_intvl (void *zocket); +CZMQ_EXPORT char * zsocket_tcp_accept_filter (void *zocket); +CZMQ_EXPORT int zsocket_rcvmore (void *zocket); +CZMQ_EXPORT int zsocket_fd (void *zocket); +CZMQ_EXPORT int zsocket_events (void *zocket); +CZMQ_EXPORT char * zsocket_last_endpoint (void *zocket); + +// Set socket options CZMQ_EXPORT void zsocket_set_router_raw (void *zocket, int router_raw); CZMQ_EXPORT void zsocket_set_ipv4only (void *zocket, int ipv4only); CZMQ_EXPORT void zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect); +CZMQ_EXPORT void zsocket_set_sndhwm (void *zocket, int sndhwm); +CZMQ_EXPORT void zsocket_set_rcvhwm (void *zocket, int rcvhwm); +CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity); +CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe); +CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe); +CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity); +CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate); +CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl); +CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf); +CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf); +CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger); +CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl); +CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max); +CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog); +CZMQ_EXPORT void zsocket_set_maxmsgsize (void *zocket, int maxmsgsize); +CZMQ_EXPORT void zsocket_set_multicast_hops (void *zocket, int multicast_hops); +CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo); +CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo); +CZMQ_EXPORT void zsocket_set_xpub_verbose (void *zocket, int xpub_verbose); +CZMQ_EXPORT void zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive); +CZMQ_EXPORT void zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle); +CZMQ_EXPORT void zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt); +CZMQ_EXPORT void zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl); +CZMQ_EXPORT void zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter); // Emulation of widely-used 2.x socket options CZMQ_EXPORT void zsocket_set_hwm (void *zocket, int hwm); @@ -184,132 +255,6 @@ CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe int zsockopt_test (bool verbose); // @end -// Deprecated function names -#if (ZMQ_VERSION_MAJOR == 3) -#define zsockopt_type zsocket_type -#define zsockopt_sndhwm zsocket_sndhwm -#define zsockopt_set_sndhwm zsocket_set_sndhwm -#define zsockopt_rcvhwm zsocket_rcvhwm -#define zsockopt_set_rcvhwm zsocket_set_rcvhwm -#define zsockopt_affinity zsocket_affinity -#define zsockopt_set_affinity zsocket_set_affinity -#define zsockopt_set_subscribe zsocket_set_subscribe -#define zsockopt_set_unsubscribe zsocket_set_unsubscribe -#define zsockopt_identity zsocket_identity -#define zsockopt_set_identity zsocket_set_identity -#define zsockopt_rate zsocket_rate -#define zsockopt_set_rate zsocket_set_rate -#define zsockopt_recovery_ivl zsocket_recovery_ivl -#define zsockopt_set_recovery_ivl zsocket_set_recovery_ivl -#define zsockopt_sndbuf zsocket_sndbuf -#define zsockopt_set_sndbuf zsocket_set_sndbuf -#define zsockopt_rcvbuf zsocket_rcvbuf -#define zsockopt_set_rcvbuf zsocket_set_rcvbuf -#define zsockopt_linger zsocket_linger -#define zsockopt_set_linger zsocket_set_linger -#define zsockopt_reconnect_ivl zsocket_reconnect_ivl -#define zsockopt_set_reconnect_ivl zsocket_set_reconnect_ivl -#define zsockopt_reconnect_ivl_max zsocket_reconnect_ivl_max -#define zsockopt_set_reconnect_ivl_max zsocket_set_reconnect_ivl_max -#define zsockopt_backlog zsocket_backlog -#define zsockopt_set_backlog zsocket_set_backlog -#define zsockopt_maxmsgsize zsocket_maxmsgsize -#define zsockopt_set_maxmsgsize zsocket_set_maxmsgsize -#define zsockopt_multicast_hops zsocket_multicast_hops -#define zsockopt_set_multicast_hops zsocket_set_multicast_hops -#define zsockopt_rcvtimeo zsocket_rcvtimeo -#define zsockopt_set_rcvtimeo zsocket_set_rcvtimeo -#define zsockopt_sndtimeo zsocket_sndtimeo -#define zsockopt_set_sndtimeo zsocket_set_sndtimeo -#define zsockopt_ipv6 zsocket_ipv6 -#define zsockopt_set_ipv6 zsocket_set_ipv6 -#define zsockopt_set_immediate zsocket_set_immediate -#define zsockopt_set_router_mandatory zsocket_set_router_mandatory -#define zsockopt_probe_router zsocket_probe_router -#define zsockopt_set_xpub_verbose zsocket_set_xpub_verbose -#define zsockopt_tcp_keepalive zsocket_tcp_keepalive -#define zsockopt_set_tcp_keepalive zsocket_set_tcp_keepalive -#define zsockopt_tcp_keepalive_idle zsocket_tcp_keepalive_idle -#define zsockopt_set_tcp_keepalive_idle zsocket_set_tcp_keepalive_idle -#define zsockopt_tcp_keepalive_cnt zsocket_tcp_keepalive_cnt -#define zsockopt_set_tcp_keepalive_cnt zsocket_set_tcp_keepalive_cnt -#define zsockopt_tcp_keepalive_intvl zsocket_tcp_keepalive_intvl -#define zsockopt_set_tcp_keepalive_intvl zsocket_set_tcp_keepalive_intvl -#define zsockopt_tcp_accept_filter zsocket_tcp_accept_filter -#define zsockopt_set_tcp_accept_filter zsocket_set_tcp_accept_filter -#define zsockopt_plain_server zsocket_plain_server -#define zsockopt_set_plain_server zsocket_set_plain_server -#define zsockopt_plain_username zsocket_plain_username -#define zsockopt_set_plain_username zsocket_set_plain_username -#define zsockopt_plain_password zsocket_plain_password -#define zsockopt_set_plain_password zsocket_set_plain_password -#define zsockopt_curve_server zsocket_curve_server -#define zsockopt_set_curve_server zsocket_set_curve_server -#define zsockopt_curve_publickey zsocket_curve_publickey -#define zsockopt_set_curve_publickey zsocket_set_curve_publickey -#define zsockopt_curve_secretkey zsocket_curve_secretkey -#define zsockopt_set_curve_secretkey zsocket_set_curve_secretkey -#define zsockopt_curve_serverkey zsocket_curve_serverkey -#define zsockopt_set_curve_serverkey zsocket_set_curve_serverkey -#define zsockopt_zap_domain zsocket_zap_domain -#define zsockopt_set_zap_domain zsocket_set_zap_domain -#define zsockopt_rcvmore zsocket_rcvmore -#define zsockopt_fd zsocket_fd -#define zsockopt_events zsocket_events -#define zsockopt_last_endpoint zsocket_last_endpoint -#define zsockopt_set_router_raw zsocket_set_router_raw -#define zsockopt_ipv4only zsocket_ipv4only -#define zsockopt_set_ipv4only zsocket_set_ipv4only -#define zsockopt_set_delay_attach_on_connect zsocket_set_delay_attach_on_connect -#endif - -// Deprecated function names -#if (ZMQ_VERSION_MAJOR == 2) -#define zsockopt_hwm zsocket_hwm -#define zsockopt_set_hwm zsocket_set_hwm -#define zsockopt_swap zsocket_swap -#define zsockopt_set_swap zsocket_set_swap -#define zsockopt_affinity zsocket_affinity -#define zsockopt_set_affinity zsocket_set_affinity -#define zsockopt_identity zsocket_identity -#define zsockopt_set_identity zsocket_set_identity -#define zsockopt_rate zsocket_rate -#define zsockopt_set_rate zsocket_set_rate -#define zsockopt_recovery_ivl zsocket_recovery_ivl -#define zsockopt_set_recovery_ivl zsocket_set_recovery_ivl -#define zsockopt_recovery_ivl_msec zsocket_recovery_ivl_msec -#define zsockopt_set_recovery_ivl_msec zsocket_set_recovery_ivl_msec -#define zsockopt_mcast_loop zsocket_mcast_loop -#define zsockopt_set_mcast_loop zsocket_set_mcast_loop -# if (ZMQ_VERSION_MINOR == 2) -#define zsockopt_rcvtimeo zsocket_rcvtimeo -#define zsockopt_set_rcvtimeo zsocket_set_rcvtimeo -# endif -# if (ZMQ_VERSION_MINOR == 2) -#define zsockopt_sndtimeo zsocket_sndtimeo -#define zsockopt_set_sndtimeo zsocket_set_sndtimeo -# endif -#define zsockopt_sndbuf zsocket_sndbuf -#define zsockopt_set_sndbuf zsocket_set_sndbuf -#define zsockopt_rcvbuf zsocket_rcvbuf -#define zsockopt_set_rcvbuf zsocket_set_rcvbuf -#define zsockopt_linger zsocket_linger -#define zsockopt_set_linger zsocket_set_linger -#define zsockopt_reconnect_ivl zsocket_reconnect_ivl -#define zsockopt_set_reconnect_ivl zsocket_set_reconnect_ivl -#define zsockopt_reconnect_ivl_max zsocket_reconnect_ivl_max -#define zsockopt_set_reconnect_ivl_max zsocket_set_reconnect_ivl_max -#define zsockopt_backlog zsocket_backlog -#define zsockopt_set_backlog zsocket_set_backlog -#define zsockopt_set_subscribe zsocket_set_subscribe -#define zsockopt_set_unsubscribe zsocket_set_unsubscribe -#define zsockopt_type zsocket_type -#define zsockopt_rcvmore zsocket_rcvmore -#define zsockopt_fd zsocket_fd -#define zsockopt_events zsocket_events -#endif - - #ifdef __cplusplus } #endif diff --git a/model/sockopts.xml b/model/sockopts.xml index a9e57af32..d9f491599 100644 --- a/model/sockopts.xml +++ b/model/sockopts.xml @@ -4,7 +4,113 @@ use 'gsl sockopts' --> + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -55,33 +151,13 @@ type = "int" mode = "rw" test = "SUB" /> - + +
// Emulation of widely-used 2.x socket options CZMQ_EXPORT void zsocket_set_hwm (void *zocket, int hwm); @@ -106,35 +182,5 @@ zsocket_set_hwm (void *zocket, int hwm) zocket = zsocket_new (ctx, ZMQ_SUB); zsocket_set_hwm (zocket, 1); - - - - - - - + diff --git a/scripts/sockopts.gsl b/scripts/sockopts.gsl index 30f37a32b..6879e3842 100644 --- a/scripts/sockopts.gsl +++ b/scripts/sockopts.gsl @@ -1,17 +1,32 @@ -.output "../include/zsockopt.h" -.for version -. for option -. if type = "uint64" | type = "int64" | type = "uint32" | type = "int" -. option.ctype = "int" -. option.ctype_const = "int" -. elsif type = "string" | type = "key" -. option.ctype = "char *" # Enforce C strings -. option.ctype_const = "const char *" -. else -. echo "E: unknown type: $(type)" -. endif -. endfor -.endfor +.# This is a code generator built using the iMatix GSL code generation +.# language. See https://github.com/imatix/gsl for details. This script +.# is licensed under MIT/X11. +.# +.template 0 + output "../include/zsockopt.h" + for version + # Expand any macros + for include + for options.macro where name = include.name + for . as child + copy child to version + endfor + endfor + endfor + # Preprocess options + for option + if type = "uint64" | type = "int64" | type = "uint32" | type = "int" + option.ctype = "int" + option.ctype_const = "int" + elsif type = "string" | type = "key" + option.ctype = "char *" # Enforce C strings + option.ctype_const = "const char *" + else + echo "E: unknown type: $(type)" + endif + endfor + endfor +.endtemplate /* ========================================================================= zsockopt - get/set 0MQ socket options @@ -91,27 +106,6 @@ $(string.trim(.):) int zsockopt_test (bool verbose); // @end -.for version -// Deprecated function names -#if (ZMQ_VERSION_MAJOR == $(major)) -. for option -. if defined (.minor) -# if (ZMQ_VERSION_MINOR == $(minor)) -. endif -. if mode = "rw" | mode = "r" -#define zsockopt_$(name) zsocket_$(name) -. endif -. if mode = "rw" | mode = "w" -#define zsockopt_set_$(name) zsocket_set_$(name) -. endif -. if defined (.minor) -# endif -. endif -. endfor -#endif - -.endfor - #ifdef __cplusplus } #endif @@ -187,7 +181,7 @@ zsocket_set_$(name) (void *zocket, $(ctype_const) $(name)) . else . .close = "" . endif - $(open)zsockopt_type (zocket) != ZMQ_$(TYPE)$(close) + $(open)zsocket_type (zocket) != ZMQ_$(TYPE)$(close) . endfor printf ("ZMQ_$(NAME) is not valid on %s sockets\\n", zsocket_type_str (zocket)); assert (false); diff --git a/src/zsocket.c b/src/zsocket.c index 699ec60c0..f3ec5b597 100644 --- a/src/zsocket.c +++ b/src/zsocket.c @@ -182,7 +182,7 @@ zsocket_type_str (void *self) "DEALER", "ROUTER", "PULL", "PUSH", "XPUB", "XSUB", "STREAM" }; - int type = zsockopt_type (self); + int type = zsocket_type (self); if (type < 0 || type > ZMQ_STREAM) return "UNKNOWN"; else diff --git a/src/zsockopt.c b/src/zsockopt.c index 940e835de..9c9afeab1 100644 --- a/src/zsockopt.c +++ b/src/zsockopt.c @@ -40,19 +40,33 @@ #include "../include/czmq.h" -#if (ZMQ_VERSION_MAJOR == 3) +#if (ZMQ_VERSION_MAJOR == 4) // -------------------------------------------------------------------------- -// Return socket ZMQ_TYPE value +// Set socket ZMQ_IPV6 value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_ipv6 (void *zocket, int ipv6) +{ +# if defined (ZMQ_IPV6) + int rc = zmq_setsockopt (zocket, ZMQ_IPV6, &ipv6, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_IPV6 value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_type (void *zocket) +zsocket_ipv6 (void *zocket) { -# if defined (ZMQ_TYPE) - int type; +# if defined (ZMQ_IPV6) + int ipv6; size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_TYPE, &type, &option_len); - return type; + zmq_getsockopt (zocket, ZMQ_IPV6, &ipv6, &option_len); + return ipv6; # else return 0; # endif @@ -60,63 +74,63 @@ zsocket_type (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_SNDHWM value +// Set socket ZMQ_IMMEDIATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_sndhwm (void *zocket, int sndhwm) +zsocket_set_immediate (void *zocket, int immediate) { -# if defined (ZMQ_SNDHWM) - int rc = zmq_setsockopt (zocket, ZMQ_SNDHWM, &sndhwm, sizeof (int)); +# if defined (ZMQ_IMMEDIATE) + int rc = zmq_setsockopt (zocket, ZMQ_IMMEDIATE, &immediate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_SNDHWM value +// Set socket ZMQ_ROUTER_RAW value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -int -zsocket_sndhwm (void *zocket) +void +zsocket_set_router_raw (void *zocket, int router_raw) { -# if defined (ZMQ_SNDHWM) - int sndhwm; - size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_SNDHWM, &sndhwm, &option_len); - return sndhwm; -# else - return 0; +# if defined (ZMQ_ROUTER_RAW) + if (zsocket_type (zocket) != ZMQ_ROUTER) { + printf ("ZMQ_ROUTER_RAW is not valid on %s sockets\n", zsocket_type_str (zocket)); + assert (false); + } + int rc = zmq_setsockopt (zocket, ZMQ_ROUTER_RAW, &router_raw, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_RCVHWM value +// Set socket ZMQ_IPV4ONLY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_rcvhwm (void *zocket, int rcvhwm) +zsocket_set_ipv4only (void *zocket, int ipv4only) { -# if defined (ZMQ_RCVHWM) - int rc = zmq_setsockopt (zocket, ZMQ_RCVHWM, &rcvhwm, sizeof (int)); +# if defined (ZMQ_IPV4ONLY) + int rc = zmq_setsockopt (zocket, ZMQ_IPV4ONLY, &ipv4only, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_RCVHWM value +// Return socket ZMQ_IPV4ONLY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_rcvhwm (void *zocket) +zsocket_ipv4only (void *zocket) { -# if defined (ZMQ_RCVHWM) - int rcvhwm; +# if defined (ZMQ_IPV4ONLY) + int ipv4only; size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_RCVHWM, &rcvhwm, &option_len); - return rcvhwm; + zmq_getsockopt (zocket, ZMQ_IPV4ONLY, &ipv4only, &option_len); + return ipv4only; # else return 0; # endif @@ -124,140 +138,139 @@ zsocket_rcvhwm (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_AFFINITY value +// Set socket ZMQ_DELAY_ATTACH_ON_CONNECT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_affinity (void *zocket, int affinity) +zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect) { -# if defined (ZMQ_AFFINITY) - uint64_t value = affinity; - int rc = zmq_setsockopt (zocket, ZMQ_AFFINITY, &value, sizeof (uint64_t)); +# if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) + int rc = zmq_setsockopt (zocket, ZMQ_DELAY_ATTACH_ON_CONNECT, &delay_attach_on_connect, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_AFFINITY value +// Set socket ZMQ_ROUTER_MANDATORY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -int -zsocket_affinity (void *zocket) +void +zsocket_set_router_mandatory (void *zocket, int router_mandatory) { -# if defined (ZMQ_AFFINITY) - uint64_t affinity; - size_t option_len = sizeof (uint64_t); - zmq_getsockopt (zocket, ZMQ_AFFINITY, &affinity, &option_len); - return (int) affinity; -# else - return 0; +# if defined (ZMQ_ROUTER_MANDATORY) + if (zsocket_type (zocket) != ZMQ_ROUTER) { + printf ("ZMQ_ROUTER_MANDATORY is not valid on %s sockets\n", zsocket_type_str (zocket)); + assert (false); + } + int rc = zmq_setsockopt (zocket, ZMQ_ROUTER_MANDATORY, &router_mandatory, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_SUBSCRIBE value +// Return socket ZMQ_PROBE_ROUTER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -void -zsocket_set_subscribe (void *zocket, const char * subscribe) +int +zsocket_probe_router (void *zocket) { -# if defined (ZMQ_SUBSCRIBE) - if (zsockopt_type (zocket) != ZMQ_SUB) { - printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); - assert (false); - } - int rc = zmq_setsockopt (zocket, ZMQ_SUBSCRIBE, subscribe, strlen (subscribe)); - assert (rc == 0 || zmq_errno () == ETERM); +# if defined (ZMQ_PROBE_ROUTER) + int probe_router; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_PROBE_ROUTER, &probe_router, &option_len); + return probe_router; +# else + return 0; # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_UNSUBSCRIBE value +// Set socket ZMQ_REQ_RELAXED value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_unsubscribe (void *zocket, const char * unsubscribe) +zsocket_set_req_relaxed (void *zocket, int req_relaxed) { -# if defined (ZMQ_UNSUBSCRIBE) - if (zsockopt_type (zocket) != ZMQ_SUB) { - printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); +# if defined (ZMQ_REQ_RELAXED) + if (zsocket_type (zocket) != ZMQ_REQ) { + printf ("ZMQ_REQ_RELAXED is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } - int rc = zmq_setsockopt (zocket, ZMQ_UNSUBSCRIBE, unsubscribe, strlen (unsubscribe)); + int rc = zmq_setsockopt (zocket, ZMQ_REQ_RELAXED, &req_relaxed, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_IDENTITY value +// Set socket ZMQ_REQ_CORRELATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_identity (void *zocket, const char * identity) +zsocket_set_req_correlate (void *zocket, int req_correlate) { -# if defined (ZMQ_IDENTITY) - if (zsockopt_type (zocket) != ZMQ_REQ - && zsockopt_type (zocket) != ZMQ_REP - && zsockopt_type (zocket) != ZMQ_DEALER - && zsockopt_type (zocket) != ZMQ_ROUTER - && zsockopt_type (zocket) != ZMQ_STREAM) { - printf ("ZMQ_IDENTITY is not valid on %s sockets\n", zsocket_type_str (zocket)); +# if defined (ZMQ_REQ_CORRELATE) + if (zsocket_type (zocket) != ZMQ_REQ) { + printf ("ZMQ_REQ_CORRELATE is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } - int rc = zmq_setsockopt (zocket, ZMQ_IDENTITY, identity, strlen (identity)); + int rc = zmq_setsockopt (zocket, ZMQ_REQ_CORRELATE, &req_correlate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_IDENTITY value +// Set socket ZMQ_CONFLATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -char * -zsocket_identity (void *zocket) -{ -# if defined (ZMQ_IDENTITY) - size_t option_len = 255; - char *identity = (char *) zmalloc (option_len); - zmq_getsockopt (zocket, ZMQ_IDENTITY, identity, &option_len); - return (char *) identity; -# else - return NULL; +void +zsocket_set_conflate (void *zocket, int conflate) +{ +# if defined (ZMQ_CONFLATE) + if (zsocket_type (zocket) != ZMQ_PUSH + && zsocket_type (zocket) != ZMQ_PULL + && zsocket_type (zocket) != ZMQ_PUB + && zsocket_type (zocket) != ZMQ_SUB + && zsocket_type (zocket) != ZMQ_DEALER) { + printf ("ZMQ_CONFLATE is not valid on %s sockets\n", zsocket_type_str (zocket)); + assert (false); + } + int rc = zmq_setsockopt (zocket, ZMQ_CONFLATE, &conflate, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_RATE value +// Set socket ZMQ_PLAIN_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_rate (void *zocket, int rate) +zsocket_set_plain_server (void *zocket, int plain_server) { -# if defined (ZMQ_RATE) - int rc = zmq_setsockopt (zocket, ZMQ_RATE, &rate, sizeof (int)); +# if defined (ZMQ_PLAIN_SERVER) + int rc = zmq_setsockopt (zocket, ZMQ_PLAIN_SERVER, &plain_server, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_RATE value +// Return socket ZMQ_PLAIN_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_rate (void *zocket) +zsocket_plain_server (void *zocket) { -# if defined (ZMQ_RATE) - int rate; +# if defined (ZMQ_PLAIN_SERVER) + int plain_server; size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_RATE, &rate, &option_len); - return rate; + zmq_getsockopt (zocket, ZMQ_PLAIN_SERVER, &plain_server, &option_len); + return plain_server; # else return 0; # endif @@ -265,95 +278,95 @@ zsocket_rate (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_RECOVERY_IVL value +// Set socket ZMQ_PLAIN_USERNAME value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_recovery_ivl (void *zocket, int recovery_ivl) +zsocket_set_plain_username (void *zocket, const char * plain_username) { -# if defined (ZMQ_RECOVERY_IVL) - int rc = zmq_setsockopt (zocket, ZMQ_RECOVERY_IVL, &recovery_ivl, sizeof (int)); +# if defined (ZMQ_PLAIN_USERNAME) + int rc = zmq_setsockopt (zocket, ZMQ_PLAIN_USERNAME, plain_username, strlen (plain_username)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_RECOVERY_IVL value +// Return socket ZMQ_PLAIN_USERNAME value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -int -zsocket_recovery_ivl (void *zocket) +char * +zsocket_plain_username (void *zocket) { -# if defined (ZMQ_RECOVERY_IVL) - int recovery_ivl; - size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len); - return recovery_ivl; +# if defined (ZMQ_PLAIN_USERNAME) + size_t option_len = 255; + char *plain_username = (char *) zmalloc (option_len); + zmq_getsockopt (zocket, ZMQ_PLAIN_USERNAME, plain_username, &option_len); + return (char *) plain_username; # else - return 0; + return NULL; # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_SNDBUF value +// Set socket ZMQ_PLAIN_PASSWORD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_sndbuf (void *zocket, int sndbuf) +zsocket_set_plain_password (void *zocket, const char * plain_password) { -# if defined (ZMQ_SNDBUF) - int rc = zmq_setsockopt (zocket, ZMQ_SNDBUF, &sndbuf, sizeof (int)); +# if defined (ZMQ_PLAIN_PASSWORD) + int rc = zmq_setsockopt (zocket, ZMQ_PLAIN_PASSWORD, plain_password, strlen (plain_password)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_SNDBUF value +// Return socket ZMQ_PLAIN_PASSWORD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -int -zsocket_sndbuf (void *zocket) +char * +zsocket_plain_password (void *zocket) { -# if defined (ZMQ_SNDBUF) - int sndbuf; - size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_SNDBUF, &sndbuf, &option_len); - return sndbuf; +# if defined (ZMQ_PLAIN_PASSWORD) + size_t option_len = 255; + char *plain_password = (char *) zmalloc (option_len); + zmq_getsockopt (zocket, ZMQ_PLAIN_PASSWORD, plain_password, &option_len); + return (char *) plain_password; # else - return 0; + return NULL; # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_RCVBUF value +// Set socket ZMQ_CURVE_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_rcvbuf (void *zocket, int rcvbuf) +zsocket_set_curve_server (void *zocket, int curve_server) { -# if defined (ZMQ_RCVBUF) - int rc = zmq_setsockopt (zocket, ZMQ_RCVBUF, &rcvbuf, sizeof (int)); +# if defined (ZMQ_CURVE_SERVER) + int rc = zmq_setsockopt (zocket, ZMQ_CURVE_SERVER, &curve_server, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_RCVBUF value +// Return socket ZMQ_CURVE_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_rcvbuf (void *zocket) +zsocket_curve_server (void *zocket) { -# if defined (ZMQ_RCVBUF) - int rcvbuf; +# if defined (ZMQ_CURVE_SERVER) + int curve_server; size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_RCVBUF, &rcvbuf, &option_len); - return rcvbuf; + zmq_getsockopt (zocket, ZMQ_CURVE_SERVER, &curve_server, &option_len); + return curve_server; # else return 0; # endif @@ -361,192 +374,187 @@ zsocket_rcvbuf (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_LINGER value +// Set socket ZMQ_CURVE_PUBLICKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_linger (void *zocket, int linger) +zsocket_set_curve_publickey (void *zocket, const char * curve_publickey) { -# if defined (ZMQ_LINGER) - int rc = zmq_setsockopt (zocket, ZMQ_LINGER, &linger, sizeof (int)); +# if defined (ZMQ_CURVE_PUBLICKEY) + int rc = zmq_setsockopt (zocket, ZMQ_CURVE_PUBLICKEY, curve_publickey, strlen (curve_publickey)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_LINGER value +// Set socket ZMQ_CURVE_PUBLICKEY value from 32-octet binary // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -int -zsocket_linger (void *zocket) +void +zsocket_set_curve_publickey_bin (void *zocket, const byte *curve_publickey) { -# if defined (ZMQ_LINGER) - int linger; - size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_LINGER, &linger, &option_len); - return linger; -# else - return 0; +# if defined (ZMQ_CURVE_PUBLICKEY) + int rc = zmq_setsockopt (zocket, ZMQ_CURVE_PUBLICKEY, curve_publickey, 32); + assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_RECONNECT_IVL value +// Return socket ZMQ_CURVE_PUBLICKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -void -zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl) +char * +zsocket_curve_publickey (void *zocket) { -# if defined (ZMQ_RECONNECT_IVL) - int rc = zmq_setsockopt (zocket, ZMQ_RECONNECT_IVL, &reconnect_ivl, sizeof (int)); - assert (rc == 0 || zmq_errno () == ETERM); +# if defined (ZMQ_CURVE_PUBLICKEY) + size_t option_len = 255; + char *curve_publickey = (char *) zmalloc (option_len); + zmq_getsockopt (zocket, ZMQ_CURVE_PUBLICKEY, curve_publickey, &option_len); + return (char *) curve_publickey; +# else + return NULL; # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_RECONNECT_IVL value +// Set socket ZMQ_CURVE_SECRETKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -int -zsocket_reconnect_ivl (void *zocket) +void +zsocket_set_curve_secretkey (void *zocket, const char * curve_secretkey) { -# if defined (ZMQ_RECONNECT_IVL) - int reconnect_ivl; - size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_RECONNECT_IVL, &reconnect_ivl, &option_len); - return reconnect_ivl; -# else - return 0; +# if defined (ZMQ_CURVE_SECRETKEY) + int rc = zmq_setsockopt (zocket, ZMQ_CURVE_SECRETKEY, curve_secretkey, strlen (curve_secretkey)); + assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_RECONNECT_IVL_MAX value +// Set socket ZMQ_CURVE_SECRETKEY value from 32-octet binary // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max) +zsocket_set_curve_secretkey_bin (void *zocket, const byte *curve_secretkey) { -# if defined (ZMQ_RECONNECT_IVL_MAX) - int rc = zmq_setsockopt (zocket, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, sizeof (int)); +# if defined (ZMQ_CURVE_SECRETKEY) + int rc = zmq_setsockopt (zocket, ZMQ_CURVE_SECRETKEY, curve_secretkey, 32); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_RECONNECT_IVL_MAX value +// Return socket ZMQ_CURVE_SECRETKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -int -zsocket_reconnect_ivl_max (void *zocket) +char * +zsocket_curve_secretkey (void *zocket) { -# if defined (ZMQ_RECONNECT_IVL_MAX) - int reconnect_ivl_max; - size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, &option_len); - return reconnect_ivl_max; +# if defined (ZMQ_CURVE_SECRETKEY) + size_t option_len = 255; + char *curve_secretkey = (char *) zmalloc (option_len); + zmq_getsockopt (zocket, ZMQ_CURVE_SECRETKEY, curve_secretkey, &option_len); + return (char *) curve_secretkey; # else - return 0; + return NULL; # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_BACKLOG value +// Set socket ZMQ_CURVE_SERVERKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_backlog (void *zocket, int backlog) +zsocket_set_curve_serverkey (void *zocket, const char * curve_serverkey) { -# if defined (ZMQ_BACKLOG) - int rc = zmq_setsockopt (zocket, ZMQ_BACKLOG, &backlog, sizeof (int)); +# if defined (ZMQ_CURVE_SERVERKEY) + int rc = zmq_setsockopt (zocket, ZMQ_CURVE_SERVERKEY, curve_serverkey, strlen (curve_serverkey)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_BACKLOG value +// Set socket ZMQ_CURVE_SERVERKEY value from 32-octet binary // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -int -zsocket_backlog (void *zocket) +void +zsocket_set_curve_serverkey_bin (void *zocket, const byte *curve_serverkey) { -# if defined (ZMQ_BACKLOG) - int backlog; - size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_BACKLOG, &backlog, &option_len); - return backlog; -# else - return 0; +# if defined (ZMQ_CURVE_SERVERKEY) + int rc = zmq_setsockopt (zocket, ZMQ_CURVE_SERVERKEY, curve_serverkey, 32); + assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_MAXMSGSIZE value +// Return socket ZMQ_CURVE_SERVERKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -void -zsocket_set_maxmsgsize (void *zocket, int maxmsgsize) +char * +zsocket_curve_serverkey (void *zocket) { -# if defined (ZMQ_MAXMSGSIZE) - int64_t value = maxmsgsize; - int rc = zmq_setsockopt (zocket, ZMQ_MAXMSGSIZE, &value, sizeof (int64_t)); - assert (rc == 0 || zmq_errno () == ETERM); +# if defined (ZMQ_CURVE_SERVERKEY) + size_t option_len = 255; + char *curve_serverkey = (char *) zmalloc (option_len); + zmq_getsockopt (zocket, ZMQ_CURVE_SERVERKEY, curve_serverkey, &option_len); + return (char *) curve_serverkey; +# else + return NULL; # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_MAXMSGSIZE value +// Set socket ZMQ_ZAP_DOMAIN value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -int -zsocket_maxmsgsize (void *zocket) +void +zsocket_set_zap_domain (void *zocket, const char * zap_domain) { -# if defined (ZMQ_MAXMSGSIZE) - int64_t maxmsgsize; - size_t option_len = sizeof (int64_t); - zmq_getsockopt (zocket, ZMQ_MAXMSGSIZE, &maxmsgsize, &option_len); - return (int) maxmsgsize; -# else - return 0; +# if defined (ZMQ_ZAP_DOMAIN) + int rc = zmq_setsockopt (zocket, ZMQ_ZAP_DOMAIN, zap_domain, strlen (zap_domain)); + assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_MULTICAST_HOPS value +// Return socket ZMQ_ZAP_DOMAIN value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -void -zsocket_set_multicast_hops (void *zocket, int multicast_hops) +char * +zsocket_zap_domain (void *zocket) { -# if defined (ZMQ_MULTICAST_HOPS) - int rc = zmq_setsockopt (zocket, ZMQ_MULTICAST_HOPS, &multicast_hops, sizeof (int)); - assert (rc == 0 || zmq_errno () == ETERM); +# if defined (ZMQ_ZAP_DOMAIN) + size_t option_len = 255; + char *zap_domain = (char *) zmalloc (option_len); + zmq_getsockopt (zocket, ZMQ_ZAP_DOMAIN, zap_domain, &option_len); + return (char *) zap_domain; +# else + return NULL; # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_MULTICAST_HOPS value +// Return socket ZMQ_TYPE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_multicast_hops (void *zocket) +zsocket_type (void *zocket) { -# if defined (ZMQ_MULTICAST_HOPS) - int multicast_hops; +# if defined (ZMQ_TYPE) + int type; size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_MULTICAST_HOPS, &multicast_hops, &option_len); - return multicast_hops; + zmq_getsockopt (zocket, ZMQ_TYPE, &type, &option_len); + return type; # else return 0; # endif @@ -554,31 +562,31 @@ zsocket_multicast_hops (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_RCVTIMEO value +// Set socket ZMQ_SNDHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_rcvtimeo (void *zocket, int rcvtimeo) +zsocket_set_sndhwm (void *zocket, int sndhwm) { -# if defined (ZMQ_RCVTIMEO) - int rc = zmq_setsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int)); +# if defined (ZMQ_SNDHWM) + int rc = zmq_setsockopt (zocket, ZMQ_SNDHWM, &sndhwm, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_RCVTIMEO value +// Return socket ZMQ_SNDHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_rcvtimeo (void *zocket) +zsocket_sndhwm (void *zocket) { -# if defined (ZMQ_RCVTIMEO) - int rcvtimeo; +# if defined (ZMQ_SNDHWM) + int sndhwm; size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, &option_len); - return rcvtimeo; + zmq_getsockopt (zocket, ZMQ_SNDHWM, &sndhwm, &option_len); + return sndhwm; # else return 0; # endif @@ -586,31 +594,31 @@ zsocket_rcvtimeo (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_SNDTIMEO value +// Set socket ZMQ_RCVHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_sndtimeo (void *zocket, int sndtimeo) +zsocket_set_rcvhwm (void *zocket, int rcvhwm) { -# if defined (ZMQ_SNDTIMEO) - int rc = zmq_setsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, sizeof (int)); +# if defined (ZMQ_RCVHWM) + int rc = zmq_setsockopt (zocket, ZMQ_RCVHWM, &rcvhwm, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_SNDTIMEO value +// Return socket ZMQ_RCVHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_sndtimeo (void *zocket) +zsocket_rcvhwm (void *zocket) { -# if defined (ZMQ_SNDTIMEO) - int sndtimeo; +# if defined (ZMQ_RCVHWM) + int rcvhwm; size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, &option_len); - return sndtimeo; + zmq_getsockopt (zocket, ZMQ_RCVHWM, &rcvhwm, &option_len); + return rcvhwm; # else return 0; # endif @@ -618,31 +626,32 @@ zsocket_sndtimeo (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_IPV6 value +// Set socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_ipv6 (void *zocket, int ipv6) +zsocket_set_affinity (void *zocket, int affinity) { -# if defined (ZMQ_IPV6) - int rc = zmq_setsockopt (zocket, ZMQ_IPV6, &ipv6, sizeof (int)); +# if defined (ZMQ_AFFINITY) + uint64_t value = affinity; + int rc = zmq_setsockopt (zocket, ZMQ_AFFINITY, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_IPV6 value +// Return socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_ipv6 (void *zocket) +zsocket_affinity (void *zocket) { -# if defined (ZMQ_IPV6) - int ipv6; - size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_IPV6, &ipv6, &option_len); - return ipv6; +# if defined (ZMQ_AFFINITY) + uint64_t affinity; + size_t option_len = sizeof (uint64_t); + zmq_getsockopt (zocket, ZMQ_AFFINITY, &affinity, &option_len); + return (int) affinity; # else return 0; # endif @@ -650,99 +659,107 @@ zsocket_ipv6 (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_IMMEDIATE value +// Set socket ZMQ_SUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_immediate (void *zocket, int immediate) +zsocket_set_subscribe (void *zocket, const char * subscribe) { -# if defined (ZMQ_IMMEDIATE) - int rc = zmq_setsockopt (zocket, ZMQ_IMMEDIATE, &immediate, sizeof (int)); +# if defined (ZMQ_SUBSCRIBE) + if (zsocket_type (zocket) != ZMQ_SUB) { + printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); + assert (false); + } + int rc = zmq_setsockopt (zocket, ZMQ_SUBSCRIBE, subscribe, strlen (subscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_ROUTER_MANDATORY value +// Set socket ZMQ_UNSUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_router_mandatory (void *zocket, int router_mandatory) +zsocket_set_unsubscribe (void *zocket, const char * unsubscribe) { -# if defined (ZMQ_ROUTER_MANDATORY) - if (zsockopt_type (zocket) != ZMQ_ROUTER) { - printf ("ZMQ_ROUTER_MANDATORY is not valid on %s sockets\n", zsocket_type_str (zocket)); +# if defined (ZMQ_UNSUBSCRIBE) + if (zsocket_type (zocket) != ZMQ_SUB) { + printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } - int rc = zmq_setsockopt (zocket, ZMQ_ROUTER_MANDATORY, &router_mandatory, sizeof (int)); + int rc = zmq_setsockopt (zocket, ZMQ_UNSUBSCRIBE, unsubscribe, strlen (unsubscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_PROBE_ROUTER value +// Set socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -int -zsocket_probe_router (void *zocket) +void +zsocket_set_identity (void *zocket, const char * identity) { -# if defined (ZMQ_PROBE_ROUTER) - int probe_router; - size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_PROBE_ROUTER, &probe_router, &option_len); - return probe_router; -# else - return 0; +# if defined (ZMQ_IDENTITY) + if (zsocket_type (zocket) != ZMQ_REQ + && zsocket_type (zocket) != ZMQ_REP + && zsocket_type (zocket) != ZMQ_DEALER + && zsocket_type (zocket) != ZMQ_ROUTER + && zsocket_type (zocket) != ZMQ_STREAM) { + printf ("ZMQ_IDENTITY is not valid on %s sockets\n", zsocket_type_str (zocket)); + assert (false); + } + int rc = zmq_setsockopt (zocket, ZMQ_IDENTITY, identity, strlen (identity)); + assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_XPUB_VERBOSE value +// Return socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -void -zsocket_set_xpub_verbose (void *zocket, int xpub_verbose) +char * +zsocket_identity (void *zocket) { -# if defined (ZMQ_XPUB_VERBOSE) - if (zsockopt_type (zocket) != ZMQ_XPUB) { - printf ("ZMQ_XPUB_VERBOSE is not valid on %s sockets\n", zsocket_type_str (zocket)); - assert (false); - } - int rc = zmq_setsockopt (zocket, ZMQ_XPUB_VERBOSE, &xpub_verbose, sizeof (int)); - assert (rc == 0 || zmq_errno () == ETERM); +# if defined (ZMQ_IDENTITY) + size_t option_len = 255; + char *identity = (char *) zmalloc (option_len); + zmq_getsockopt (zocket, ZMQ_IDENTITY, identity, &option_len); + return (char *) identity; +# else + return NULL; # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_TCP_KEEPALIVE value +// Set socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive) +zsocket_set_rate (void *zocket, int rate) { -# if defined (ZMQ_TCP_KEEPALIVE) - int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE, &tcp_keepalive, sizeof (int)); +# if defined (ZMQ_RATE) + int rc = zmq_setsockopt (zocket, ZMQ_RATE, &rate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_TCP_KEEPALIVE value +// Return socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_tcp_keepalive (void *zocket) +zsocket_rate (void *zocket) { -# if defined (ZMQ_TCP_KEEPALIVE) - int tcp_keepalive; +# if defined (ZMQ_RATE) + int rate; size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE, &tcp_keepalive, &option_len); - return tcp_keepalive; + zmq_getsockopt (zocket, ZMQ_RATE, &rate, &option_len); + return rate; # else return 0; # endif @@ -750,31 +767,31 @@ zsocket_tcp_keepalive (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_TCP_KEEPALIVE_IDLE value +// Set socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle) +zsocket_set_recovery_ivl (void *zocket, int recovery_ivl) { -# if defined (ZMQ_TCP_KEEPALIVE_IDLE) - int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, sizeof (int)); +# if defined (ZMQ_RECOVERY_IVL) + int rc = zmq_setsockopt (zocket, ZMQ_RECOVERY_IVL, &recovery_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_TCP_KEEPALIVE_IDLE value +// Return socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_tcp_keepalive_idle (void *zocket) +zsocket_recovery_ivl (void *zocket) { -# if defined (ZMQ_TCP_KEEPALIVE_IDLE) - int tcp_keepalive_idle; +# if defined (ZMQ_RECOVERY_IVL) + int recovery_ivl; size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, &option_len); - return tcp_keepalive_idle; + zmq_getsockopt (zocket, ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len); + return recovery_ivl; # else return 0; # endif @@ -782,31 +799,31 @@ zsocket_tcp_keepalive_idle (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_TCP_KEEPALIVE_CNT value +// Set socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt) +zsocket_set_sndbuf (void *zocket, int sndbuf) { -# if defined (ZMQ_TCP_KEEPALIVE_CNT) - int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, sizeof (int)); +# if defined (ZMQ_SNDBUF) + int rc = zmq_setsockopt (zocket, ZMQ_SNDBUF, &sndbuf, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_TCP_KEEPALIVE_CNT value +// Return socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_tcp_keepalive_cnt (void *zocket) +zsocket_sndbuf (void *zocket) { -# if defined (ZMQ_TCP_KEEPALIVE_CNT) - int tcp_keepalive_cnt; +# if defined (ZMQ_SNDBUF) + int sndbuf; size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, &option_len); - return tcp_keepalive_cnt; + zmq_getsockopt (zocket, ZMQ_SNDBUF, &sndbuf, &option_len); + return sndbuf; # else return 0; # endif @@ -814,31 +831,31 @@ zsocket_tcp_keepalive_cnt (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_TCP_KEEPALIVE_INTVL value +// Set socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl) +zsocket_set_rcvbuf (void *zocket, int rcvbuf) { -# if defined (ZMQ_TCP_KEEPALIVE_INTVL) - int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, sizeof (int)); +# if defined (ZMQ_RCVBUF) + int rc = zmq_setsockopt (zocket, ZMQ_RCVBUF, &rcvbuf, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_TCP_KEEPALIVE_INTVL value +// Return socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_tcp_keepalive_intvl (void *zocket) +zsocket_rcvbuf (void *zocket) { -# if defined (ZMQ_TCP_KEEPALIVE_INTVL) - int tcp_keepalive_intvl; +# if defined (ZMQ_RCVBUF) + int rcvbuf; size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, &option_len); - return tcp_keepalive_intvl; + zmq_getsockopt (zocket, ZMQ_RCVBUF, &rcvbuf, &option_len); + return rcvbuf; # else return 0; # endif @@ -846,63 +863,63 @@ zsocket_tcp_keepalive_intvl (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_TCP_ACCEPT_FILTER value +// Set socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter) +zsocket_set_linger (void *zocket, int linger) { -# if defined (ZMQ_TCP_ACCEPT_FILTER) - int rc = zmq_setsockopt (zocket, ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, strlen (tcp_accept_filter)); +# if defined (ZMQ_LINGER) + int rc = zmq_setsockopt (zocket, ZMQ_LINGER, &linger, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_TCP_ACCEPT_FILTER value +// Return socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -char * -zsocket_tcp_accept_filter (void *zocket) +int +zsocket_linger (void *zocket) { -# if defined (ZMQ_TCP_ACCEPT_FILTER) - size_t option_len = 255; - char *tcp_accept_filter = (char *) zmalloc (option_len); - zmq_getsockopt (zocket, ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, &option_len); - return (char *) tcp_accept_filter; +# if defined (ZMQ_LINGER) + int linger; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_LINGER, &linger, &option_len); + return linger; # else - return NULL; + return 0; # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_PLAIN_SERVER value +// Set socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_plain_server (void *zocket, int plain_server) +zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl) { -# if defined (ZMQ_PLAIN_SERVER) - int rc = zmq_setsockopt (zocket, ZMQ_PLAIN_SERVER, &plain_server, sizeof (int)); +# if defined (ZMQ_RECONNECT_IVL) + int rc = zmq_setsockopt (zocket, ZMQ_RECONNECT_IVL, &reconnect_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_PLAIN_SERVER value +// Return socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_plain_server (void *zocket) +zsocket_reconnect_ivl (void *zocket) { -# if defined (ZMQ_PLAIN_SERVER) - int plain_server; +# if defined (ZMQ_RECONNECT_IVL) + int reconnect_ivl; size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_PLAIN_SERVER, &plain_server, &option_len); - return plain_server; + zmq_getsockopt (zocket, ZMQ_RECONNECT_IVL, &reconnect_ivl, &option_len); + return reconnect_ivl; # else return 0; # endif @@ -910,95 +927,96 @@ zsocket_plain_server (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_PLAIN_USERNAME value +// Set socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_plain_username (void *zocket, const char * plain_username) +zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max) { -# if defined (ZMQ_PLAIN_USERNAME) - int rc = zmq_setsockopt (zocket, ZMQ_PLAIN_USERNAME, plain_username, strlen (plain_username)); +# if defined (ZMQ_RECONNECT_IVL_MAX) + int rc = zmq_setsockopt (zocket, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_PLAIN_USERNAME value +// Return socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -char * -zsocket_plain_username (void *zocket) +int +zsocket_reconnect_ivl_max (void *zocket) { -# if defined (ZMQ_PLAIN_USERNAME) - size_t option_len = 255; - char *plain_username = (char *) zmalloc (option_len); - zmq_getsockopt (zocket, ZMQ_PLAIN_USERNAME, plain_username, &option_len); - return (char *) plain_username; +# if defined (ZMQ_RECONNECT_IVL_MAX) + int reconnect_ivl_max; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, &option_len); + return reconnect_ivl_max; # else - return NULL; + return 0; # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_PLAIN_PASSWORD value +// Set socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_plain_password (void *zocket, const char * plain_password) +zsocket_set_backlog (void *zocket, int backlog) { -# if defined (ZMQ_PLAIN_PASSWORD) - int rc = zmq_setsockopt (zocket, ZMQ_PLAIN_PASSWORD, plain_password, strlen (plain_password)); +# if defined (ZMQ_BACKLOG) + int rc = zmq_setsockopt (zocket, ZMQ_BACKLOG, &backlog, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_PLAIN_PASSWORD value +// Return socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -char * -zsocket_plain_password (void *zocket) +int +zsocket_backlog (void *zocket) { -# if defined (ZMQ_PLAIN_PASSWORD) - size_t option_len = 255; - char *plain_password = (char *) zmalloc (option_len); - zmq_getsockopt (zocket, ZMQ_PLAIN_PASSWORD, plain_password, &option_len); - return (char *) plain_password; +# if defined (ZMQ_BACKLOG) + int backlog; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_BACKLOG, &backlog, &option_len); + return backlog; # else - return NULL; + return 0; # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_CURVE_SERVER value +// Set socket ZMQ_MAXMSGSIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_curve_server (void *zocket, int curve_server) +zsocket_set_maxmsgsize (void *zocket, int maxmsgsize) { -# if defined (ZMQ_CURVE_SERVER) - int rc = zmq_setsockopt (zocket, ZMQ_CURVE_SERVER, &curve_server, sizeof (int)); +# if defined (ZMQ_MAXMSGSIZE) + int64_t value = maxmsgsize; + int rc = zmq_setsockopt (zocket, ZMQ_MAXMSGSIZE, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_CURVE_SERVER value +// Return socket ZMQ_MAXMSGSIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_curve_server (void *zocket) +zsocket_maxmsgsize (void *zocket) { -# if defined (ZMQ_CURVE_SERVER) - int curve_server; - size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_CURVE_SERVER, &curve_server, &option_len); - return curve_server; +# if defined (ZMQ_MAXMSGSIZE) + int64_t maxmsgsize; + size_t option_len = sizeof (int64_t); + zmq_getsockopt (zocket, ZMQ_MAXMSGSIZE, &maxmsgsize, &option_len); + return (int) maxmsgsize; # else return 0; # endif @@ -1006,169 +1024,273 @@ zsocket_curve_server (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_CURVE_PUBLICKEY value +// Set socket ZMQ_MULTICAST_HOPS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_curve_publickey (void *zocket, const char * curve_publickey) +zsocket_set_multicast_hops (void *zocket, int multicast_hops) { -# if defined (ZMQ_CURVE_PUBLICKEY) - int rc = zmq_setsockopt (zocket, ZMQ_CURVE_PUBLICKEY, curve_publickey, strlen (curve_publickey)); +# if defined (ZMQ_MULTICAST_HOPS) + int rc = zmq_setsockopt (zocket, ZMQ_MULTICAST_HOPS, &multicast_hops, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_CURVE_PUBLICKEY value from 32-octet binary +// Return socket ZMQ_MULTICAST_HOPS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -void -zsocket_set_curve_publickey_bin (void *zocket, const byte *curve_publickey) +int +zsocket_multicast_hops (void *zocket) { -# if defined (ZMQ_CURVE_PUBLICKEY) - int rc = zmq_setsockopt (zocket, ZMQ_CURVE_PUBLICKEY, curve_publickey, 32); - assert (rc == 0 || zmq_errno () == ETERM); +# if defined (ZMQ_MULTICAST_HOPS) + int multicast_hops; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_MULTICAST_HOPS, &multicast_hops, &option_len); + return multicast_hops; +# else + return 0; # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_CURVE_PUBLICKEY value +// Set socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -char * -zsocket_curve_publickey (void *zocket) +void +zsocket_set_rcvtimeo (void *zocket, int rcvtimeo) { -# if defined (ZMQ_CURVE_PUBLICKEY) - size_t option_len = 255; - char *curve_publickey = (char *) zmalloc (option_len); - zmq_getsockopt (zocket, ZMQ_CURVE_PUBLICKEY, curve_publickey, &option_len); - return (char *) curve_publickey; -# else - return NULL; +# if defined (ZMQ_RCVTIMEO) + int rc = zmq_setsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_CURVE_SECRETKEY value +// Return socket ZMQ_RCVTIMEO value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_rcvtimeo (void *zocket) +{ +# if defined (ZMQ_RCVTIMEO) + int rcvtimeo; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, &option_len); + return rcvtimeo; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_curve_secretkey (void *zocket, const char * curve_secretkey) +zsocket_set_sndtimeo (void *zocket, int sndtimeo) { -# if defined (ZMQ_CURVE_SECRETKEY) - int rc = zmq_setsockopt (zocket, ZMQ_CURVE_SECRETKEY, curve_secretkey, strlen (curve_secretkey)); +# if defined (ZMQ_SNDTIMEO) + int rc = zmq_setsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_CURVE_SECRETKEY value from 32-octet binary +// Return socket ZMQ_SNDTIMEO value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_sndtimeo (void *zocket) +{ +# if defined (ZMQ_SNDTIMEO) + int sndtimeo; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, &option_len); + return sndtimeo; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_XPUB_VERBOSE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_curve_secretkey_bin (void *zocket, const byte *curve_secretkey) +zsocket_set_xpub_verbose (void *zocket, int xpub_verbose) { -# if defined (ZMQ_CURVE_SECRETKEY) - int rc = zmq_setsockopt (zocket, ZMQ_CURVE_SECRETKEY, curve_secretkey, 32); +# if defined (ZMQ_XPUB_VERBOSE) + if (zsocket_type (zocket) != ZMQ_XPUB) { + printf ("ZMQ_XPUB_VERBOSE is not valid on %s sockets\n", zsocket_type_str (zocket)); + assert (false); + } + int rc = zmq_setsockopt (zocket, ZMQ_XPUB_VERBOSE, &xpub_verbose, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_CURVE_SECRETKEY value +// Set socket ZMQ_TCP_KEEPALIVE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -char * -zsocket_curve_secretkey (void *zocket) +void +zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive) { -# if defined (ZMQ_CURVE_SECRETKEY) - size_t option_len = 255; - char *curve_secretkey = (char *) zmalloc (option_len); - zmq_getsockopt (zocket, ZMQ_CURVE_SECRETKEY, curve_secretkey, &option_len); - return (char *) curve_secretkey; +# if defined (ZMQ_TCP_KEEPALIVE) + int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE, &tcp_keepalive, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_TCP_KEEPALIVE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_tcp_keepalive (void *zocket) +{ +# if defined (ZMQ_TCP_KEEPALIVE) + int tcp_keepalive; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE, &tcp_keepalive, &option_len); + return tcp_keepalive; # else - return NULL; + return 0; # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_CURVE_SERVERKEY value +// Set socket ZMQ_TCP_KEEPALIVE_IDLE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_curve_serverkey (void *zocket, const char * curve_serverkey) +zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle) { -# if defined (ZMQ_CURVE_SERVERKEY) - int rc = zmq_setsockopt (zocket, ZMQ_CURVE_SERVERKEY, curve_serverkey, strlen (curve_serverkey)); +# if defined (ZMQ_TCP_KEEPALIVE_IDLE) + int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_CURVE_SERVERKEY value from 32-octet binary +// Return socket ZMQ_TCP_KEEPALIVE_IDLE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_tcp_keepalive_idle (void *zocket) +{ +# if defined (ZMQ_TCP_KEEPALIVE_IDLE) + int tcp_keepalive_idle; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, &option_len); + return tcp_keepalive_idle; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_TCP_KEEPALIVE_CNT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_curve_serverkey_bin (void *zocket, const byte *curve_serverkey) +zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt) { -# if defined (ZMQ_CURVE_SERVERKEY) - int rc = zmq_setsockopt (zocket, ZMQ_CURVE_SERVERKEY, curve_serverkey, 32); +# if defined (ZMQ_TCP_KEEPALIVE_CNT) + int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_CURVE_SERVERKEY value +// Return socket ZMQ_TCP_KEEPALIVE_CNT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -char * -zsocket_curve_serverkey (void *zocket) +int +zsocket_tcp_keepalive_cnt (void *zocket) { -# if defined (ZMQ_CURVE_SERVERKEY) - size_t option_len = 255; - char *curve_serverkey = (char *) zmalloc (option_len); - zmq_getsockopt (zocket, ZMQ_CURVE_SERVERKEY, curve_serverkey, &option_len); - return (char *) curve_serverkey; +# if defined (ZMQ_TCP_KEEPALIVE_CNT) + int tcp_keepalive_cnt; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, &option_len); + return tcp_keepalive_cnt; # else - return NULL; + return 0; # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_ZAP_DOMAIN value +// Set socket ZMQ_TCP_KEEPALIVE_INTVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_zap_domain (void *zocket, const char * zap_domain) +zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl) { -# if defined (ZMQ_ZAP_DOMAIN) - int rc = zmq_setsockopt (zocket, ZMQ_ZAP_DOMAIN, zap_domain, strlen (zap_domain)); +# if defined (ZMQ_TCP_KEEPALIVE_INTVL) + int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_ZAP_DOMAIN value +// Return socket ZMQ_TCP_KEEPALIVE_INTVL value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_tcp_keepalive_intvl (void *zocket) +{ +# if defined (ZMQ_TCP_KEEPALIVE_INTVL) + int tcp_keepalive_intvl; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, &option_len); + return tcp_keepalive_intvl; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_TCP_ACCEPT_FILTER value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter) +{ +# if defined (ZMQ_TCP_ACCEPT_FILTER) + int rc = zmq_setsockopt (zocket, ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, strlen (tcp_accept_filter)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_TCP_ACCEPT_FILTER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * -zsocket_zap_domain (void *zocket) +zsocket_tcp_accept_filter (void *zocket) { -# if defined (ZMQ_ZAP_DOMAIN) +# if defined (ZMQ_TCP_ACCEPT_FILTER) size_t option_len = 255; - char *zap_domain = (char *) zmalloc (option_len); - zmq_getsockopt (zocket, ZMQ_ZAP_DOMAIN, zap_domain, &option_len); - return (char *) zap_domain; + char *tcp_accept_filter = (char *) zmalloc (option_len); + zmq_getsockopt (zocket, ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, &option_len); + return (char *) tcp_accept_filter; # else return NULL; # endif @@ -1247,6 +1369,19 @@ zsocket_last_endpoint (void *zocket) } +// -------------------------------------------------------------------------- +// Set socket high-water mark, emulating 2.x API + +void +zsocket_set_hwm (void *zocket, int hwm) +{ + zsocket_set_sndhwm (zocket, hwm); + zsocket_set_rcvhwm (zocket, hwm); +} + +#endif + +#if (ZMQ_VERSION_MAJOR == 3) // -------------------------------------------------------------------------- // Set socket ZMQ_ROUTER_RAW value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** @@ -1255,7 +1390,7 @@ void zsocket_set_router_raw (void *zocket, int router_raw) { # if defined (ZMQ_ROUTER_RAW) - if (zsockopt_type (zocket) != ZMQ_ROUTER) { + if (zsocket_type (zocket) != ZMQ_ROUTER) { printf ("ZMQ_ROUTER_RAW is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } @@ -1312,45 +1447,49 @@ zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect) // -------------------------------------------------------------------------- -// Set socket high-water mark, emulating 2.x API +// Return socket ZMQ_TYPE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -void -zsocket_set_hwm (void *zocket, int hwm) +int +zsocket_type (void *zocket) { - zsocket_set_sndhwm (zocket, hwm); - zsocket_set_rcvhwm (zocket, hwm); +# if defined (ZMQ_TYPE) + int type; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_TYPE, &type, &option_len); + return type; +# else + return 0; +# endif } -#endif -#if (ZMQ_VERSION_MAJOR == 2) // -------------------------------------------------------------------------- -// Set socket ZMQ_HWM value +// Set socket ZMQ_SNDHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_hwm (void *zocket, int hwm) +zsocket_set_sndhwm (void *zocket, int sndhwm) { -# if defined (ZMQ_HWM) - uint64_t value = hwm; - int rc = zmq_setsockopt (zocket, ZMQ_HWM, &value, sizeof (uint64_t)); +# if defined (ZMQ_SNDHWM) + int rc = zmq_setsockopt (zocket, ZMQ_SNDHWM, &sndhwm, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_HWM value +// Return socket ZMQ_SNDHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_hwm (void *zocket) +zsocket_sndhwm (void *zocket) { -# if defined (ZMQ_HWM) - uint64_t hwm; - size_t option_len = sizeof (uint64_t); - zmq_getsockopt (zocket, ZMQ_HWM, &hwm, &option_len); - return (int) hwm; +# if defined (ZMQ_SNDHWM) + int sndhwm; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_SNDHWM, &sndhwm, &option_len); + return sndhwm; # else return 0; # endif @@ -1358,32 +1497,31 @@ zsocket_hwm (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_SWAP value +// Set socket ZMQ_RCVHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_swap (void *zocket, int swap) +zsocket_set_rcvhwm (void *zocket, int rcvhwm) { -# if defined (ZMQ_SWAP) - int64_t value = swap; - int rc = zmq_setsockopt (zocket, ZMQ_SWAP, &value, sizeof (int64_t)); +# if defined (ZMQ_RCVHWM) + int rc = zmq_setsockopt (zocket, ZMQ_RCVHWM, &rcvhwm, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_SWAP value +// Return socket ZMQ_RCVHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_swap (void *zocket) +zsocket_rcvhwm (void *zocket) { -# if defined (ZMQ_SWAP) - int64_t swap; - size_t option_len = sizeof (int64_t); - zmq_getsockopt (zocket, ZMQ_SWAP, &swap, &option_len); - return (int) swap; +# if defined (ZMQ_RCVHWM) + int rcvhwm; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_RCVHWM, &rcvhwm, &option_len); + return rcvhwm; # else return 0; # endif @@ -1423,6 +1561,42 @@ zsocket_affinity (void *zocket) } +// -------------------------------------------------------------------------- +// Set socket ZMQ_SUBSCRIBE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_subscribe (void *zocket, const char * subscribe) +{ +# if defined (ZMQ_SUBSCRIBE) + if (zsocket_type (zocket) != ZMQ_SUB) { + printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); + assert (false); + } + int rc = zmq_setsockopt (zocket, ZMQ_SUBSCRIBE, subscribe, strlen (subscribe)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_UNSUBSCRIBE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_unsubscribe (void *zocket, const char * unsubscribe) +{ +# if defined (ZMQ_UNSUBSCRIBE) + if (zsocket_type (zocket) != ZMQ_SUB) { + printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); + assert (false); + } + int rc = zmq_setsockopt (zocket, ZMQ_UNSUBSCRIBE, unsubscribe, strlen (unsubscribe)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + // -------------------------------------------------------------------------- // Set socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** @@ -1431,6 +1605,14 @@ void zsocket_set_identity (void *zocket, const char * identity) { # if defined (ZMQ_IDENTITY) + if (zsocket_type (zocket) != ZMQ_REQ + && zsocket_type (zocket) != ZMQ_REP + && zsocket_type (zocket) != ZMQ_DEALER + && zsocket_type (zocket) != ZMQ_ROUTER + && zsocket_type (zocket) != ZMQ_STREAM) { + printf ("ZMQ_IDENTITY is not valid on %s sockets\n", zsocket_type_str (zocket)); + assert (false); + } int rc = zmq_setsockopt (zocket, ZMQ_IDENTITY, identity, strlen (identity)); assert (rc == 0 || zmq_errno () == ETERM); # endif @@ -1463,8 +1645,7 @@ void zsocket_set_rate (void *zocket, int rate) { # if defined (ZMQ_RATE) - int64_t value = rate; - int rc = zmq_setsockopt (zocket, ZMQ_RATE, &value, sizeof (int64_t)); + int rc = zmq_setsockopt (zocket, ZMQ_RATE, &rate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } @@ -1478,10 +1659,10 @@ int zsocket_rate (void *zocket) { # if defined (ZMQ_RATE) - int64_t rate; - size_t option_len = sizeof (int64_t); + int rate; + size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RATE, &rate, &option_len); - return (int) rate; + return rate; # else return 0; # endif @@ -1496,8 +1677,7 @@ void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl) { # if defined (ZMQ_RECOVERY_IVL) - int64_t value = recovery_ivl; - int rc = zmq_setsockopt (zocket, ZMQ_RECOVERY_IVL, &value, sizeof (int64_t)); + int rc = zmq_setsockopt (zocket, ZMQ_RECOVERY_IVL, &recovery_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } @@ -1511,150 +1691,16 @@ int zsocket_recovery_ivl (void *zocket) { # if defined (ZMQ_RECOVERY_IVL) - int64_t recovery_ivl; - size_t option_len = sizeof (int64_t); - zmq_getsockopt (zocket, ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len); - return (int) recovery_ivl; -# else - return 0; -# endif -} - - -// -------------------------------------------------------------------------- -// Set socket ZMQ_RECOVERY_IVL_MSEC value -// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** - -void -zsocket_set_recovery_ivl_msec (void *zocket, int recovery_ivl_msec) -{ -# if defined (ZMQ_RECOVERY_IVL_MSEC) - int64_t value = recovery_ivl_msec; - int rc = zmq_setsockopt (zocket, ZMQ_RECOVERY_IVL_MSEC, &value, sizeof (int64_t)); - assert (rc == 0 || zmq_errno () == ETERM); -# endif -} - - -// -------------------------------------------------------------------------- -// Return socket ZMQ_RECOVERY_IVL_MSEC value -// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** - -int -zsocket_recovery_ivl_msec (void *zocket) -{ -# if defined (ZMQ_RECOVERY_IVL_MSEC) - int64_t recovery_ivl_msec; - size_t option_len = sizeof (int64_t); - zmq_getsockopt (zocket, ZMQ_RECOVERY_IVL_MSEC, &recovery_ivl_msec, &option_len); - return (int) recovery_ivl_msec; -# else - return 0; -# endif -} - - -// -------------------------------------------------------------------------- -// Set socket ZMQ_MCAST_LOOP value -// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** - -void -zsocket_set_mcast_loop (void *zocket, int mcast_loop) -{ -# if defined (ZMQ_MCAST_LOOP) - int64_t value = mcast_loop; - int rc = zmq_setsockopt (zocket, ZMQ_MCAST_LOOP, &value, sizeof (int64_t)); - assert (rc == 0 || zmq_errno () == ETERM); -# endif -} - - -// -------------------------------------------------------------------------- -// Return socket ZMQ_MCAST_LOOP value -// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** - -int -zsocket_mcast_loop (void *zocket) -{ -# if defined (ZMQ_MCAST_LOOP) - int64_t mcast_loop; - size_t option_len = sizeof (int64_t); - zmq_getsockopt (zocket, ZMQ_MCAST_LOOP, &mcast_loop, &option_len); - return (int) mcast_loop; -# else - return 0; -# endif -} - - -# if (ZMQ_VERSION_MINOR == 2) -// -------------------------------------------------------------------------- -// Set socket ZMQ_RCVTIMEO value -// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** - -void -zsocket_set_rcvtimeo (void *zocket, int rcvtimeo) -{ -# if defined (ZMQ_RCVTIMEO) - int rc = zmq_setsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int)); - assert (rc == 0 || zmq_errno () == ETERM); -# endif -} - - -// -------------------------------------------------------------------------- -// Return socket ZMQ_RCVTIMEO value -// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** - -int -zsocket_rcvtimeo (void *zocket) -{ -# if defined (ZMQ_RCVTIMEO) - int rcvtimeo; - size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, &option_len); - return rcvtimeo; -# else - return 0; -# endif -} - - -# endif -# if (ZMQ_VERSION_MINOR == 2) -// -------------------------------------------------------------------------- -// Set socket ZMQ_SNDTIMEO value -// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** - -void -zsocket_set_sndtimeo (void *zocket, int sndtimeo) -{ -# if defined (ZMQ_SNDTIMEO) - int rc = zmq_setsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, sizeof (int)); - assert (rc == 0 || zmq_errno () == ETERM); -# endif -} - - -// -------------------------------------------------------------------------- -// Return socket ZMQ_SNDTIMEO value -// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** - -int -zsocket_sndtimeo (void *zocket) -{ -# if defined (ZMQ_SNDTIMEO) - int sndtimeo; + int recovery_ivl; size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, &option_len); - return sndtimeo; + zmq_getsockopt (zocket, ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len); + return recovery_ivl; # else return 0; # endif } -# endif // -------------------------------------------------------------------------- // Set socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** @@ -1663,8 +1709,7 @@ void zsocket_set_sndbuf (void *zocket, int sndbuf) { # if defined (ZMQ_SNDBUF) - uint64_t value = sndbuf; - int rc = zmq_setsockopt (zocket, ZMQ_SNDBUF, &value, sizeof (uint64_t)); + int rc = zmq_setsockopt (zocket, ZMQ_SNDBUF, &sndbuf, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } @@ -1678,10 +1723,10 @@ int zsocket_sndbuf (void *zocket) { # if defined (ZMQ_SNDBUF) - uint64_t sndbuf; - size_t option_len = sizeof (uint64_t); + int sndbuf; + size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_SNDBUF, &sndbuf, &option_len); - return (int) sndbuf; + return sndbuf; # else return 0; # endif @@ -1696,8 +1741,7 @@ void zsocket_set_rcvbuf (void *zocket, int rcvbuf) { # if defined (ZMQ_RCVBUF) - uint64_t value = rcvbuf; - int rc = zmq_setsockopt (zocket, ZMQ_RCVBUF, &value, sizeof (uint64_t)); + int rc = zmq_setsockopt (zocket, ZMQ_RCVBUF, &rcvbuf, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } @@ -1711,10 +1755,10 @@ int zsocket_rcvbuf (void *zocket) { # if defined (ZMQ_RCVBUF) - uint64_t rcvbuf; - size_t option_len = sizeof (uint64_t); + int rcvbuf; + size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RCVBUF, &rcvbuf, &option_len); - return (int) rcvbuf; + return rcvbuf; # else return 0; # endif @@ -1850,53 +1894,64 @@ zsocket_backlog (void *zocket) // -------------------------------------------------------------------------- -// Set socket ZMQ_SUBSCRIBE value +// Set socket ZMQ_MAXMSGSIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void -zsocket_set_subscribe (void *zocket, const char * subscribe) +zsocket_set_maxmsgsize (void *zocket, int maxmsgsize) { -# if defined (ZMQ_SUBSCRIBE) - if (zsockopt_type (zocket) != ZMQ_SUB) { - printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); - assert (false); - } - int rc = zmq_setsockopt (zocket, ZMQ_SUBSCRIBE, subscribe, strlen (subscribe)); +# if defined (ZMQ_MAXMSGSIZE) + int64_t value = maxmsgsize; + int rc = zmq_setsockopt (zocket, ZMQ_MAXMSGSIZE, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- -// Set socket ZMQ_UNSUBSCRIBE value +// Return socket ZMQ_MAXMSGSIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -void -zsocket_set_unsubscribe (void *zocket, const char * unsubscribe) +int +zsocket_maxmsgsize (void *zocket) { -# if defined (ZMQ_UNSUBSCRIBE) - if (zsockopt_type (zocket) != ZMQ_SUB) { - printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); - assert (false); - } - int rc = zmq_setsockopt (zocket, ZMQ_UNSUBSCRIBE, unsubscribe, strlen (unsubscribe)); - assert (rc == 0 || zmq_errno () == ETERM); +# if defined (ZMQ_MAXMSGSIZE) + int64_t maxmsgsize; + size_t option_len = sizeof (int64_t); + zmq_getsockopt (zocket, ZMQ_MAXMSGSIZE, &maxmsgsize, &option_len); + return (int) maxmsgsize; +# else + return 0; # endif } // -------------------------------------------------------------------------- -// Return socket ZMQ_TYPE value +// Set socket ZMQ_MULTICAST_HOPS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** -int -zsocket_type (void *zocket) -{ -# if defined (ZMQ_TYPE) - int type; +void +zsocket_set_multicast_hops (void *zocket, int multicast_hops) +{ +# if defined (ZMQ_MULTICAST_HOPS) + int rc = zmq_setsockopt (zocket, ZMQ_MULTICAST_HOPS, &multicast_hops, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_MULTICAST_HOPS value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_multicast_hops (void *zocket) +{ +# if defined (ZMQ_MULTICAST_HOPS) + int multicast_hops; size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_TYPE, &type, &option_len); - return type; + zmq_getsockopt (zocket, ZMQ_MULTICAST_HOPS, &multicast_hops, &option_len); + return multicast_hops; # else return 0; # endif @@ -1904,17 +1959,31 @@ zsocket_type (void *zocket) // -------------------------------------------------------------------------- -// Return socket ZMQ_RCVMORE value +// Set socket ZMQ_RCVTIMEO value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_rcvtimeo (void *zocket, int rcvtimeo) +{ +# if defined (ZMQ_RCVTIMEO) + int rc = zmq_setsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_rcvmore (void *zocket) +zsocket_rcvtimeo (void *zocket) { -# if defined (ZMQ_RCVMORE) - int64_t rcvmore; - size_t option_len = sizeof (int64_t); - zmq_getsockopt (zocket, ZMQ_RCVMORE, &rcvmore, &option_len); - return (int) rcvmore; +# if defined (ZMQ_RCVTIMEO) + int rcvtimeo; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, &option_len); + return rcvtimeo; # else return 0; # endif @@ -1922,17 +1991,31 @@ zsocket_rcvmore (void *zocket) // -------------------------------------------------------------------------- -// Return socket ZMQ_FD value +// Set socket ZMQ_SNDTIMEO value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_sndtimeo (void *zocket, int sndtimeo) +{ +# if defined (ZMQ_SNDTIMEO) + int rc = zmq_setsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_fd (void *zocket) +zsocket_sndtimeo (void *zocket) { -# if defined (ZMQ_FD) - int fd; +# if defined (ZMQ_SNDTIMEO) + int sndtimeo; size_t option_len = sizeof (int); - zmq_getsockopt (zocket, ZMQ_FD, &fd, &option_len); - return fd; + zmq_getsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, &option_len); + return sndtimeo; # else return 0; # endif @@ -1940,39 +2023,1305 @@ zsocket_fd (void *zocket) // -------------------------------------------------------------------------- -// Return socket ZMQ_EVENTS value +// Set socket ZMQ_XPUB_VERBOSE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_xpub_verbose (void *zocket, int xpub_verbose) +{ +# if defined (ZMQ_XPUB_VERBOSE) + if (zsocket_type (zocket) != ZMQ_XPUB) { + printf ("ZMQ_XPUB_VERBOSE is not valid on %s sockets\n", zsocket_type_str (zocket)); + assert (false); + } + int rc = zmq_setsockopt (zocket, ZMQ_XPUB_VERBOSE, &xpub_verbose, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_TCP_KEEPALIVE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive) +{ +# if defined (ZMQ_TCP_KEEPALIVE) + int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE, &tcp_keepalive, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_TCP_KEEPALIVE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int -zsocket_events (void *zocket) +zsocket_tcp_keepalive (void *zocket) { -# if defined (ZMQ_EVENTS) - uint32_t events; - size_t option_len = sizeof (uint32_t); - zmq_getsockopt (zocket, ZMQ_EVENTS, &events, &option_len); - return (int) events; +# if defined (ZMQ_TCP_KEEPALIVE) + int tcp_keepalive; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE, &tcp_keepalive, &option_len); + return tcp_keepalive; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_TCP_KEEPALIVE_IDLE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle) +{ +# if defined (ZMQ_TCP_KEEPALIVE_IDLE) + int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_TCP_KEEPALIVE_IDLE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_tcp_keepalive_idle (void *zocket) +{ +# if defined (ZMQ_TCP_KEEPALIVE_IDLE) + int tcp_keepalive_idle; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, &option_len); + return tcp_keepalive_idle; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_TCP_KEEPALIVE_CNT value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt) +{ +# if defined (ZMQ_TCP_KEEPALIVE_CNT) + int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_TCP_KEEPALIVE_CNT value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_tcp_keepalive_cnt (void *zocket) +{ +# if defined (ZMQ_TCP_KEEPALIVE_CNT) + int tcp_keepalive_cnt; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, &option_len); + return tcp_keepalive_cnt; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_TCP_KEEPALIVE_INTVL value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl) +{ +# if defined (ZMQ_TCP_KEEPALIVE_INTVL) + int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_TCP_KEEPALIVE_INTVL value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_tcp_keepalive_intvl (void *zocket) +{ +# if defined (ZMQ_TCP_KEEPALIVE_INTVL) + int tcp_keepalive_intvl; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, &option_len); + return tcp_keepalive_intvl; # else return 0; # endif } +// -------------------------------------------------------------------------- +// Set socket ZMQ_TCP_ACCEPT_FILTER value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter) +{ +# if defined (ZMQ_TCP_ACCEPT_FILTER) + int rc = zmq_setsockopt (zocket, ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, strlen (tcp_accept_filter)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_TCP_ACCEPT_FILTER value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +char * +zsocket_tcp_accept_filter (void *zocket) +{ +# if defined (ZMQ_TCP_ACCEPT_FILTER) + size_t option_len = 255; + char *tcp_accept_filter = (char *) zmalloc (option_len); + zmq_getsockopt (zocket, ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, &option_len); + return (char *) tcp_accept_filter; +# else + return NULL; +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_RCVMORE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_rcvmore (void *zocket) +{ +# if defined (ZMQ_RCVMORE) + int rcvmore; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_RCVMORE, &rcvmore, &option_len); + return rcvmore; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_FD value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_fd (void *zocket) +{ +# if defined (ZMQ_FD) + int fd; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_FD, &fd, &option_len); + return fd; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_EVENTS value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_events (void *zocket) +{ +# if defined (ZMQ_EVENTS) + int events; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_EVENTS, &events, &option_len); + return events; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_LAST_ENDPOINT value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +char * +zsocket_last_endpoint (void *zocket) +{ +# if defined (ZMQ_LAST_ENDPOINT) + size_t option_len = 255; + char *last_endpoint = (char *) zmalloc (option_len); + zmq_getsockopt (zocket, ZMQ_LAST_ENDPOINT, last_endpoint, &option_len); + return (char *) last_endpoint; +# else + return NULL; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket high-water mark, emulating 2.x API + +void +zsocket_set_hwm (void *zocket, int hwm) +{ + zsocket_set_sndhwm (zocket, hwm); + zsocket_set_rcvhwm (zocket, hwm); +} + +#endif + +#if (ZMQ_VERSION_MAJOR == 2) +// -------------------------------------------------------------------------- +// Set socket ZMQ_HWM value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_hwm (void *zocket, int hwm) +{ +# if defined (ZMQ_HWM) + uint64_t value = hwm; + int rc = zmq_setsockopt (zocket, ZMQ_HWM, &value, sizeof (uint64_t)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_HWM value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_hwm (void *zocket) +{ +# if defined (ZMQ_HWM) + uint64_t hwm; + size_t option_len = sizeof (uint64_t); + zmq_getsockopt (zocket, ZMQ_HWM, &hwm, &option_len); + return (int) hwm; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_SWAP value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_swap (void *zocket, int swap) +{ +# if defined (ZMQ_SWAP) + int64_t value = swap; + int rc = zmq_setsockopt (zocket, ZMQ_SWAP, &value, sizeof (int64_t)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_SWAP value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_swap (void *zocket) +{ +# if defined (ZMQ_SWAP) + int64_t swap; + size_t option_len = sizeof (int64_t); + zmq_getsockopt (zocket, ZMQ_SWAP, &swap, &option_len); + return (int) swap; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_AFFINITY value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_affinity (void *zocket, int affinity) +{ +# if defined (ZMQ_AFFINITY) + uint64_t value = affinity; + int rc = zmq_setsockopt (zocket, ZMQ_AFFINITY, &value, sizeof (uint64_t)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_AFFINITY value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_affinity (void *zocket) +{ +# if defined (ZMQ_AFFINITY) + uint64_t affinity; + size_t option_len = sizeof (uint64_t); + zmq_getsockopt (zocket, ZMQ_AFFINITY, &affinity, &option_len); + return (int) affinity; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_IDENTITY value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_identity (void *zocket, const char * identity) +{ +# if defined (ZMQ_IDENTITY) + int rc = zmq_setsockopt (zocket, ZMQ_IDENTITY, identity, strlen (identity)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_IDENTITY value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +char * +zsocket_identity (void *zocket) +{ +# if defined (ZMQ_IDENTITY) + size_t option_len = 255; + char *identity = (char *) zmalloc (option_len); + zmq_getsockopt (zocket, ZMQ_IDENTITY, identity, &option_len); + return (char *) identity; +# else + return NULL; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_RATE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_rate (void *zocket, int rate) +{ +# if defined (ZMQ_RATE) + int64_t value = rate; + int rc = zmq_setsockopt (zocket, ZMQ_RATE, &value, sizeof (int64_t)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_RATE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_rate (void *zocket) +{ +# if defined (ZMQ_RATE) + int64_t rate; + size_t option_len = sizeof (int64_t); + zmq_getsockopt (zocket, ZMQ_RATE, &rate, &option_len); + return (int) rate; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_RECOVERY_IVL value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_recovery_ivl (void *zocket, int recovery_ivl) +{ +# if defined (ZMQ_RECOVERY_IVL) + int64_t value = recovery_ivl; + int rc = zmq_setsockopt (zocket, ZMQ_RECOVERY_IVL, &value, sizeof (int64_t)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_RECOVERY_IVL value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_recovery_ivl (void *zocket) +{ +# if defined (ZMQ_RECOVERY_IVL) + int64_t recovery_ivl; + size_t option_len = sizeof (int64_t); + zmq_getsockopt (zocket, ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len); + return (int) recovery_ivl; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_RECOVERY_IVL_MSEC value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_recovery_ivl_msec (void *zocket, int recovery_ivl_msec) +{ +# if defined (ZMQ_RECOVERY_IVL_MSEC) + int64_t value = recovery_ivl_msec; + int rc = zmq_setsockopt (zocket, ZMQ_RECOVERY_IVL_MSEC, &value, sizeof (int64_t)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_RECOVERY_IVL_MSEC value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_recovery_ivl_msec (void *zocket) +{ +# if defined (ZMQ_RECOVERY_IVL_MSEC) + int64_t recovery_ivl_msec; + size_t option_len = sizeof (int64_t); + zmq_getsockopt (zocket, ZMQ_RECOVERY_IVL_MSEC, &recovery_ivl_msec, &option_len); + return (int) recovery_ivl_msec; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_MCAST_LOOP value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_mcast_loop (void *zocket, int mcast_loop) +{ +# if defined (ZMQ_MCAST_LOOP) + int64_t value = mcast_loop; + int rc = zmq_setsockopt (zocket, ZMQ_MCAST_LOOP, &value, sizeof (int64_t)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_MCAST_LOOP value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_mcast_loop (void *zocket) +{ +# if defined (ZMQ_MCAST_LOOP) + int64_t mcast_loop; + size_t option_len = sizeof (int64_t); + zmq_getsockopt (zocket, ZMQ_MCAST_LOOP, &mcast_loop, &option_len); + return (int) mcast_loop; +# else + return 0; +# endif +} + + +# if (ZMQ_VERSION_MINOR == 2) +// -------------------------------------------------------------------------- +// Set socket ZMQ_RCVTIMEO value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_rcvtimeo (void *zocket, int rcvtimeo) +{ +# if defined (ZMQ_RCVTIMEO) + int rc = zmq_setsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_RCVTIMEO value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_rcvtimeo (void *zocket) +{ +# if defined (ZMQ_RCVTIMEO) + int rcvtimeo; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, &option_len); + return rcvtimeo; +# else + return 0; +# endif +} + + +# endif +# if (ZMQ_VERSION_MINOR == 2) +// -------------------------------------------------------------------------- +// Set socket ZMQ_SNDTIMEO value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_sndtimeo (void *zocket, int sndtimeo) +{ +# if defined (ZMQ_SNDTIMEO) + int rc = zmq_setsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_SNDTIMEO value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_sndtimeo (void *zocket) +{ +# if defined (ZMQ_SNDTIMEO) + int sndtimeo; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, &option_len); + return sndtimeo; +# else + return 0; +# endif +} + + +# endif +// -------------------------------------------------------------------------- +// Set socket ZMQ_SNDBUF value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_sndbuf (void *zocket, int sndbuf) +{ +# if defined (ZMQ_SNDBUF) + uint64_t value = sndbuf; + int rc = zmq_setsockopt (zocket, ZMQ_SNDBUF, &value, sizeof (uint64_t)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_SNDBUF value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_sndbuf (void *zocket) +{ +# if defined (ZMQ_SNDBUF) + uint64_t sndbuf; + size_t option_len = sizeof (uint64_t); + zmq_getsockopt (zocket, ZMQ_SNDBUF, &sndbuf, &option_len); + return (int) sndbuf; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_RCVBUF value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_rcvbuf (void *zocket, int rcvbuf) +{ +# if defined (ZMQ_RCVBUF) + uint64_t value = rcvbuf; + int rc = zmq_setsockopt (zocket, ZMQ_RCVBUF, &value, sizeof (uint64_t)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_RCVBUF value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_rcvbuf (void *zocket) +{ +# if defined (ZMQ_RCVBUF) + uint64_t rcvbuf; + size_t option_len = sizeof (uint64_t); + zmq_getsockopt (zocket, ZMQ_RCVBUF, &rcvbuf, &option_len); + return (int) rcvbuf; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_LINGER value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_linger (void *zocket, int linger) +{ +# if defined (ZMQ_LINGER) + int rc = zmq_setsockopt (zocket, ZMQ_LINGER, &linger, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_LINGER value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_linger (void *zocket) +{ +# if defined (ZMQ_LINGER) + int linger; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_LINGER, &linger, &option_len); + return linger; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_RECONNECT_IVL value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl) +{ +# if defined (ZMQ_RECONNECT_IVL) + int rc = zmq_setsockopt (zocket, ZMQ_RECONNECT_IVL, &reconnect_ivl, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_RECONNECT_IVL value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_reconnect_ivl (void *zocket) +{ +# if defined (ZMQ_RECONNECT_IVL) + int reconnect_ivl; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_RECONNECT_IVL, &reconnect_ivl, &option_len); + return reconnect_ivl; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_RECONNECT_IVL_MAX value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max) +{ +# if defined (ZMQ_RECONNECT_IVL_MAX) + int rc = zmq_setsockopt (zocket, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_RECONNECT_IVL_MAX value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_reconnect_ivl_max (void *zocket) +{ +# if defined (ZMQ_RECONNECT_IVL_MAX) + int reconnect_ivl_max; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, &option_len); + return reconnect_ivl_max; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_BACKLOG value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_backlog (void *zocket, int backlog) +{ +# if defined (ZMQ_BACKLOG) + int rc = zmq_setsockopt (zocket, ZMQ_BACKLOG, &backlog, sizeof (int)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_BACKLOG value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_backlog (void *zocket) +{ +# if defined (ZMQ_BACKLOG) + int backlog; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_BACKLOG, &backlog, &option_len); + return backlog; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_SUBSCRIBE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_subscribe (void *zocket, const char * subscribe) +{ +# if defined (ZMQ_SUBSCRIBE) + if (zsocket_type (zocket) != ZMQ_SUB) { + printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); + assert (false); + } + int rc = zmq_setsockopt (zocket, ZMQ_SUBSCRIBE, subscribe, strlen (subscribe)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Set socket ZMQ_UNSUBSCRIBE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +void +zsocket_set_unsubscribe (void *zocket, const char * unsubscribe) +{ +# if defined (ZMQ_UNSUBSCRIBE) + if (zsocket_type (zocket) != ZMQ_SUB) { + printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); + assert (false); + } + int rc = zmq_setsockopt (zocket, ZMQ_UNSUBSCRIBE, unsubscribe, strlen (unsubscribe)); + assert (rc == 0 || zmq_errno () == ETERM); +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_TYPE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_type (void *zocket) +{ +# if defined (ZMQ_TYPE) + int type; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_TYPE, &type, &option_len); + return type; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_RCVMORE value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_rcvmore (void *zocket) +{ +# if defined (ZMQ_RCVMORE) + int64_t rcvmore; + size_t option_len = sizeof (int64_t); + zmq_getsockopt (zocket, ZMQ_RCVMORE, &rcvmore, &option_len); + return (int) rcvmore; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_FD value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_fd (void *zocket) +{ +# if defined (ZMQ_FD) + int fd; + size_t option_len = sizeof (int); + zmq_getsockopt (zocket, ZMQ_FD, &fd, &option_len); + return fd; +# else + return 0; +# endif +} + + +// -------------------------------------------------------------------------- +// Return socket ZMQ_EVENTS value +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsocket_events (void *zocket) +{ +# if defined (ZMQ_EVENTS) + uint32_t events; + size_t option_len = sizeof (uint32_t); + zmq_getsockopt (zocket, ZMQ_EVENTS, &events, &option_len); + return (int) events; +# else + return 0; +# endif +} + + +#endif + +// -------------------------------------------------------------------------- +// Selftest +// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** + +int +zsockopt_test (bool verbose) +{ + printf (" * zsockopt: "); + + // @selftest + zctx_t *ctx = zctx_new (); + assert (ctx); + void *zocket; +#if (ZMQ_VERSION_MAJOR == 4) +# if defined (ZMQ_IPV6) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_ipv6 (zocket, 1); + assert (zsocket_ipv6 (zocket) == 1); + zsocket_ipv6 (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_IMMEDIATE) + zocket = zsocket_new (ctx, ZMQ_DEALER); + assert (zocket); + zsocket_set_immediate (zocket, 1); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_ROUTER_RAW) + zocket = zsocket_new (ctx, ZMQ_ROUTER); + assert (zocket); + zsocket_set_router_raw (zocket, 1); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_IPV4ONLY) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_ipv4only (zocket, 1); + assert (zsocket_ipv4only (zocket) == 1); + zsocket_ipv4only (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) + zocket = zsocket_new (ctx, ZMQ_PUB); + assert (zocket); + zsocket_set_delay_attach_on_connect (zocket, 1); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_ROUTER_MANDATORY) + zocket = zsocket_new (ctx, ZMQ_ROUTER); + assert (zocket); + zsocket_set_router_mandatory (zocket, 1); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_PROBE_ROUTER) + zocket = zsocket_new (ctx, ZMQ_DEALER); + assert (zocket); + zsocket_probe_router (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_REQ_RELAXED) + zocket = zsocket_new (ctx, ZMQ_REQ); + assert (zocket); + zsocket_set_req_relaxed (zocket, 1); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_REQ_CORRELATE) + zocket = zsocket_new (ctx, ZMQ_REQ); + assert (zocket); + zsocket_set_req_correlate (zocket, 1); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_CONFLATE) + zocket = zsocket_new (ctx, ZMQ_PUSH); + assert (zocket); + zsocket_set_conflate (zocket, 1); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_PLAIN_SERVER) + zocket = zsocket_new (ctx, ZMQ_PUB); + assert (zocket); + zsocket_set_plain_server (zocket, 1); + assert (zsocket_plain_server (zocket) == 1); + zsocket_plain_server (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_PLAIN_USERNAME) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_plain_username (zocket, "test"); + char *plain_username = zsocket_plain_username (zocket); + assert (plain_username); + free (plain_username); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_PLAIN_PASSWORD) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_plain_password (zocket, "test"); + char *plain_password = zsocket_plain_password (zocket); + assert (plain_password); + free (plain_password); + zsocket_destroy (ctx, zocket); +# endif +# if defined (HAVE_LIBSODIUM) +# if defined (ZMQ_CURVE_SERVER) + zocket = zsocket_new (ctx, ZMQ_PUB); + assert (zocket); + zsocket_set_curve_server (zocket, 1); + assert (zsocket_curve_server (zocket) == 1); + zsocket_curve_server (zocket); + zsocket_destroy (ctx, zocket); +# endif +# endif +# if defined (HAVE_LIBSODIUM) +# if defined (ZMQ_CURVE_PUBLICKEY) + zocket = zsocket_new (ctx, ZMQ_PUB); + assert (zocket); + zsocket_set_curve_publickey (zocket, "Yne@$w-vo}U?@Lns47E1%kR.o@n%FcmmsL/@{H8]yf7"); + char *curve_serverkey = zsocket_curve_serverkey (zocket); + assert (curve_serverkey); + free (curve_serverkey); + zsocket_destroy (ctx, zocket); +# endif +# endif +# if defined (ZMQ_ZAP_DOMAIN) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_zap_domain (zocket, "test"); + char *zap_domain = zsocket_zap_domain (zocket); + assert (zap_domain); + free (zap_domain); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_TYPE) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_type (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_SNDHWM) + zocket = zsocket_new (ctx, ZMQ_PUB); + assert (zocket); + zsocket_set_sndhwm (zocket, 1); + assert (zsocket_sndhwm (zocket) == 1); + zsocket_sndhwm (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_RCVHWM) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_rcvhwm (zocket, 1); + assert (zsocket_rcvhwm (zocket) == 1); + zsocket_rcvhwm (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_AFFINITY) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_affinity (zocket, 1); + assert (zsocket_affinity (zocket) == 1); + zsocket_affinity (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_SUBSCRIBE) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_subscribe (zocket, "test"); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_UNSUBSCRIBE) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_unsubscribe (zocket, "test"); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_IDENTITY) + zocket = zsocket_new (ctx, ZMQ_DEALER); + assert (zocket); + zsocket_set_identity (zocket, "test"); + char *identity = zsocket_identity (zocket); + assert (identity); + free (identity); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_RATE) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_rate (zocket, 1); + assert (zsocket_rate (zocket) == 1); + zsocket_rate (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_RECOVERY_IVL) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_recovery_ivl (zocket, 1); + assert (zsocket_recovery_ivl (zocket) == 1); + zsocket_recovery_ivl (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_SNDBUF) + zocket = zsocket_new (ctx, ZMQ_PUB); + assert (zocket); + zsocket_set_sndbuf (zocket, 1); + assert (zsocket_sndbuf (zocket) == 1); + zsocket_sndbuf (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_RCVBUF) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_rcvbuf (zocket, 1); + assert (zsocket_rcvbuf (zocket) == 1); + zsocket_rcvbuf (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_LINGER) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_linger (zocket, 1); + assert (zsocket_linger (zocket) == 1); + zsocket_linger (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_RECONNECT_IVL) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_reconnect_ivl (zocket, 1); + assert (zsocket_reconnect_ivl (zocket) == 1); + zsocket_reconnect_ivl (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_RECONNECT_IVL_MAX) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_reconnect_ivl_max (zocket, 1); + assert (zsocket_reconnect_ivl_max (zocket) == 1); + zsocket_reconnect_ivl_max (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_BACKLOG) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_backlog (zocket, 1); + assert (zsocket_backlog (zocket) == 1); + zsocket_backlog (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_MAXMSGSIZE) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_maxmsgsize (zocket, 1); + assert (zsocket_maxmsgsize (zocket) == 1); + zsocket_maxmsgsize (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_MULTICAST_HOPS) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_multicast_hops (zocket, 1); + assert (zsocket_multicast_hops (zocket) == 1); + zsocket_multicast_hops (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_RCVTIMEO) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_rcvtimeo (zocket, 1); + assert (zsocket_rcvtimeo (zocket) == 1); + zsocket_rcvtimeo (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_SNDTIMEO) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_sndtimeo (zocket, 1); + assert (zsocket_sndtimeo (zocket) == 1); + zsocket_sndtimeo (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_XPUB_VERBOSE) + zocket = zsocket_new (ctx, ZMQ_XPUB); + assert (zocket); + zsocket_set_xpub_verbose (zocket, 1); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_TCP_KEEPALIVE) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_tcp_keepalive (zocket, 1); + assert (zsocket_tcp_keepalive (zocket) == 1); + zsocket_tcp_keepalive (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_TCP_KEEPALIVE_IDLE) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_tcp_keepalive_idle (zocket, 1); + assert (zsocket_tcp_keepalive_idle (zocket) == 1); + zsocket_tcp_keepalive_idle (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_TCP_KEEPALIVE_CNT) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_tcp_keepalive_cnt (zocket, 1); + assert (zsocket_tcp_keepalive_cnt (zocket) == 1); + zsocket_tcp_keepalive_cnt (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_TCP_KEEPALIVE_INTVL) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_tcp_keepalive_intvl (zocket, 1); + assert (zsocket_tcp_keepalive_intvl (zocket) == 1); + zsocket_tcp_keepalive_intvl (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_TCP_ACCEPT_FILTER) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_tcp_accept_filter (zocket, "127.0.0.1"); + char *tcp_accept_filter = zsocket_tcp_accept_filter (zocket); + assert (tcp_accept_filter); + free (tcp_accept_filter); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_RCVMORE) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_rcvmore (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_FD) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_fd (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_EVENTS) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_events (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_LAST_ENDPOINT) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + char *last_endpoint = zsocket_last_endpoint (zocket); + assert (last_endpoint); + free (last_endpoint); + zsocket_destroy (ctx, zocket); +# endif + + zocket = zsocket_new (ctx, ZMQ_SUB); + zsocket_set_hwm (zocket, 1); #endif -// -------------------------------------------------------------------------- -// Selftest -// *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** - -int -zsockopt_test (bool verbose) -{ - printf (" * zsockopt: "); - - // @selftest - zctx_t *ctx = zctx_new (); - assert (ctx); - void *zocket; #if (ZMQ_VERSION_MAJOR == 3) +# if defined (ZMQ_ROUTER_RAW) + zocket = zsocket_new (ctx, ZMQ_ROUTER); + assert (zocket); + zsocket_set_router_raw (zocket, 1); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_IPV4ONLY) + zocket = zsocket_new (ctx, ZMQ_SUB); + assert (zocket); + zsocket_set_ipv4only (zocket, 1); + assert (zsocket_ipv4only (zocket) == 1); + zsocket_ipv4only (zocket); + zsocket_destroy (ctx, zocket); +# endif +# if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) + zocket = zsocket_new (ctx, ZMQ_PUB); + assert (zocket); + zsocket_set_delay_attach_on_connect (zocket, 1); + zsocket_destroy (ctx, zocket); +# endif # if defined (ZMQ_TYPE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); @@ -2120,32 +3469,6 @@ zsockopt_test (bool verbose) zsocket_sndtimeo (zocket); zsocket_destroy (ctx, zocket); # endif -# if defined (ZMQ_IPV6) - zocket = zsocket_new (ctx, ZMQ_SUB); - assert (zocket); - zsocket_set_ipv6 (zocket, 1); - assert (zsocket_ipv6 (zocket) == 1); - zsocket_ipv6 (zocket); - zsocket_destroy (ctx, zocket); -# endif -# if defined (ZMQ_IMMEDIATE) - zocket = zsocket_new (ctx, ZMQ_DEALER); - assert (zocket); - zsocket_set_immediate (zocket, 1); - zsocket_destroy (ctx, zocket); -# endif -# if defined (ZMQ_ROUTER_MANDATORY) - zocket = zsocket_new (ctx, ZMQ_ROUTER); - assert (zocket); - zsocket_set_router_mandatory (zocket, 1); - zsocket_destroy (ctx, zocket); -# endif -# if defined (ZMQ_PROBE_ROUTER) - zocket = zsocket_new (ctx, ZMQ_DEALER); - assert (zocket); - zsocket_probe_router (zocket); - zsocket_destroy (ctx, zocket); -# endif # if defined (ZMQ_XPUB_VERBOSE) zocket = zsocket_new (ctx, ZMQ_XPUB); assert (zocket); @@ -2193,84 +3516,6 @@ zsockopt_test (bool verbose) free (tcp_accept_filter); zsocket_destroy (ctx, zocket); # endif -# if defined (ZMQ_PLAIN_SERVER) - zocket = zsocket_new (ctx, ZMQ_PUB); - assert (zocket); - zsocket_set_plain_server (zocket, 1); - assert (zsocket_plain_server (zocket) == 1); - zsocket_plain_server (zocket); - zsocket_destroy (ctx, zocket); -# endif -# if defined (ZMQ_PLAIN_USERNAME) - zocket = zsocket_new (ctx, ZMQ_SUB); - assert (zocket); - zsocket_set_plain_username (zocket, "test"); - char *plain_username = zsocket_plain_username (zocket); - assert (plain_username); - free (plain_username); - zsocket_destroy (ctx, zocket); -# endif -# if defined (ZMQ_PLAIN_PASSWORD) - zocket = zsocket_new (ctx, ZMQ_SUB); - assert (zocket); - zsocket_set_plain_password (zocket, "test"); - char *plain_password = zsocket_plain_password (zocket); - assert (plain_password); - free (plain_password); - zsocket_destroy (ctx, zocket); -# endif -# if defined (HAVE_LIBSODIUM) -# if defined (ZMQ_CURVE_SERVER) - zocket = zsocket_new (ctx, ZMQ_PUB); - assert (zocket); - zsocket_set_curve_server (zocket, 1); - assert (zsocket_curve_server (zocket) == 1); - zsocket_curve_server (zocket); - zsocket_destroy (ctx, zocket); -# endif -# endif -# if defined (HAVE_LIBSODIUM) -# if defined (ZMQ_CURVE_PUBLICKEY) - zocket = zsocket_new (ctx, ZMQ_PUB); - assert (zocket); - zsocket_set_curve_publickey (zocket, "Yne@$w-vo}U?@Lns47E1%kR.o@n%FcmmsL/@{H8]yf7"); - char *curve_serverkey = zsocket_curve_serverkey (zocket); - assert (curve_serverkey); - free (curve_serverkey); - zsocket_destroy (ctx, zocket); -# endif -# endif -# if defined (ZMQ_ZAP_DOMAIN) - zocket = zsocket_new (ctx, ZMQ_SUB); - assert (zocket); - zsocket_set_zap_domain (zocket, "test"); - char *zap_domain = zsocket_zap_domain (zocket); - assert (zap_domain); - free (zap_domain); - zsocket_destroy (ctx, zocket); -# endif # if defined (ZMQ_RCVMORE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); @@ -2297,26 +3542,6 @@ zsockopt_test (bool verbose) free (last_endpoint); zsocket_destroy (ctx, zocket); # endif -# if defined (ZMQ_ROUTER_RAW) - zocket = zsocket_new (ctx, ZMQ_ROUTER); - assert (zocket); - zsocket_set_router_raw (zocket, 1); - zsocket_destroy (ctx, zocket); -# endif -# if defined (ZMQ_IPV4ONLY) - zocket = zsocket_new (ctx, ZMQ_SUB); - assert (zocket); - zsocket_set_ipv4only (zocket, 1); - assert (zsocket_ipv4only (zocket) == 1); - zsocket_ipv4only (zocket); - zsocket_destroy (ctx, zocket); -# endif -# if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) - zocket = zsocket_new (ctx, ZMQ_PUB); - assert (zocket); - zsocket_set_delay_attach_on_connect (zocket, 1); - zsocket_destroy (ctx, zocket); -# endif zocket = zsocket_new (ctx, ZMQ_SUB); zsocket_set_hwm (zocket, 1);