Definitions – TCP versus UDP
Both TCP and UDP are protocols used for sending bits of data — known as packets — over the Internet.
They both build on top of the Internet protocol. In other words, whether you are sending a packet via TCP or UDP, that packet is sent to an IP address.
Transmission Control Protocol (TCP)
TCP guarantees the recipient will receive the packets in order by numbering them. The recipient sends messages back to the sender saying it received the messages. If the sender does not get a correct response, it will resend the packets to ensure the recipient received them. Packets are also checked for errors. TCP is all about this reliability — packets sent with TCP are tracked so no data is lost or corrupted in transit.
User Datagram Protocol (UDP)
The UDP protocol works similarly to TCP, but it throws all the error-checking stuff out.
When using UDP, packets are just sent to the recipient. The sender will not wait to make sure the recipient received the packet — it will just continue sending the next packets.
There is no guarantee you are getting all the packets and there is no way to ask for a packet again if you miss it.
UDP is used when speed is desirable and error correction is not necessary. For example, UDP is frequently used for live broadcasts and online games.