Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.5.0, 5.5.1, 5.6.0 Alpha
-
None
-
- Win 10, [VS 2013 | VS 2015], [Qt 5.5.1 | Qt 5.6.0 Alpha]
- Win 8.1, [VS 2013 | VS 2015], Qt 5.5.1
-
-
09487deeaea584b2abcc2b1049df2a8542bc113e
Description
It seems like UDP broadcast does not correctly work on Windows Phone.
I have the following code:
QUdpSocket udpSocket = new QUdpSocket(this); if(udpSocket->bind(BROADCAST_PORT)) { foreach (QNetworkInterface iff, ifs) { if(iff.isValid() && !(iff.flags() & QNetworkInterface::IsLoopBack) && (iff.flags() & QNetworkInterface::CanBroadcast) && (iff.flags() & QNetworkInterface::IsRunning) && (iff.addressEntries().size() > 0)) { foreach(QNetworkAddressEntry a, iff.addressEntries()) { if(a.ip().protocol() == QAbstractSocket::IPv4Protocol) { udpSocket->writeDatagram(data, length, a.broadcast(), BROADCAST_PORT); } } } } }
This very same code works fine on all the other platforms but fails miserably on WinPhone.
Using this code as it is does not issue any message because
CanBroadcast
is always false. That's wrong since, according to multiple sources on the Internet, UDP broadcast is supported on WinPhone 8+ (differently from WinPhone 7).
If we factor out that check, UDP messages are correctly sent but all the received messages has the wrong form of
\0x00cdcdcdcdcdcdcdcd...
with variable length dependent on the expected packet length.