diff options
author | Liang Qi <liang.qi@qt.io> | 2017-02-24 19:57:17 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-02-24 20:01:42 +0100 |
commit | de49839df8abfba1f3ed3c36ef3177e4a9d6ef00 (patch) | |
tree | 71e777ca1e33c58edd9149821e970495ef4b75b2 /src/network/socket/qnativesocketengine_win.cpp | |
parent | e6234535929c67e7fbfa1ad7ce88f37df0b68d45 (diff) | |
parent | 4d3781b640e8fb0a04e96b2d05199247556b8d86 (diff) |
Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
mkspecs/features/moc.prf
Change-Id: Ia71c8e3b3185f7c999bf226d0675051b10b8740b
Diffstat (limited to 'src/network/socket/qnativesocketengine_win.cpp')
-rw-r--r-- | src/network/socket/qnativesocketengine_win.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index 80147b47ba..28aea6be3d 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -955,10 +955,16 @@ static bool multicastMembershipHelper(QNativeSocketEnginePrivate *d, if (iface.isValid()) { const QList<QNetworkAddressEntry> addressEntries = iface.addressEntries(); - if (!addressEntries.isEmpty()) { - QHostAddress firstIP = addressEntries.first().ip(); - mreq4.imr_interface.s_addr = htonl(firstIP.toIPv4Address()); - } else { + bool found = false; + for (const QNetworkAddressEntry &entry : addressEntries) { + const QHostAddress ip = entry.ip(); + if (ip.protocol() == QAbstractSocket::IPv4Protocol) { + mreq4.imr_interface.s_addr = htonl(ip.toIPv4Address()); + found = true; + break; + } + } + if (!found) { d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::NetworkUnreachableErrorString); return false; |