Answer the question
In order to leave comments, you need to log in
What is the most correct way to read data from QUdpSocket?
Good day!
I took out the work with sockets in a separate thread and the question arose of how it would be most correct to receive packets.
Or, as usual, by subscribing to the event:
connect(_socket, &QUdpSocket::readyRead, this, &UDPStream::onReadyRead);
if (_socket->hasPendingDatagrams()) {
QByteArray data;
data.resize(_socket->pendingDatagramSize());
.........
}
Answer the question
In order to leave comments, you need to log in
And it will work anyway. The size of the queue depends on the bandwidth and availability of the network adapter.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question