From 821f93a97d2a2e9cc904a35f32eb3f3a94e0c070 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 31 Jul 2019 21:32:02 -0700 Subject: [PATCH] Send multicast packets on all multicast-capable interfaces --- src/src/server.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/src/server.cpp b/src/src/server.cpp index 7e76b4f..2e8830c 100644 --- a/src/src/server.cpp +++ b/src/src/server.cpp @@ -153,6 +153,14 @@ void Server::sendMessageToAll(const Message &message) { QByteArray packet; toPacket(message, packet); - d->ipv4Socket.writeDatagram(packet, MdnsIpv4Address, MdnsPort); - d->ipv6Socket.writeDatagram(packet, MdnsIpv6Address, MdnsPort); + + foreach (QNetworkInterface interface, QNetworkInterface::allInterfaces()) { + if (interface.flags() & QNetworkInterface::CanMulticast) { + d->ipv4Socket.setMulticastInterface(interface); + d->ipv4Socket.writeDatagram(packet, MdnsIpv4Address, MdnsPort); + + d->ipv6Socket.setMulticastInterface(interface); + d->ipv6Socket.writeDatagram(packet, MdnsIpv6Address, MdnsPort); + } + } }