diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2011-05-15 18:25:43 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2011-05-15 18:25:43 +0200 |
commit | 5d0cffc52f575ff572751cc85fd43063391a211d (patch) | |
tree | 2f61c1e0f6060fc756feefef11fcafa1c168d16f /src/options.cpp | |
parent | 49df2f416cd43e9e18f3dbd964271c5cca835729 (diff) |
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 <sustrik@250bpm.com>
Diffstat (limited to 'src/options.cpp')
-rw-r--r-- | src/options.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
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; |