Reliability and ordering versus speed
TCP is a stream protocol: it guarantees every byte arrives exactly once, in order. Lost packets are retransmitted, out-of-order packets are reordered, duplicates are discarded. The application sees a clean, ordered sequence of bytes. UDP is a datagram protocol: it sends individual packets with no guarantee. A packet might arrive out of order, be lost, duplicated, or corrupted. The application sees raw datagrams and must handle loss itself. TCP's guarantees cost latency and overhead; UDP is fast and simple but requires resilience from the application.
Connection setup and message semantics
TCP requires a handshake (SYN, SYN/ACK, ACK) before data flows, adding latency but ensuring both sides are ready. UDP is connection-less: the first packet is data, no setup. TCP treats data as a stream: 'hello' and 'world' might arrive as 'helloworld' or be split across packets. UDP preserves packet boundaries: a send of 100 bytes arrives as exactly 100 bytes or not at all. Applications that need message integrity use UDP with checksums or sequence numbers in the payload.
Use cases and trade-offs
TCP powers reliable applications: file transfer (FTP), email (SMTP), web (HTTP). UDP powers speed-sensitive applications: voice calls (Skype), live video (Twitch, YouTube), online games, DNS. A lost video frame in a call is acceptable; a retransmission would cause unacceptable delay. A lost DNS query is retried immediately. For applications that need selective reliability (some packets must arrive, others can be lost), a hybrid approach (TCP with message loss tolerance or UDP with per-message acknowledgments) is used.