Hello!

I'm having troubles receiving UDP broadcast packets to a low port (port number 1001) on a Windows machine.
I'm using Wireshark to check if the packets arrive on my host successfully and this is the case. Binding the
socket to the "any" address and the low port returns true. Nevertheless, I tried running my program with
administrator privileges and it doesn't change anything. The readyRead() signal is never emitted and when I
manually test for pendingDatagramSize() it always returns -1. Below is the code of my UDPSocket class, that
works perfectly fine in a different application, where a high port is used. Any ideas what I'm doing wrong?

Qt Code:
  1. UDPSocket::UDPSocket()
  2. {
  3. portNumber = 1001;
  4. bool yes = udpSocket.bind(portNumber, QUdpSocket::ShareAddress); // bind returns true!
  5. qDebug() << "udp socket bind says" << yes;
  6. }
  7.  
  8. void UDPSocket::startRecording()
  9. {
  10. processPendingDatagrams(); // Clear the socket to make sure the readyRead() signal will be emitted.
  11. data.clear();
  12. connect(&udpSocket, SIGNAL(readyRead()), this, SLOT(processPendingDatagrams()));
  13. qDebug() << "udp socket is connected";
  14. }
  15.  
  16. void UDPSocket::stopRecording()
  17. {
  18. udpSocket.disconnect(); // Disconnects the Qt signal, not the socket.
  19. }
  20.  
  21. void UDPSocket::processPendingDatagrams()
  22. {
  23. QHostAddress sender;
  24. quint16 senderPort;
  25.  
  26. qDebug() << "packet arrived!";
  27.  
  28. while (udpSocket.hasPendingDatagrams())
  29. {
  30. datagram.resize(udpSocket.pendingDatagramSize());
  31. udpSocket.readDatagram(datagram.data(), datagram.size(), &sender, &senderPort);
  32. data.append(datagram);
  33. }
  34. }
To copy to clipboard, switch view to plain text mode