Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/cpp/rtps/transport/UDPv4Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,14 @@ eProsimaUDPSocket UDPv4Transport::OpenAndBindInputSocket(
if (is_multicast)
{
getSocketPtr(socket)->set_option(ip::udp::socket::reuse_address(true));
#if defined(__QNX__)
// QNX and Apple require SO_REUSEPORT for multiple processes to all
// receive the same multicast datagrams; SO_REUSEADDR alone makes the
// second bind fail (EADDRINUSE) on Darwin. Linux deliberately omitted:
// there SO_REUSEPORT load-balances instead of duplicating delivery.
#if defined(__QNX__) || defined(__APPLE__)
getSocketPtr(socket)->set_option(asio::detail::socket_option::boolean<
ASIO_OS_DEF(SOL_SOCKET), SO_REUSEPORT>(true));
#endif // if defined(__QNX__)
#endif // if defined(__QNX__) || defined(__APPLE__)
}
else
{
Expand Down
8 changes: 6 additions & 2 deletions src/cpp/rtps/transport/UDPv6Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,14 @@ eProsimaUDPSocket UDPv6Transport::OpenAndBindInputSocket(
if (is_multicast)
{
getSocketPtr(socket)->set_option(ip::udp::socket::reuse_address(true));
#if defined(__QNX__)
// QNX and Apple require SO_REUSEPORT for multiple processes to all
// receive the same multicast datagrams; SO_REUSEADDR alone makes the
// second bind fail (EADDRINUSE) on Darwin. Linux deliberately omitted:
// there SO_REUSEPORT load-balances instead of duplicating delivery.
#if defined(__QNX__) || defined(__APPLE__)
getSocketPtr(socket)->set_option(asio::detail::socket_option::boolean<
ASIO_OS_DEF(SOL_SOCKET), SO_REUSEPORT>(true));
#endif // if defined(__QNX__)
#endif // if defined(__QNX__) || defined(__APPLE__)
}
else
{
Expand Down