[SOLVED ]QUdpSocket doesn't emit readyRead
I've browsed through this forum without any help at all. This computer is used professionally at work.
My operation system is: Windows XP
Qt version: 4.7.3
MSVC 2010 Professional.
I want to make a network linker that forwards different broadcasts to different network. Reason; We have a distributed network solution at our system, and we don't want to send unnecessary data due to the high update rate.
I have installed two loopback adapters, and one network adapter + on wireless card.
I've tried the Qt examples for UDP, which worked.
For simplicity, I have used the Qt Network UDP sender, to ensure that I can read the UDP packets.
The example programs UDP Sender and UDP Receiver, works perfectly.
Wireshark reveals that the Qt UDP Sender example are sending from 192.168.100.5, and broadcasts to 255.255.255.255 to port 45454.
Since the Qt UDP receiver application works, I did a cut 'n' paste on that code into mine.
Code as follows:
connect(udpSocket, SIGNAL(readyRead()), this, SLOT(processPendingDatagrams()));
But it didn't work at all.....
What can I do?
I would make the connection before I bind. Theoretically, the readyRead() signal could have been fired before you made the connection. It won't be emitted until you have actually read some data. I am however not sure if this is what causes your issue.
Are you returning to the event loop after those calls?
I did a QCoreApplication::sendPostedEvents after each signal-slot connection. That really made the trick. Why did this solve my problem?
Thank you for the clue, peppe ;-)