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:
void Listener::readDatagrams()
{
while ( m_aSocket->hasPendingDatagrams() )
{
// Never gets here
}
}
void Listener::readDatagrams()
{
while ( m_aSocket->hasPendingDatagrams() )
{
// Never gets here
}
}
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:
datagram.resize(m_aSocket->pendingDatagramSize());
quint16 senderPort;
m_aSocket->readDatagram(datagram.data(), datagram.size(), &sender, &senderPort);
if ( datagram.size() > 0 )
{
// Gets here without loop
}
QByteArray datagram;
datagram.resize(m_aSocket->pendingDatagramSize());
QHostAddress sender;
quint16 senderPort;
m_aSocket->readDatagram(datagram.data(), datagram.size(), &sender, &senderPort);
if ( datagram.size() > 0 )
{
// Gets here without loop
}
To copy to clipboard, switch view to plain text mode
Can anyone help out?
Bookmarks