summaryrefslogtreecommitdiff
path: root/src/options.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-06-12 15:24:08 +0200
committerMartin Sustrik <sustrik@250bpm.com>2011-06-12 15:24:08 +0200
commitff93f54653d099bddfed34a342906a3546e70496 (patch)
tree36f61ed29ae8f7335ab9086aea6afaa50aeb2305 /src/options.cpp
parente080e3e8b620b0e7ed02c28712a0c92b08de3451 (diff)
ZMQ_FILTER socket option added
This option is a performance tweak. In devices XSUB socket filters the messages just to send them to XPUB socket which filters them once more. Setting ZMQ_FILTER option to 0 allows to switch the filtering in XSUB socket off. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/options.cpp')
-rw-r--r--src/options.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/options.cpp b/src/options.cpp
index 271ebdb..29cf023 100644
--- a/src/options.cpp
+++ b/src/options.cpp
@@ -38,6 +38,7 @@ zmq::options_t::options_t () :
reconnect_ivl_max (0),
backlog (100),
maxmsgsize (-1),
+ filter (1),
immediate_connect (true)
{
}
@@ -172,6 +173,15 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
multicast_hops = *((int*) optval_);
return 0;
+ case ZMQ_FILTER:
+ if (optvallen_ != sizeof (int) || (*((int*) optval_) != 0 &&
+ *((int*) optval_) != 1)) {
+ errno = EINVAL;
+ return -1;
+ }
+ filter = *((int*) optval_);
+ return 0;
+
}
errno = EINVAL;
@@ -317,6 +327,15 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
*optvallen_ = sizeof (int);
return 0;
+ case ZMQ_FILTER:
+ if (*optvallen_ < sizeof (int)) {
+ errno = EINVAL;
+ return -1;
+ }
+ *((int*) optval_) = filter;
+ *optvallen_ = sizeof (int);
+ return 0;
+
}
errno = EINVAL;