From 5d0cffc52f575ff572751cc85fd43063391a211d Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Sun, 15 May 2011 18:25:43 +0200 Subject: ZMQ_MULTICAST_HOPS socket option added Sets the time-to-live field in every multicast packet sent from the socket. Signed-off-by: Martin Sustrik --- src/options.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/options.cpp') diff --git a/src/options.cpp b/src/options.cpp index 399fd27..897e0f5 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -29,6 +29,7 @@ zmq::options_t::options_t () : affinity (0), rate (100), recovery_ivl (10000), + multicast_hops (1), sndbuf (0), rcvbuf (0), type (-1), @@ -165,6 +166,14 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, maxmsgsize = *((int64_t*) optval_); return 0; + case ZMQ_MULTICAST_HOPS: + if (optvallen_ != sizeof (int) || *((int*) optval_) <= 0) { + errno = EINVAL; + return -1; + } + multicast_hops = *((int*) optval_); + return 0; + } errno = EINVAL; @@ -301,6 +310,15 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_) *optvallen_ = sizeof (int64_t); return 0; + case ZMQ_MULTICAST_HOPS: + if (*optvallen_ < sizeof (int)) { + errno = EINVAL; + return -1; + } + *((int*) optval_) = multicast_hops; + *optvallen_ = sizeof (int); + return 0; + } errno = EINVAL; -- cgit v1.2.3