Permalink
Browse files

Merge pull request #79 from hintjens/master

Added some missing setsockopts
  • Loading branch information...
methodmissing committed Oct 8, 2012
2 parents ffe7e0c + 84a0420 commit 6211a8f03d3d8cb4c35d1aab5f92d3fbc88126a9
Showing with 126 additions and 89 deletions.
  1. +87 −83 include/zsockopt.h
  2. +4 −1 sockopts.xml
  3. +35 −5 src/zsockopt.c
View
@@ -35,112 +35,114 @@ extern "C" {
// @interface
#if (ZMQ_VERSION_MAJOR == 2)
// Get socket options
-CZMQ_EXPORT int zsocket_hwm (void *socket);
-CZMQ_EXPORT int zsocket_swap (void *socket);
-CZMQ_EXPORT int zsocket_affinity (void *socket);
+CZMQ_EXPORT int zsocket_hwm (void *socket);
+CZMQ_EXPORT int zsocket_swap (void *socket);
+CZMQ_EXPORT int zsocket_affinity (void *socket);
// Returns freshly allocated string, free when done
-char * zsocket_identity (void *socket);
-CZMQ_EXPORT int zsocket_rate (void *socket);
-CZMQ_EXPORT int zsocket_recovery_ivl (void *socket);
-CZMQ_EXPORT int zsocket_recovery_ivl_msec (void *socket);
-CZMQ_EXPORT int zsocket_mcast_loop (void *socket);
+CZMQ_EXPORT char * zsocket_identity (void *socket);
+CZMQ_EXPORT int zsocket_rate (void *socket);
+CZMQ_EXPORT int zsocket_recovery_ivl (void *socket);
+CZMQ_EXPORT int zsocket_recovery_ivl_msec (void *socket);
+CZMQ_EXPORT int zsocket_mcast_loop (void *socket);
# if (ZMQ_VERSION_MINOR == 2)
-CZMQ_EXPORT int zsocket_rcvtimeo (void *socket);
+CZMQ_EXPORT int zsocket_rcvtimeo (void *socket);
# endif
# if (ZMQ_VERSION_MINOR == 2)
-CZMQ_EXPORT int zsocket_sndtimeo (void *socket);
+CZMQ_EXPORT int zsocket_sndtimeo (void *socket);
# endif
-CZMQ_EXPORT int zsocket_sndbuf (void *socket);
-CZMQ_EXPORT int zsocket_rcvbuf (void *socket);
-CZMQ_EXPORT int zsocket_linger (void *socket);
-CZMQ_EXPORT int zsocket_reconnect_ivl (void *socket);
-CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *socket);
-CZMQ_EXPORT int zsocket_backlog (void *socket);
-CZMQ_EXPORT int zsocket_type (void *socket);
-CZMQ_EXPORT int zsocket_rcvmore (void *socket);
-CZMQ_EXPORT int zsocket_fd (void *socket);
-CZMQ_EXPORT int zsocket_events (void *socket);
+CZMQ_EXPORT int zsocket_sndbuf (void *socket);
+CZMQ_EXPORT int zsocket_rcvbuf (void *socket);
+CZMQ_EXPORT int zsocket_linger (void *socket);
+CZMQ_EXPORT int zsocket_reconnect_ivl (void *socket);
+CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *socket);
+CZMQ_EXPORT int zsocket_backlog (void *socket);
+CZMQ_EXPORT int zsocket_type (void *socket);
+CZMQ_EXPORT int zsocket_rcvmore (void *socket);
+CZMQ_EXPORT int zsocket_fd (void *socket);
+CZMQ_EXPORT int zsocket_events (void *socket);
// Set socket options
-CZMQ_EXPORT void zsocket_set_hwm (void *socket, int hwm);
-CZMQ_EXPORT void zsocket_set_swap (void *socket, int swap);
-CZMQ_EXPORT void zsocket_set_affinity (void *socket, int affinity);
-CZMQ_EXPORT void zsocket_set_identity (void *socket, char * identity);
-CZMQ_EXPORT void zsocket_set_rate (void *socket, int rate);
-CZMQ_EXPORT void zsocket_set_recovery_ivl (void *socket, int recovery_ivl);
-CZMQ_EXPORT void zsocket_set_recovery_ivl_msec (void *socket, int recovery_ivl_msec);
-CZMQ_EXPORT void zsocket_set_mcast_loop (void *socket, int mcast_loop);
+CZMQ_EXPORT void zsocket_set_hwm (void *socket, int hwm);
+CZMQ_EXPORT void zsocket_set_swap (void *socket, int swap);
+CZMQ_EXPORT void zsocket_set_affinity (void *socket, int affinity);
+CZMQ_EXPORT void zsocket_set_identity (void *socket, char * identity);
+CZMQ_EXPORT void zsocket_set_rate (void *socket, int rate);
+CZMQ_EXPORT void zsocket_set_recovery_ivl (void *socket, int recovery_ivl);
+CZMQ_EXPORT void zsocket_set_recovery_ivl_msec (void *socket, int recovery_ivl_msec);
+CZMQ_EXPORT void zsocket_set_mcast_loop (void *socket, int mcast_loop);
# if (ZMQ_VERSION_MINOR == 2)
-CZMQ_EXPORT void zsocket_set_rcvtimeo (void *socket, int rcvtimeo);
+CZMQ_EXPORT void zsocket_set_rcvtimeo (void *socket, int rcvtimeo);
# endif
# if (ZMQ_VERSION_MINOR == 2)
-CZMQ_EXPORT void zsocket_set_sndtimeo (void *socket, int sndtimeo);
+CZMQ_EXPORT void zsocket_set_sndtimeo (void *socket, int sndtimeo);
# endif
-CZMQ_EXPORT void zsocket_set_sndbuf (void *socket, int sndbuf);
-CZMQ_EXPORT void zsocket_set_rcvbuf (void *socket, int rcvbuf);
-CZMQ_EXPORT void zsocket_set_linger (void *socket, int linger);
-CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *socket, int reconnect_ivl);
-CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *socket, int reconnect_ivl_max);
-CZMQ_EXPORT void zsocket_set_backlog (void *socket, int backlog);
-CZMQ_EXPORT void zsocket_set_subscribe (void *socket, char * subscribe);
-CZMQ_EXPORT void zsocket_set_unsubscribe (void *socket, char * unsubscribe);
+CZMQ_EXPORT void zsocket_set_sndbuf (void *socket, int sndbuf);
+CZMQ_EXPORT void zsocket_set_rcvbuf (void *socket, int rcvbuf);
+CZMQ_EXPORT void zsocket_set_linger (void *socket, int linger);
+CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *socket, int reconnect_ivl);
+CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *socket, int reconnect_ivl_max);
+CZMQ_EXPORT void zsocket_set_backlog (void *socket, int backlog);
+CZMQ_EXPORT void zsocket_set_subscribe (void *socket, char * subscribe);
+CZMQ_EXPORT void zsocket_set_unsubscribe (void *socket, char * unsubscribe);
#endif
#if (ZMQ_VERSION_MAJOR == 3)
// Get socket options
-CZMQ_EXPORT int zsocket_type (void *socket);
-CZMQ_EXPORT int zsocket_sndhwm (void *socket);
-CZMQ_EXPORT int zsocket_rcvhwm (void *socket);
-CZMQ_EXPORT int zsocket_affinity (void *socket);
+CZMQ_EXPORT int zsocket_type (void *socket);
+CZMQ_EXPORT int zsocket_sndhwm (void *socket);
+CZMQ_EXPORT int zsocket_rcvhwm (void *socket);
+CZMQ_EXPORT int zsocket_affinity (void *socket);
// Returns freshly allocated string, free when done
-char * zsocket_identity (void *socket);
-CZMQ_EXPORT int zsocket_rate (void *socket);
-CZMQ_EXPORT int zsocket_recovery_ivl (void *socket);
-CZMQ_EXPORT int zsocket_sndbuf (void *socket);
-CZMQ_EXPORT int zsocket_rcvbuf (void *socket);
-CZMQ_EXPORT int zsocket_linger (void *socket);
-CZMQ_EXPORT int zsocket_reconnect_ivl (void *socket);
-CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *socket);
-CZMQ_EXPORT int zsocket_backlog (void *socket);
-CZMQ_EXPORT int zsocket_maxmsgsize (void *socket);
-CZMQ_EXPORT int zsocket_multicast_hops (void *socket);
-CZMQ_EXPORT int zsocket_rcvtimeo (void *socket);
-CZMQ_EXPORT int zsocket_sndtimeo (void *socket);
-CZMQ_EXPORT int zsocket_ipv4only (void *socket);
-CZMQ_EXPORT int zsocket_rcvmore (void *socket);
-CZMQ_EXPORT int zsocket_fd (void *socket);
-CZMQ_EXPORT int zsocket_events (void *socket);
+CZMQ_EXPORT char * zsocket_identity (void *socket);
+CZMQ_EXPORT int zsocket_rate (void *socket);
+CZMQ_EXPORT int zsocket_recovery_ivl (void *socket);
+CZMQ_EXPORT int zsocket_sndbuf (void *socket);
+CZMQ_EXPORT int zsocket_rcvbuf (void *socket);
+CZMQ_EXPORT int zsocket_linger (void *socket);
+CZMQ_EXPORT int zsocket_reconnect_ivl (void *socket);
+CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *socket);
+CZMQ_EXPORT int zsocket_backlog (void *socket);
+CZMQ_EXPORT int zsocket_maxmsgsize (void *socket);
+CZMQ_EXPORT int zsocket_multicast_hops (void *socket);
+CZMQ_EXPORT int zsocket_rcvtimeo (void *socket);
+CZMQ_EXPORT int zsocket_sndtimeo (void *socket);
+CZMQ_EXPORT int zsocket_ipv4only (void *socket);
+CZMQ_EXPORT int zsocket_rcvmore (void *socket);
+CZMQ_EXPORT int zsocket_fd (void *socket);
+CZMQ_EXPORT int zsocket_events (void *socket);
// Returns freshly allocated string, free when done
-char * zsocket_last_endpoint (void *socket);
+CZMQ_EXPORT char * zsocket_last_endpoint (void *socket);
// Set socket options
-CZMQ_EXPORT void zsocket_set_sndhwm (void *socket, int sndhwm);
-CZMQ_EXPORT void zsocket_set_rcvhwm (void *socket, int rcvhwm);
-CZMQ_EXPORT void zsocket_set_affinity (void *socket, int affinity);
-CZMQ_EXPORT void zsocket_set_subscribe (void *socket, char * subscribe);
-CZMQ_EXPORT void zsocket_set_unsubscribe (void *socket, char * unsubscribe);
-CZMQ_EXPORT void zsocket_set_identity (void *socket, char * identity);
-CZMQ_EXPORT void zsocket_set_rate (void *socket, int rate);
-CZMQ_EXPORT void zsocket_set_recovery_ivl (void *socket, int recovery_ivl);
-CZMQ_EXPORT void zsocket_set_sndbuf (void *socket, int sndbuf);
-CZMQ_EXPORT void zsocket_set_rcvbuf (void *socket, int rcvbuf);
-CZMQ_EXPORT void zsocket_set_linger (void *socket, int linger);
-CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *socket, int reconnect_ivl);
-CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *socket, int reconnect_ivl_max);
-CZMQ_EXPORT void zsocket_set_backlog (void *socket, int backlog);
-CZMQ_EXPORT void zsocket_set_maxmsgsize (void *socket, int maxmsgsize);
-CZMQ_EXPORT void zsocket_set_multicast_hops (void *socket, int multicast_hops);
-CZMQ_EXPORT void zsocket_set_rcvtimeo (void *socket, int rcvtimeo);
-CZMQ_EXPORT void zsocket_set_sndtimeo (void *socket, int sndtimeo);
-CZMQ_EXPORT void zsocket_set_ipv4only (void *socket, int ipv4only);
-CZMQ_EXPORT void zsocket_set_router_behavior (void *socket, int router_behavior);
+CZMQ_EXPORT void zsocket_set_sndhwm (void *socket, int sndhwm);
+CZMQ_EXPORT void zsocket_set_rcvhwm (void *socket, int rcvhwm);
+CZMQ_EXPORT void zsocket_set_affinity (void *socket, int affinity);
+CZMQ_EXPORT void zsocket_set_subscribe (void *socket, char * subscribe);
+CZMQ_EXPORT void zsocket_set_unsubscribe (void *socket, char * unsubscribe);
+CZMQ_EXPORT void zsocket_set_identity (void *socket, char * identity);
+CZMQ_EXPORT void zsocket_set_rate (void *socket, int rate);
+CZMQ_EXPORT void zsocket_set_recovery_ivl (void *socket, int recovery_ivl);
+CZMQ_EXPORT void zsocket_set_sndbuf (void *socket, int sndbuf);
+CZMQ_EXPORT void zsocket_set_rcvbuf (void *socket, int rcvbuf);
+CZMQ_EXPORT void zsocket_set_linger (void *socket, int linger);
+CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *socket, int reconnect_ivl);
+CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *socket, int reconnect_ivl_max);
+CZMQ_EXPORT void zsocket_set_backlog (void *socket, int backlog);
+CZMQ_EXPORT void zsocket_set_maxmsgsize (void *socket, int maxmsgsize);
+CZMQ_EXPORT void zsocket_set_multicast_hops (void *socket, int multicast_hops);
+CZMQ_EXPORT void zsocket_set_rcvtimeo (void *socket, int rcvtimeo);
+CZMQ_EXPORT void zsocket_set_sndtimeo (void *socket, int sndtimeo);
+CZMQ_EXPORT void zsocket_set_ipv4only (void *socket, int ipv4only);
+CZMQ_EXPORT void zsocket_set_delay_attach_on_connect (void *socket, int delay_attach_on_connect);
+CZMQ_EXPORT void zsocket_set_router_mandatory (void *socket, int router_mandatory);
+CZMQ_EXPORT void zsocket_set_xpub_verbose (void *socket, int xpub_verbose);
// Emulation of widely-used 2.x socket options
-CZMQ_EXPORT void zsocket_set_hwm (void *socket, int hwm);
+void zsocket_set_hwm (void *socket, int hwm);
#endif
// Self test of this class
-CZMQ_EXPORT int zsockopt_test (Bool verbose);
+int zsockopt_test (Bool verbose);
// @end
// Deprecated function names
@@ -228,7 +230,9 @@ CZMQ_EXPORT int zsockopt_test (Bool verbose);
#define zsockopt_set_sndtimeo zsocket_set_sndtimeo
#define zsockopt_ipv4only zsocket_ipv4only
#define zsockopt_set_ipv4only zsocket_set_ipv4only
-#define zsockopt_set_router_behavior zsocket_set_router_behavior
+#define zsockopt_set_delay_attach_on_connect zsocket_set_delay_attach_on_connect
+#define zsockopt_set_router_mandatory zsocket_set_router_mandatory
+#define zsockopt_set_xpub_verbose zsocket_set_xpub_verbose
#define zsockopt_rcvmore zsocket_rcvmore
#define zsockopt_fd zsocket_fd
#define zsockopt_events zsocket_events
View
@@ -50,7 +50,10 @@
<option name = "rcvtimeo" type = "int" mode = "rw" test = "SUB" />
<option name = "sndtimeo" type = "int" mode = "rw" test = "SUB" />
<option name = "ipv4only" type = "int" mode = "rw" test = "SUB" />
- <option name = "router_behavior" type = "int" mode = "w" test = "ROUTER" />
+ <option name = "delay_attach_on_connect"
+ type = "int" mode = "w" test = "PUB" />
+ <option name = "router_mandatory" type = "int" mode = "w" test = "ROUTER" />
+ <option name = "xpub_verbose" type = "int" mode = "w" test = "XPUB" />
<option name = "rcvmore" type = "int" mode = "r" test = "SUB" />
<option name = "fd" type = "int" mode = "r" test = "SUB" />
<option name = "events" type = "int" mode = "r" test = "SUB" />
View
@@ -135,7 +135,7 @@ char *
zsocket_identity (void *socket)
{
size_t option_len = 255;
- char *identity = (char *) zmalloc (option_len);
+ char *identity = zmalloc (option_len);
zmq_getsockopt (socket, ZMQ_IDENTITY, &identity, &option_len);
return (char *) identity;
}
@@ -962,12 +962,34 @@ zsocket_ipv4only (void *socket)
// --------------------------------------------------------------------------
-// Set socket ZMQ_ROUTER_BEHAVIOR value
+// Set socket ZMQ_DELAY_ATTACH_ON_CONNECT value
+
+void
+zsocket_set_delay_attach_on_connect (void *socket, int delay_attach_on_connect)
+{
+ int rc = zmq_setsockopt (socket, ZMQ_DELAY_ATTACH_ON_CONNECT, &delay_attach_on_connect, sizeof (int));
+ assert (rc == 0 || errno == ETERM);
+}
+
+
+// --------------------------------------------------------------------------
+// Set socket ZMQ_ROUTER_MANDATORY value
+
+void
+zsocket_set_router_mandatory (void *socket, int router_mandatory)
+{
+ int rc = zmq_setsockopt (socket, ZMQ_ROUTER_MANDATORY, &router_mandatory, sizeof (int));
+ assert (rc == 0 || errno == ETERM);
+}
+
+
+// --------------------------------------------------------------------------
+// Set socket ZMQ_XPUB_VERBOSE value
void
-zsocket_set_router_behavior (void *socket, int router_behavior)
+zsocket_set_xpub_verbose (void *socket, int xpub_verbose)
{
- int rc = zmq_setsockopt (socket, ZMQ_ROUTER_BEHAVIOR, &router_behavior, sizeof (int));
+ int rc = zmq_setsockopt (socket, ZMQ_XPUB_VERBOSE, &xpub_verbose, sizeof (int));
assert (rc == 0 || errno == ETERM);
}
@@ -1288,9 +1310,17 @@ zsockopt_test (Bool verbose)
assert (zsocket_ipv4only (socket) == 1);
zsocket_ipv4only (socket);
zsocket_destroy (ctx, socket);
+ socket = zsocket_new (ctx, ZMQ_PUB);
+ assert (socket);
+ zsocket_set_delay_attach_on_connect (socket, 1);
+ zsocket_destroy (ctx, socket);
socket = zsocket_new (ctx, ZMQ_ROUTER);
assert (socket);
- zsocket_set_router_behavior (socket, 1);
+ zsocket_set_router_mandatory (socket, 1);
+ zsocket_destroy (ctx, socket);
+ socket = zsocket_new (ctx, ZMQ_XPUB);
+ assert (socket);
+ zsocket_set_xpub_verbose (socket, 1);
zsocket_destroy (ctx, socket);
socket = zsocket_new (ctx, ZMQ_SUB);
assert (socket);

0 comments on commit 6211a8f

Please sign in to comment.