An unreliable UDP call is a simplification that puts TCP as a panacea for all network problems. In the same vein, the definition of TCP as reliable is again erroneous. While it is true that TCP has mechanisms for attempting to transmit data, many of the errors that cause the UDP packet to fail will also cause TCP to fail.
For example, a hardware network error will have the same effect on UDP and TCP packets. If the error persists, TCP will not pass as accurately as UDP. In fact, in this case, TCP has the disadvantage that it will try to complete the lost cause longer. Now, if you send data over the Internet, TCP has some advantages, since the route sent by the packet cannot be predetermined. However, UDP is quite adequate for sending data over a local network. If your packages do not reach their destination, this indicates a hardware problem that needs to be fixed. TCP will not help here.
Also, when choosing a protocol, you should also understand your data. If your data is transient, such as reading from a sensor, it makes sense to use UDP over TCP. If a packet is lost in this situation, it does not really matter, since another packet will soon occur. TCP, on the other hand, will shut down and try again. By the time data arrives, it will already be obsolete.
Actually TCP is designed for streaming data. In this situation, it is important that all data packets are reliable and orderly. UDP is for packet data and is for this type of data. UDP is absolutely acceptable, reliable, has less overhead and detects and repairs faster due to network failures.
source share