Card 09/ 09
Recap: Ports, TCP and UDP
A port reaches the program, and the transport is chosen by what a late packet costs.
The transport layer gets data from a machine to a program, and it offers two different promises.
- A port names one program's endpoint on a host. Servers listen on well-known ports; clients use ephemeral ones.
- Five values, the protocol, both addresses and both ports, identify a connection. No two live connections share all five.
- UDP sends datagrams with no connection, no retransmission and no order, in an eight-byte header.
- TCP delivers a complete, ordered stream of bytes, at the cost of a handshake and of waiting for lost data.
- The choice turns on what a late packet is worth: wait for it with TCP, or carry on without it with UDP.
- Refused means a host answered and nothing listens on the port; timed out means nothing answered.
| Property | TCP | UDP |
|---|---|---|
| Lost data | Sent again | Stays lost |
| Order | Guaranteed | Not guaranteed |
| Cost | A handshake and waiting behind a loss | None; the application handles gaps |
← → move through sections and cards