Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.0.2, 5.1.1, 5.2.1, 5.3.2, 5.4.2, 5.5.1, 5.6.1
-
None
-
openSUSE Leap 42.1 (x86_64)
Qt 5.6.1 (GCC 4.8.5, 64 bit)
Description
Code to reproduce bug:
main.cpp
#include <QCoreApplication> // add necessary includes here #include <QUdpSocket> #include <QDebug> #include <QNetworkInterface> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QUdpSocket * udpSocket = new QUdpSocket(&a); QObject::connect(udpSocket, &QUdpSocket::stateChanged, [=](){ if (udpSocket->state() == QUdpSocket::BoundState) { if (!udpSocket->joinMulticastGroup(QHostAddress("232.1.1.12"))) { qDebug() << "Socket not bound to multicast group"; return; } qDebug() << "Socket bound to multicast group"; qDebug() << udpSocket->multicastInterface().hardwareAddress(); qDebug() << udpSocket->multicastInterface().allAddresses(); qDebug() << udpSocket->localAddress() << ":" << udpSocket->localPort(); udpSocket->open(QAbstractSocket::ReadOnly); qDebug() << "isOpen = " << udpSocket->isOpen(); } }); QObject::connect(udpSocket, &QUdpSocket::readyRead, [=]() { qDebug() << "udpSocket" << udpSocket->bytesAvailable(); qDebug() << "udpSocket" << udpSocket->hasPendingDatagrams(); qDebug() << "udpSocket" << udpSocket->pendingDatagramSize(); qDebug() << "udpSocket" << udpSocket->state(); qDebug() << "udpSocket" << udpSocket->readAll().toHex(); }); QObject::connect(udpSocket, static_cast<void (QUdpSocket::*)(QUdpSocket::SocketError)>(&QUdpSocket::error), [=]() { qDebug() << udpSocket->errorString(); }); // udpSocket->bind(QHostAddress("10.10.3.103"), 21112, QUdpSocket::ShareAddress); udpSocket->bind(QHostAddress::AnyIPv4, 21112, QUdpSocket::ShareAddress); // udpSocket->connectToHost(QHostAddress("232.1.1.12"), 21112, QAbstractSocket::ReadOnly); return a.exec(); }
Send datagram to group:
echo -ne "\xf0\x00\x04\x80\x01\x01" | socat - udp-datagram:232.1.1.12:21112,ip-add-membership=232.1.1.12:10.10.3.103
Console output:
Socket bound to multicast group
""
(QHostAddress("127.0.0.1"), QHostAddress("::1"), QHostAddress("10.10.3.103"), QHostAddress("fe80::e2cb:4eff:feec:ea39%br1"))
QHostAddress("0.0.0.0") : 21112
isOpen = true
udpSocket 6
udpSocket true
udpSocket 6
udpSocket QAbstractSocket::BoundState
udpSocket ""