PDA

View Full Version : QUdpSocket and UnconnectedState problem



RThaden
14th September 2009, 18:20
Hi all,

I have a class derived from QUdpSocket. Basically, I just added some functions, nothing of interest.
I iterate through all interfaces on a computer to send local UDP broadcasts.
In a loop, I try to find out if there's any response from a device, therefore I do


Q_FOREACH(CHD2UdpSocket* socket, udpSockets)
{
if (socket->state()==QAbstractSocket::UnconnectedState)
continue;
while (socket->hasPendingDatagrams())
{
...


The strange thing is: these are udp sockets, so they are not in a ConnectedState but in a BoundState.
The if statement is false, so the socket is NOT in an UnconnectedState (it's in a BoundState).
But then the socket->hasPendingDiagrams spits out the following debug message
QNativeSocketEngine::hasPendingDiagrams() was called in QAbstractSocket::UnconnectedState.

Any idea what's happening here?
Is it a bug or am I doing something wrong?

Best regards,

Rainer