As the title suggests, I was wondering how one decides which protocol to implement. So far I understand that UDP can make for faster transmission of data but with the order it’s sent in neglected and it doesn’t monitor if the data is even received. To my knowledge TCP is safer and is used when data has to be precise and the reception time doesn’t have to be as swift. But I noticed that different online games use different protocols even though all of them games play quite fluently(which I’m assuming means fast data transfer.) So I’m wondering how can you tell which is used, and why is that protocol used?
Thanks
Warning: incoming oversimplification. Still, this should help you understand.
TCP is reliable. If you send data, it will either get there in one piece and in perfect order, or it won’t get there. This reliability comes at a cost of more traffic overhead, because the receiver has to acknowledge its receipt to the sender, and the sender may send the same data multiple times to ensure correct delivery.
UDP is unreliable, but with no such overhead. The sender tosses packets at the receiver. Packets that do arrive are still guaranteed to arrive in one piece, but not all packets are guaranteed to arrive. UDP is useful when you can afford transmission loss and the overhead of TCP is too great to justify the reliability.
Examples of uses for UDP include real-time content streaming (video/audio) and continuous state updates (e.g., packets notifying the client of the state of various objects in your game universe). In general, these are adequate targets because data becomes irrelevant very quickly as it is replaced with new data. Better to keep throwing bits and chugging along than to worry about intact arrival of past data that may no longer matter.
On the other hand, something like authentication, a content updating system, or in-game chat would strongly benefit from a more reliable TCP connection, as latency is far less important than integrity.