YouTube, WhatsApp and email are all running on your phone at the same time. So how does incoming data know which app to go to?
The IP alone isn't enough
The IP address gets data to the right device. But inside that device, lots of apps are running. Think of a block of flats: the building's address is the IP, but there are 100 flats inside. The port tells you which flat's door to knock on.
Ports on your phone
When you open YouTube, your phone gives that connection a port number, say 51234. WhatsApp's connection gets a different one, say 51890. Data coming back from YouTube's server is addressed to port 51234, so it goes to YouTube and not to WhatsApp. Your phone picks these numbers automatically, usually from the high range 49152 to 65535, each time.
Ports on a server: listening
On the server side it's the opposite: each service waits on a fixed port. That's called listening. A website listens on 80 (HTTP) or 443 (HTTPS); SSH listens on 22. Port numbers run from 0 to 65535. You'll learn the five most important ones in lesson 13.
Why hackers look at ports
A thief trying to get into a building first walks along the corridor checking for an open door. Every open port on a server is a door. If a port that nobody needs is left open, running an old or badly configured service, that's an attacker's way in. That's exactly what a port scan with Nmap looks for (lesson 15).
Key takeaways
- IP = building address; port = the door inside it.
- Your phone gives each app's connection its own temporary port.
- Servers listen on fixed ports: 80/443 for websites, 22 for SSH.
- Every open port is a possible way in for an attacker.
Quick quiz
Pick an answer to check yourself. Answer both to mark this lesson done.
1. What decides which app or service inside a device receives incoming data?
- A) MAC address
- B) Port number
- C) Modem
- D) Wi-Fi password
Show answer
Answer: B. The IP gets data to the right device; the port number decides which app inside it.
2. Why is it dangerous to leave unnecessary ports open?
- A) The internet gets slow
- B) It can be an attacker's way in
- C) The IP address changes
- D) The phone battery drains
Show answer
Answer: B. Every open port is like a door. An unneeded open door is one an attacker can try to walk through.
Frequently asked questions
What is a port number in networking?
A number from 0 to 65535 that identifies which app or service on a device should receive data. The IP finds the device; the port finds the app.
What does it mean when a port is open?
A service on that device is listening on that port and will accept connections. Open ports are what scanners like Nmap look for.
Which ports do websites use?
Port 80 for HTTP and port 443 for HTTPS.