In general, differences in how UDP and TCP deliver data are similar to the differences between a telephone call and a postcard. TCP works like a telephone call by verifying that the destination is available and ready to communicate. UDP works like a postcard–messages are small and delivery is likely, but not always assured.
UDP is typically used by programs that transmit small amounts of data at one time or have real-time requirements. In these situations, the low overhead and multicasting capabilities of UDP (for example, one datagram, many recipients) are better suited than TCP.
UDP contrasts directly with the services and features provided by TCP. The following table compares differences in how TCP/IP communication is handled depending on whether UDP or TCP is used for transporting data.
|Connectionless service; no session is established between hosts.||Connection-oriented service; a session is established between hosts.|
|UDP does not guarantee or acknowledge delivery, or sequence data.||TCP guarantees delivery through the use of acknowledgments and sequenced delivery of data.|
|Programs that use UDP are responsible for providing any reliability needed to transport data.||Programs that use TCP are provided assurance of reliable data transport.|
|UDP is fast, has low overhead requirements, and can support point-to-point and point-to-multipoint communication.||TCP is slower, has higher overhead requirements, and only supports point-to-point communication.|
Both UDP and TCP use ports to identify communications for each TCP/IP program.