Interview Q&A / Computer Networks

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What is a port number, and how is it different from an IP address?

SHORT ANSWER

An IP address identifies a machine on a network. A port number (0 to 65535) identifies which program on that machine should receive the data. Together they pick out one exact conversation endpoint.

Explain it simply

An IP address is like the street address of a college hostel. A port is the room number. The postman needs both, otherwise the letter reaches the building but nobody knows whom to give it to.

Example

text
https://example.com      ->  203.0.113.7 : 443   (web server)
ssh user@203.0.113.7     ->  203.0.113.7 : 22    (SSH daemon)
same machine, same IP, different programs

Port ranges: 0 to 1023 are well-known (80 HTTP, 443 HTTPS, 22 SSH, 53 DNS, 25 SMTP). 1024 to 49151 are registered, and 49152 to 65535 are mostly used as temporary ports. When your browser connects, the operating system picks a random temporary source port, such as 51734, so replies find the right tab.

Ports belong to the transport layer, so TCP port 53 and UDP port 53 are separate things.

What to say in the interview

"The IP address finds the host; the port finds the process. A port is a 16-bit number, so there are 65,536 of them. TCP and UDP each have their own port space. The pair of IP and port is what the OS uses to hand arriving data to the correct application."

Common mistakes

  • Thinking a port is a physical socket on the computer.
  • Forgetting that the client also uses a port, a random temporary one.

#ports#ip-address#transport

Related questions

Practise more Computer Networks questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Computer Networks quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.