TCP:
- Reliable, ordered delivery
- Connection-oriented (handshake required)
- Flow and congestion control
- Higher overhead
- Use for: HTTP, database connections, file transfers
UDP:
- Unreliable, unordered
- Connectionless (no handshake)
- No congestion control
- Lower latency
- Use for: DNS queries, video streaming, gaming
Interview question: "Why does DNS use UDP?"
DNS queries are small and fit in single packets. UDP's lower overhead means faster responses. If a query is lost, the client simply retries. For zone transfers (large data), DNS uses TCP.