The application sends the packet properly and the response packet arrives but the readPendingDatagrams() function is never called. I have verified the packets are sent and received using Wireshark and that the application is listening on the port indicated in wireshark using Process Explorer.

The device on the network listens on port 65001 and responds to packets on the source port of the received packet. It is necessary to use connectToHost(...) in order to know what port to bind for the response packet.

It is also necessary to bind to the correct address and port to receive the packets. This was the problem.

Neither solution worked. Using udpSocketSend->bind(udpSocketSend->localPort()) and connect(udpSocketSend,SIGNAL(readyRead()),this,SLOT(readPendingDatagrams())) doesn't trigger readPendingDatagrams(). Also configuring udpSocketSend with QIODevice::WriteOnly and doesn't trigger readPendingDatagrams(). Since this is UDP the connectToHost(...) method does not bind to a port, it just sets up the udpSocketSend so it can use udpSocketSend->write(*datagram) instead of udpSocketSend->writeDatagram(...) which is not recommended to be used on a connected socket.
–
zuwgapJun 29 '11 at 14:42