Network Transport Protocols: UDP vs TCP
TCP is really useful when you need a single connection between client and server and during this connection, you need to transfer a file and it is important that due to high latency and packet loss that there is a proper error recovery system in place so that the entire file is sent to the server for processing . However, doing the same on UDP protocol with high latency and packet loss will result in your file being corrupted as it reaches the server. This is a popular case where TCP is preferred over UDP. Now let’s check out the case where UDP is more advantages than TCP. Think of a real-time multiplayer game, where it is vital that your movement in the game is being sent to the server and the other players as quickly as possible. If there is any lag in the game, you will notice it and also the other players in the lobby will notice it as well. This is because TCP is slower, it takes time to make a connection and TCP has more overhead in the data that is being sent to the server in comparison with UDP.
You can read the full article here: https://interviewnoodle.com/network-transport-protocols-udp-vs-tcp-982c129442a9