Co-Authored By:

Asked by: Sevastita Grunenthal
technology and computing artificial intelligenceWhen would you use UDP instead of TCP?
Similarly, when should I use UDP instead of TCP?
Typically, use UDP in applications where speedismore critical than reliability. For example, it may be bettertouse UDP in an application sending data from afastacquisition where it is acceptable to lose some data points.Youcan also use UDP to broadcast to any machine(s) listeningtothe server.
- 1) UDP is much faster. TCP is slow as it requires3-wayhandshake.
- 2) DNS requests are generally very small and fit well withinUDPsegments.
- 2) UDP is not reliable, but reliability can added onapplicationlayer. An application can use UDP and can be reliableby using atimeout and resend at the application layer.
Then, is UDP better than TCP?
UDP is efficient for broadcast and multicasttypeof network transmission. TCP is reliable as itguaranteesdelivery of data to the destination router. UDPisfaster, simpler and more efficient thanTCP.Retransmission of lost packets is possible in TCP,but notin UDP.
First, one of the attractive features of UDPisthat since it does not need to retransmit lost packets nor doesitdo any connection setup, sending data incurs less delay. Thislowerdelay makes UDP an appealing choice fordelay-sensitiveapplications like audio and video.