mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-13 10:52:56 +01:00
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:
parent
49df2f416c
commit
5d0cffc52f
@ -283,7 +283,7 @@ Applicable socket types:: all, only for connection-oriented transports
|
|||||||
ZMQ_MAXMSGSIZE: Maximum acceptable inbound message size
|
ZMQ_MAXMSGSIZE: Maximum acceptable inbound message size
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
The options shall retrieve limit for the inbound messages. If a peer sends
|
The option shall retrieve limit for the inbound messages. If a peer sends
|
||||||
a message larger than ZMQ_MAXMSGSIZE it is disconnected. Value of -1 means
|
a message larger than ZMQ_MAXMSGSIZE it is disconnected. Value of -1 means
|
||||||
'no limit'.
|
'no limit'.
|
||||||
|
|
||||||
@ -294,6 +294,19 @@ Default value:: -1
|
|||||||
Applicable socket types:: all
|
Applicable socket types:: all
|
||||||
|
|
||||||
|
|
||||||
|
ZMQ_MULTICAST_HOPS: Maximum network hops for multicast packets
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
The option shell retrieve time-to-live used for outbound multicast packets.
|
||||||
|
The default of 1 means that the multicast packets don't leave the local network.
|
||||||
|
|
||||||
|
[horizontal]
|
||||||
|
Option value type:: int
|
||||||
|
Option value unit:: network hops
|
||||||
|
Default value:: 1
|
||||||
|
Applicable socket types:: all, when using multicast transports
|
||||||
|
|
||||||
|
|
||||||
ZMQ_FD: Retrieve file descriptor associated with the socket
|
ZMQ_FD: Retrieve file descriptor associated with the socket
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
The 'ZMQ_FD' option shall retrieve the file descriptor associated with the
|
The 'ZMQ_FD' option shall retrieve the file descriptor associated with the
|
||||||
|
@ -296,6 +296,18 @@ Option value unit:: bytes
|
|||||||
Default value:: -1
|
Default value:: -1
|
||||||
Applicable socket types:: all
|
Applicable socket types:: all
|
||||||
|
|
||||||
|
ZMQ_MULTICAST_HOPS: Maximum network hops for multicast packets
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Sets the time-to-live field in every multicast packet sent from this socket.
|
||||||
|
The default is 1 which means that the multicast packets don't leave the local
|
||||||
|
network.
|
||||||
|
|
||||||
|
[horizontal]
|
||||||
|
Option value type:: int
|
||||||
|
Option value unit:: network hops
|
||||||
|
Default value:: 1
|
||||||
|
Applicable socket types:: all, when using multicast transports
|
||||||
|
|
||||||
RETURN VALUE
|
RETURN VALUE
|
||||||
------------
|
------------
|
||||||
|
@ -179,6 +179,7 @@ ZMQ_EXPORT int zmq_term (void *context);
|
|||||||
#define ZMQ_MAXMSGSIZE 22
|
#define ZMQ_MAXMSGSIZE 22
|
||||||
#define ZMQ_SNDHWM 23
|
#define ZMQ_SNDHWM 23
|
||||||
#define ZMQ_RCVHWM 24
|
#define ZMQ_RCVHWM 24
|
||||||
|
#define ZMQ_MULTICAST_HOPS 25
|
||||||
|
|
||||||
/* Send/recv options. */
|
/* Send/recv options. */
|
||||||
#define ZMQ_DONTWAIT 1
|
#define ZMQ_DONTWAIT 1
|
||||||
|
@ -29,6 +29,7 @@ zmq::options_t::options_t () :
|
|||||||
affinity (0),
|
affinity (0),
|
||||||
rate (100),
|
rate (100),
|
||||||
recovery_ivl (10000),
|
recovery_ivl (10000),
|
||||||
|
multicast_hops (1),
|
||||||
sndbuf (0),
|
sndbuf (0),
|
||||||
rcvbuf (0),
|
rcvbuf (0),
|
||||||
type (-1),
|
type (-1),
|
||||||
@ -165,6 +166,14 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
|||||||
maxmsgsize = *((int64_t*) optval_);
|
maxmsgsize = *((int64_t*) optval_);
|
||||||
return 0;
|
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;
|
errno = EINVAL;
|
||||||
@ -301,6 +310,15 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
|
|||||||
*optvallen_ = sizeof (int64_t);
|
*optvallen_ = sizeof (int64_t);
|
||||||
return 0;
|
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;
|
errno = EINVAL;
|
||||||
|
@ -48,6 +48,9 @@ namespace zmq
|
|||||||
// Reliability time interval [ms]. Default 10 seconds.
|
// Reliability time interval [ms]. Default 10 seconds.
|
||||||
int recovery_ivl;
|
int recovery_ivl;
|
||||||
|
|
||||||
|
// Sets the time-to-live field in every multicast packet sent.
|
||||||
|
int multicast_hops;
|
||||||
|
|
||||||
// SO_SNDBUF and SO_RCVBUF to be passed to underlying transport sockets.
|
// SO_SNDBUF and SO_RCVBUF to be passed to underlying transport sockets.
|
||||||
int sndbuf;
|
int sndbuf;
|
||||||
int rcvbuf;
|
int rcvbuf;
|
||||||
|
@ -169,24 +169,30 @@ int zmq::pgm_socket_t::init (bool udp_encapsulation_, const char *network_)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const int rcvbuf = (int) options.rcvbuf,
|
// Propagate various socket options to the OpenPGM layer.
|
||||||
sndbuf = (int) options.sndbuf,
|
const int rcvbuf = (int) options.rcvbuf;
|
||||||
max_tpdu = (int) pgm_max_tpdu;
|
|
||||||
if (rcvbuf) {
|
if (rcvbuf) {
|
||||||
if (!pgm_setsockopt (sock, SOL_SOCKET, SO_RCVBUF, &rcvbuf,
|
if (!pgm_setsockopt (sock, SOL_SOCKET, SO_RCVBUF, &rcvbuf,
|
||||||
sizeof (rcvbuf)))
|
sizeof (rcvbuf)))
|
||||||
goto err_abort;
|
goto err_abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int sndbuf = (int) options.sndbuf;
|
||||||
if (sndbuf) {
|
if (sndbuf) {
|
||||||
if (!pgm_setsockopt (sock, SOL_SOCKET, SO_SNDBUF, &sndbuf,
|
if (!pgm_setsockopt (sock, SOL_SOCKET, SO_SNDBUF, &sndbuf,
|
||||||
sizeof (sndbuf)))
|
sizeof (sndbuf)))
|
||||||
goto err_abort;
|
goto err_abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set maximum transport protocol data unit size (TPDU).
|
const int max_tpdu = (int) pgm_max_tpdu;
|
||||||
if (!pgm_setsockopt (sock, IPPROTO_PGM, PGM_MTU, &max_tpdu,
|
if (!pgm_setsockopt (sock, IPPROTO_PGM, PGM_MTU, &max_tpdu,
|
||||||
sizeof (max_tpdu)))
|
sizeof (max_tpdu)))
|
||||||
goto err_abort;
|
goto err_abort;
|
||||||
|
|
||||||
|
const int multicast_hops = (int) options.multicast_hops;
|
||||||
|
if (!pgm_setsockopt (sock, IPPROTO_PGM, PGM_MULTICAST_HOPS,
|
||||||
|
&multicast_hops, sizeof (int)))
|
||||||
|
goto err_abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (receiver) {
|
if (receiver) {
|
||||||
|
Loading…
Reference in New Issue
Block a user