Using UDP

In contrast to TCP, UDP is unreliable and connectionless. Neither the order of packets, nor their delivery is guaranteed. UDP, however, is very fast. So, if you have frequent data, which does not necessarily need to be received by the peer, use UDP. This data could, for example, be real-time positions of a player that get updated frequently or live video/audio streaming. Since QUdpSocket is mostly the same as QTcpSocket—both inherit QAbstractSocket—there is not much to explain. The main difference between them is that TCP is stream-orientated, whereas UDP is datagram-orientated. This means that the data is sent in small packages, containing among the actual content, the sender's as well as the receiver's IP address and port number. Due ...

Get Game Programming Using Qt now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.