Commit d8f3b283 authored by Byron Mallett's avatar Byron Mallett Committed by Luca Boccassi

Added SO_REUSEPORT socket option for UDP recv ports (#3237)

* Added SO_REUSEPORT socket option for UDP multicast recv ports
parent 50dbd80c
...@@ -206,10 +206,21 @@ void zmq::udp_engine_t::plug (io_thread_t *io_thread_, session_base_t *session_) ...@@ -206,10 +206,21 @@ void zmq::udp_engine_t::plug (io_thread_t *io_thread_, session_base_t *session_)
bool multicast = udp_addr->is_mcast (); bool multicast = udp_addr->is_mcast ();
if (multicast) { if (multicast) {
// Multicast addresses should be allowed to bind to more than
// one port as all ports should receive the message
#ifdef SO_REUSEPORT
rc = setsockopt (_fd, SOL_SOCKET, SO_REUSEPORT,
reinterpret_cast<char *> (&on), sizeof (on));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert (rc != SOCKET_ERROR);
#else
errno_assert (rc == 0);
#endif
#endif
// In multicast we should bind ANY and use the mreq struct to // In multicast we should bind ANY and use the mreq struct to
// specify the interface // specify the interface
any.set_port (bind_addr->port ()); any.set_port (bind_addr->port ());
real_bind_addr = &any; real_bind_addr = &any;
} else { } else {
real_bind_addr = bind_addr; real_bind_addr = bind_addr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment