skipnothing/HTTP & Networking

Ports & Sockets

ss -tn on a machine serving traffic prints dozens of rows, and every one shows 10.0.0.5:443 on the left with a different address on the right. One slot, dozens of live conversations, and the right column is why.

  • ▸One server holds thousands of live connections on one slot, because the four numbers naming each still differ.
  • ▸Two servers can share the same number on one machine, as long as each binds a different local address.
  • ▸Stop a server and its address stays unusable for a minute, held by a closed endpoint still releasing its coordinate.
BUILDS ON
01

A port is a 16-bit slot

You start a web server and tell it to listen on 443. That number is nothing special to the wire: it is one value in a 16-bit field, so it runs 0 to 65535 and no further.

The values split into three bands. System ports, 0 to 1023, are the ones the operating system guards: on Linux a program cannot claim one without root or a specific capability. User ports, 1024 to 49151, any program may take. Dynamic ports, 49152 to 65535, IANA never hands to anyone; they are left for temporary, local use.

The guard on the low band is not written in the number. The operating system enforces it, and a different system can draw the line in a different place.

PLACE A PORT, READ ITS BAND

Keep going, sign up to unlock the rest

4 more parts in this topic, plus 23+ more topics in HTTP & Networking.

Sign up, it's freeSee the full HTTP & Networking