From f7f1dfc86dd649edbd789a5d157d74721338c912 Mon Sep 17 00:00:00 2001 From: Thijs Terlouw Date: Wed, 26 Jan 2011 07:01:06 +0100 Subject: ZMQ_RECONNECT_IVL_MAX socket option added It allows for exponential back-off strategy when reconnecting. Signed-off-by: Thijs Terlouw --- src/options.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/options.cpp') diff --git a/src/options.cpp b/src/options.cpp index ae35059..c6d5760 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -37,6 +37,7 @@ zmq::options_t::options_t () : type (-1), linger (-1), reconnect_ivl (100), + reconnect_ivl_max (0), backlog (100), requires_in (false), requires_out (false), @@ -161,6 +162,18 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, reconnect_ivl = *((int*) optval_); return 0; + case ZMQ_RECONNECT_IVL_MAX: + if (optvallen_ != sizeof (int)) { + errno = EINVAL; + return -1; + } + if (*((int*) optval_) < 0) { + errno = EINVAL; + return -1; + } + reconnect_ivl_max = *((int*) optval_); + return 0; + case ZMQ_BACKLOG: if (optvallen_ != sizeof (int)) { errno = EINVAL; @@ -297,6 +310,15 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_) *optvallen_ = sizeof (int); return 0; + case ZMQ_RECONNECT_IVL_MAX: + if (*optvallen_ < sizeof (int)) { + errno = EINVAL; + return -1; + } + *((int*) optval_) = reconnect_ivl_max; + *optvallen_ = sizeof (int); + return 0; + case ZMQ_BACKLOG: if (*optvallen_ < sizeof (int)) { errno = EINVAL; -- cgit v1.2.3