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>
This commit is contained in:
Martin Sustrik
2011-05-15 18:25:43 +02:00
parent 49df2f416c
commit 5d0cffc52f
6 changed files with 58 additions and 5 deletions

View File

@@ -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;