[Interest] QUdpSocket on Windows 10: QNetworkDatagram::destinationAddress/Port not set
Thiago Macieira
thiago.macieira at intel.com
Tue Oct 3 16:52:11 CEST 2017
On terça-feira, 3 de outubro de 2017 07:28:15 PDT Richard Öhlinger wrote:
> Hi,
>
> I'm using QUdpSocket on Windows 10 to receive Multicast messages. Since
> Windows does not allow for binding directly to the multicast address
> I've to bind to the AnyIP and filter for destination address.
>
> Therefore I use QUdpSocket::receiveDatagram to get a QNetworkDatagram.
> But its destinationAddress is not valid and destinationPort is -1.
>
> The exact same code works on Linux. I'm using Qt 5.9.0
>
> Is there a limitation on Windows systems? The Documentation would list
> it as supported [1].
Maybe. All unit tests for tst_QUdpSocket are passing on my Windows 10,
indicating normal multicast is working.
Anyway, binding to the multicast address is wrong. You shouldn't ever do that.
You just join the multicast group that you wanted to. But that actually might
be the issue: because of the multicast, you need to specifically choose the
address family at bind time: if your multicast address is IPv6, bind to
AnyIPv6; if it's IPv4, bind to AnyIPv4. Linux is capable of receiving IPv4
multicast on an IPv6 socket, but that feature is not usually present in other
OSes.
If that doesn't fix the issue, can you make a simple example for what fails for
you? I need to test what's wrong.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Interest
mailing list