I am trying to capture some test broadcast messages from 192.168.0.xxx while I am at 192.168.1.xxx
I have a device that sends broadcast test packets from 192.168.0.1 to 192.168.0.255.
My application is on 192.168.1.70 and trying to receive the broadcast UDP using the same port number for both.
I have WireShark running and I can see the correct packets from the device going from ...0.1 to ...0.255. However, I'm not able to pick it up by code from ...1.70.
Here's a receiving sample test code-bits I'm using on ...1.70.
QUdpSocket *udpSocket = new QUdpSocket(this);
udpSocket->bind(PortValue, QUdpSocket::ShareAddress); //PortValue = 47808
while (1) {
if (udpSocket->hasPendingDatagrams()) {
QByteArray datagram;
QString Msg;
datagram.resize(udpSocket->pendingDatagramSize());
udpInSocket->readDatagram(datagram.data(), datagram.size());
for (uint32_t n = 0; n < datagram.count(); n++) {
Msg += QString::number((datagram[n] & 0xff), 16) + " ";
}
qDebug() << "Datagram: " << Msg;
Pause->msleep(1); //1 msec
}
}