Connection-Oriented TCP
TCP (Transmission Control Protocol) is connection-oriented. Before sending any data, the sender and receiver must perform a three-way handshake (SYN, SYN-ACK, ACK) to synchronize sequence numbers and allocate resources.
TCP provides strict guarantees: data is delivered in order, missing packets are retransmitted, and flow control is managed dynamically. This overhead makes TCP ideal for web pages, file downloads, and APIs.
Connectionless UDP
UDP (User Datagram Protocol) is a lightweight, connectionless protocol. Packets (datagrams) are sent immediately to the destination without establishing a session, verifying arrival, or managing network flow.
Because there is no handshake, retransmission, or sequencing, UDP has minimal overhead, making it fast and low-latency. It is used for DNS queries, video streaming, voice-over-IP, and online games.
Comparison Summary
Use TCP when reliability is mandatory and latency can tolerate handshake hops. Use UDP when immediate speed is required and losing occasional packets does not break the application.
