TCP vs UDP

View saved

Carry data in packets

Both TCP and UDP ride on IP. They add port numbers so many programs can share one IP address, and they define how the two ends exchange data.

Use TCP for reliable streams

TCP sets up a connection, numbers data, retransmits lost pieces, and delivers bytes in order. Web browsing, email, and file transfers usually rely on TCP.

Use UDP for simple datagrams

UDP sends individual messages without a handshake or automatic retransmission. DNS queries, many games, and live media often prefer UDP because lower overhead and quicker delivery matter more than perfect recovery.

Match the tool to the job

  • Choose TCP when missing data must be repaired
  • Choose UDP when speed or simplicity matters and the app can handle loss
  • Remember that "unreliable" UDP still works well for short, self-contained messages

Comments

One comment per signed-in account. Comments are saved with this page’s URL.