What is the return value of writeDatagram and readDatagram?
In general: you shall take care about return values - they have a meaning.
Here is the Qt documentation on writeDatagram:
Datagrams are always written as one block. The maximum size of a datagram is highly platform-dependent, but can be as low as 8192 bytes. If the datagram is too large, this function will return -1 and error() will return DatagramTooLargeError.
Sending datagrams larger than 512 bytes is in general disadvised, as even if they are sent successfully, they are likely to be fragmented by the IP layer before arriving at their final destination.
Believe it or not: ip packet loss is part of udp - if you need reliability: use tcp.
Bookmarks