Sobes.tech
Junior

How does TCP differ from UDP?

sobes.tech AI

Answer from AI

TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are two main transport layer protocols in a network.

Main differences:

  • Reliability:

    • TCP provides reliable data delivery — guarantees that all packets arrive and in the correct order.
    • UDP does not guarantee delivery or order — packets may be lost or arrive out of order.
  • Connection:

    • TCP is connection-oriented (handshake) before data transfer.
    • UDP is connectionless.
  • Speed:

    • TCP is slower due to error checking and acknowledgments.
    • UDP is faster, suitable for applications where speed is more important than complete reliability (e.g., streaming, gaming).
  • Flow and congestion control:

    • TCP has mechanisms for flow and congestion control.
    • UDP does not have such mechanisms.

Example of use:

  • TCP — web servers, email, file sharing.
  • UDP — DNS queries, VoIP, online gaming.