Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.0.0
-
None
-
Qt 5.0.0 X-compiled on Gentoo Linux for mingw64, Windows Vista 64Bit as test environment.
-
e3bd06426afce9773fa64afe1a9946647cdec181
Description
The broadcast sender example is not able to send via the (unbind) socket.
This is the original code:
QByteArray datagram = "Broadcast message " + QByteArray::number(messageNo);
udpSocket->writeDatagram(datagram.data(), datagram.size(),
QHostAddress::Broadcast, 45454);
To show the problem, I changed the source like this:
QByteArray datagram = "Broadcast message " + QByteArray::number(messageNo);
if(1 == udpSocket>writeDatagram(datagram.data(), datagram.size(), QHostAddress::Broadcast, 45454))
qDebug() << "error on write datagram";
This Variant is working:
if(!udpSocket->bind(QHostAddress::AnyIPv4, 12345))
qDebug() << "error on bind";
QByteArray datagram = "Broadcast message " + QByteArray::number(messageNo);
if(1 == udpSocket>writeDatagram(datagram.data(), datagram.size(), QHostAddress::Broadcast, 45454))
qDebug() << "error on write datagram";
To make the example working, the port to bind to is unimportant.