[Interest] UDP broadcast on Winphone
Andrew Knight
andrew.knight at intopalo.com
Mon Oct 19 21:13:08 CEST 2015
Hi Federico,
On 10/19/2015 08:55 PM, Federico Buti wrote:
> Hi list.
>
> According to multiple sources, UDP broadcast is supported on WinPhone
> 8+ (e.g. look here
> <http://stackoverflow.com/questions/23504957/windows-phone-8-1-doesnt-send-udp-broadcast>,
> here
> <http://metronuggets.com/2013/03/18/how-to-send-and-receive-a-udp-broadcast-in-windows-phone-8-and-win8/> or
> here
> <http://01siddharth.blogspot.it/2014/08/send-and-receive-udp-broadcast-in.html>)
> but it seems that the feature in not supported in Qt since
> CanBroadcast flag is set to false in QNetworkInterface (or am I
> misinterpreting?)
> The test code I've used is as simple as the following:
>
That missing flag likely indicates that this has not been
tested/implemented. While UDP is supported, broadcasts may only work by
accident.
>
> udpSocket->bind(BROADCAST_PORT);
> udpSocket->writeDatagram(data, length, a.broadcast(), BROADCAST_PORT);
>
>
> A 4-bytes message is sent on a network where our target device is
> connected. The sent message is correctly received by the target BUT
> the answer we receive back is plain wrong. At least, the length of the
> messages match the expected lengths:
>
>
> \0x00cdcdcd// original message sent by my code - 4 bytes
> \0x00cdcdcdcdcdcdcdcdcdcdcdcdcdcd// answer from the target device - 15
> bytes
>
>
> The very same code works fine on other platforms. Any idea or suggestion?
Yes, those lengths are clearly wrong. The repeating 0xcd is
uninitialized memory.
The truth is, despite passing autotests and having gone through several
Qt minor revisions worth of bug fixes, the Qt network stack for Windows
Phone (Runtime) has goblins. This can be blamed on the large difference
in design and behavior between the WinRT API and traditional (BSD-style)
sockets that most of QtNetwork uses.
So, please test against a released Qt version (or better yet, the 5.6
branch) and file a bug report with your case.
> Thanks in advance,
> F.
>
Cheers,
Andrew
More information about the Interest
mailing list