I am setting up a QUdpSocket and connecting the readyRead() signal to my readDatagrams() method, however when I get into the method and check the socket with hasPendingDatagrams() it never enters my loop, i.e:

Qt Code:
  1. void Listener::readDatagrams()
  2. {
  3. while ( m_aSocket->hasPendingDatagrams() )
  4. {
  5. // Never gets here
  6. }
  7. }
To copy to clipboard, switch view to plain text mode 

however, if i skip that loop and just read a datagram from the socket I get my data:

Qt Code:
  1. QByteArray datagram;
  2. datagram.resize(m_aSocket->pendingDatagramSize());
  3. QHostAddress sender;
  4. quint16 senderPort;
  5.  
  6. m_aSocket->readDatagram(datagram.data(), datagram.size(), &sender, &senderPort);
  7.  
  8. if ( datagram.size() > 0 )
  9. {
  10. // Gets here without loop
  11. }
To copy to clipboard, switch view to plain text mode 

Can anyone help out?