Don't try to send broadcasts over IPv6
IPv6 has no such thing, so don't try to bind to an IPv6 address to send broadcasts (even though that works) and it's a poor idea to bind to IPv6 to receive broadcasts. Moreover, skip any IPv6 network addresses (broadcast() is invalid). Change-Id: I2829b042c000158565adfd92db682f37d67dacae Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
parent
7a303ff55f
commit
68d8d27fad
@ -282,8 +282,11 @@ void tst_QUdpSocket::broadcasting()
|
||||
foreach (QNetworkInterface iface, QNetworkInterface::allInterfaces()) {
|
||||
if ((iface.flags() & QNetworkInterface::CanBroadcast)
|
||||
&& iface.flags() & QNetworkInterface::IsUp) {
|
||||
for (int i=0;i<iface.addressEntries().count();i++)
|
||||
broadcastAddresses.append(iface.addressEntries().at(i).broadcast());
|
||||
for (int i=0;i<iface.addressEntries().count();i++) {
|
||||
QHostAddress broadcast = iface.addressEntries().at(i).broadcast();
|
||||
if (broadcast.protocol() == QAbstractSocket::IPv4Protocol)
|
||||
broadcastAddresses.append(broadcast);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (broadcastAddresses.isEmpty())
|
||||
@ -293,7 +296,7 @@ void tst_QUdpSocket::broadcasting()
|
||||
#ifdef FORCE_SESSION
|
||||
serverSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
|
||||
#endif
|
||||
QVERIFY2(serverSocket.bind(QHostAddress::Any, 5000), serverSocket.errorString().toLatin1().constData());
|
||||
QVERIFY2(serverSocket.bind(QHostAddress::AnyIPv4, 5000), serverSocket.errorString().toLatin1().constData());
|
||||
|
||||
QCOMPARE(serverSocket.state(), QUdpSocket::BoundState);
|
||||
|
||||
@ -303,7 +306,7 @@ void tst_QUdpSocket::broadcasting()
|
||||
#ifdef FORCE_SESSION
|
||||
broadcastSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
|
||||
#endif
|
||||
broadcastSocket.bind();
|
||||
broadcastSocket.bind(QHostAddress(QHostAddress::AnyIPv4), 0);
|
||||
|
||||
for (int j = 0; j < 100; ++j) {
|
||||
for (int k = 0; k < 4; k++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user