Applications need a way to send data between computers. TCP and UDP are transport protocols that offer different trade-offs to software running above them.
TCP provides a reliable byte stream
Transmission Control Protocol (TCP) establishes a connection and delivers bytes in order. It detects loss, retransmits data, and manages how much data is sent at once. Applications can read a stream of bytes, but they must define their own message boundaries if they need separate messages.
Reliability and ordering are useful for web pages, file transfers, and many APIs, where missing or rearranged data would be a problem.
UDP sends independent datagrams
User Datagram Protocol (UDP) sends individual datagrams without TCP's built-in delivery and ordering guarantees. This keeps the transport simpler and can be useful when an application prefers fresh data over waiting for retransmission, such as live voice or some games.
The application still has responsibilities
UDP does not guarantee that a packet arrives, arrives once, or arrives in order. Applications that need reliability can add their own mechanisms. TCP has different performance characteristics, especially when packets are lost, but no transport is universally faster for every workload.
Choose based on what the application needs: reliable ordered bytes, or independent datagrams with behavior controlled by the application.