I have to communicate with some device over UDP. The problem is that QUdpSocket doesn't not work at all without special case of bind(). I use the connectToHost() method for access to read()/write() functions.
UDP exchange not working at all when using the code:
m_udp.connectToHost(QHostAddress("192.168.100.15"), 4001);
m_udp.waitForConnected();
The I don't receive any bytes. Message in Wireshark:
The below code doesn't work too:
m_udp.bind(QHostAddress("192.168.100.15"), 4001);
m_udp.connectToHost(QHostAddress("192.168.100.15"), 4001);
m_udp.waitForConnected();
Only this code works:
m_udp.bind(4001);
m_udp.connectToHost(QHostAddress("192.168.100.15"), 4001);
m_udp.waitForConnected();
But the code works only in Qt 5.6.2 and not work in Qt 5.4.2. Here is how I try to receive:
dev->waitForReadyRead(500);
QByteArray ba = dev->readAll();
Why the behaviour is so strange? How can one understand this?