[Interest] Simple device discovery using UDP
Michael Jackson
mike.jackson at bluequartz.net
Tue Oct 2 17:19:07 CEST 2018
What you want is this:
https://github.com/nitroshare/qmdnsengine
Don't reinvent the wheel if you don't have to. MIT licensed. No relation to the project at all.
--
Michael Jackson | Owner, President
BlueQuartz Software
[e] mike.jackson at bluequartz.net
[w] www.bluequartz.net <http://www.bluequartz.net>
On 10/2/18, 9:43 AM, "Interest on behalf of Jason H" <interest-bounces+mike.jackson=bluequartz.net at qt-project.org on behalf of jhihn at gmx.com> wrote:
I have an app (Desktop) that I want it to know about other running instances on the local network. I figured UDP broadcast was a natural choice. I tried it, but I never saw anything but my own (local) packets. There's quite a few stackoverflow questions, but none used Qt. I'm wondering if it's a wifi/router thing?
The hosts are on the same WiFi SSID and address space:
10.31.4.26 host1
10.31.4.202 host2
Both are on my desk.
HostInfoService::HostInfoService(...) {
...
udpSocket4.bind(QHostAddress::Any, 13999, QUdpSocket::ShareAddress);
connect(&udpSocket4, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));
...
}
void HostInfoService::readPendingDatagrams()
{
for (auto udpSocket: {&udpSocket4 } ) { //, &udpSocket6}) {
while (udpSocket->hasPendingDatagrams()) {
QNetworkDatagram datagram = udpSocket->receiveDatagram();
QString host = QString(datagram.data().constData());
messages[host] = datagram.senderAddress();
qDebug() << Q_FUNC_INFO << host << datagram.senderAddress().toString();
}
}
}
I also tried on an IPv6 socket, no joy.
Has anyone else done something like this?
_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list