A port number is a 16-bit unsigned integer, thus ranging from 0 to 65535


And I think computers have small number of hardware interfaces(ports) for network communications, so what is the relation between hardware and software ports. Like HTTP by default will run on port 80, so does that mean it will run on hardware port 80?


There is no relation (or only a very distant one).

A hardware interface attaches a network to a host (or devices like switches or router).

A port number in a transport-layer protocol (L4) serves as a subaddress on a host - that way, you can run multiple, independent applications on a host. Each subaddress/port allows you to address an application/a process on a host instead of the host as a whole (roughly). Without L4 ports, you couldn't run FTP, HTTP, SSH, SMTP, ... all on a single server.

From the network theory perspective, a hardware interface (physical layer L1) is multiplexed by using e.g. MAC addresses and VLANs in the data link layer (L2). That in turn is multiplexed by using e.g. IP addresses in the network layer (L3). That in turn is multiplexed using transport-layer protocols like TCP or UDP (L4). Many of those are then multiplexed using port numbers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.