0

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   
     }   
  }   
Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
Rob Dugas
  • 1
  • 1
  • Well, broadcast to .1.x means "go to everyone on .1.x, but to no one else"... – PlasmaHH Jan 27 '14 at 20:16
  • This is really mostly a network configuration question. The "subnet mask" is what determines what's seen as a "local" address, and therefore receives broadcasts. With a `192.168.x.x` address, you'll normally set the subnet mask to `255.255.255.0`. With the subnet mask changed to `255.255.0.0`, both of those will be seen as parts of the local network. – Jerry Coffin Jan 27 '14 at 20:26
  • Thank you for your comments. I have my subnet mask at 255.255.0.0 - Also, I added a second IP ...0.71 (with ...1.70) in my LAN adapter > Properties > Advanced etc... with both subnet at 255.255.0.0. The device at 0.1 is also writing to broadcast FF.FF.FF.FF:FFFF. I'm just trying to read anything coming from that device. Wireshark has no problem picking up that traffic. – Rob Dugas Jan 28 '14 at 13:53

0 Answers0