diff options
author | Johann Latocha | 2011-09-23 01:48:10 +0200 |
---|---|---|
committer | Johann Latocha | 2011-09-23 01:48:10 +0200 |
commit | 59c088461212e71f9c6324d346ac5917b5c17bcb (patch) | |
tree | 06aabe9de47df3dfee474b71de2283d2b896c6b7 | |
parent | Defect #824 (diff) | |
download | pvs-59c088461212e71f9c6324d346ac5917b5c17bcb.tar.gz pvs-59c088461212e71f9c6324d346ac5917b5c17bcb.tar.xz pvs-59c088461212e71f9c6324d346ac5917b5c17bcb.zip |
[PVSMGR] Ask system for network interface before each broadcast
-rw-r--r-- | src/net/pvsServiceBroadcast.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/net/pvsServiceBroadcast.cpp b/src/net/pvsServiceBroadcast.cpp index a861456..7ce7f12 100644 --- a/src/net/pvsServiceBroadcast.cpp +++ b/src/net/pvsServiceBroadcast.cpp @@ -28,14 +28,6 @@ PVSServiceBroadcast::PVSServiceBroadcast() _announce = NULL;
_timer = 0;
_broadcaster.bind(SD_PORT_CONSOLE);
-
- foreach (QNetworkInterface interface, QNetworkInterface::allInterfaces())
- foreach (QNetworkAddressEntry entry, interface.addressEntries())
- if (!entry.broadcast().isNull() && entry.broadcast().toString() != "127.255.255.255")
- _everyone.append(entry.broadcast());
-
- if (_everyone.isEmpty())
- qDebug("ERROR: No broadcast address found");
}
PVSServiceBroadcast::~PVSServiceBroadcast()
@@ -56,10 +48,20 @@ void PVSServiceBroadcast::setFingerprint(QByteArray sha1) void PVSServiceBroadcast::timerEvent(QTimerEvent *event)
{
+ foreach (QNetworkInterface interface, QNetworkInterface::allInterfaces())
+ foreach (QNetworkAddressEntry entry, interface.addressEntries())
+ if (!entry.broadcast().isNull() && entry.broadcast().toString() != "127.255.255.255")
+ _everyone.append(entry.broadcast());
+
+ if (_everyone.isEmpty())
+ qDebug("ERROR: No broadcast address found");
+
if (_announce == NULL) return;
foreach (QHostAddress bcast, _everyone)
{
qDebug("DEBUG: Broadcasting to %s:%i", qPrintable(bcast.toString()),SD_PORT_CLIENT);
_broadcaster.writeDatagram(*_announce, bcast, SD_PORT_CLIENT);
}
+
+ _everyone.clear();
}
|