ELI5: In computer networking, what is a port?
ELI5: In computer networking, what is a port?
One network interface has just one IP address, but it can have a bunch of different programs listening and talking.
A server might have both a webserver and a mail server running on the same machine - and they don't want each other's network traffic.
So you mark each packet with a destination port number, to let the server work out which program you're talking to.
Your web browser will mark all its packets with port 80 or port 443, and when the server gets those, it knows it's web traffic, and passes it to the webserver software.
Your email client will mark all its packets with port 25 or 993, and when the server gets those, it knows it's email traffic, and passes it to the mailserver software.
Typically each separate kind of network service will have its own well-known port number assigned to it.
There's also a source port field on packets, so that your computer can get return traffic back to the right program running on your machine.
id say your telephone number example can be extended:
1800 is for free numbers, but why? no particular reason, just that’s the number that got chosen at some time… same with port 80 being HTTP: that’s just the number that got chosen!
you can also have an HTTP server running on port 25 (usually mail); it’s just bad practice… just like there’s no reason why your phone company couldn’t make a regular phone number toll free!
what’s pretty normal though is running an HTTP server on say, port 5000: this is just for more technical users though, because you have to know the port; your browser doesn’t “remember” it for you
There’s something important missing from most of the other answers. There’s a lot of different kinds of network and internet traffic. Web browsing, email, instant messaging, online video games…
By formal standard, certain port numbers are designated for certain functions. Web traffic happens on port 80. Incoming email is sent on port 143, outgoing email is sent on port 456 or 587. Something like Discord will have a specific port it uses for both sending and receiving messages. Word of Warcraft has certain ports its uses for telling the server when you cast a spell, and for the server to tell your client when you take damage.
So yes, ports are like PO boxes at a post office, but the analogy doesn’t quite capture it. Port 80 is always web traffic, and this is important, since your web browser requests pages on port 80, just as a web server returns web pages on port 80. The web server probably has other ports on it, like FTP (ports 20 and 21) or SFPT (port 22). If you connect to a web server on port 80, that means you’re asking for its webpages. If you connect on 20, 21, or 22, it means you’re trying to transfer files to it.
Word of Warcraft
Is Blizzard branching out into religious literature or word processing programs? 🙂
Additionally to all the correct answers, a 'port' can also mean something completely different 'in networking'.
It can be a physical socket in a network equipment, like 'Ethernet port'. Or it can be a virtual equivalent of such, e.g. when connecting virtual machines on a host - that could be called a 'logical port'.
Those can sometimes be used interchangeably with 'interface' or 'device', but it depends on convention used in particular system or environment.
Imagine you need to go see your doctor. They work in a building with 65535 rooms. Some rooms are empty. Some rooms have people in them that provide different services. But you need your doctor so you look their location.
You learn the building address (IP address) and the room number (port)
In practice, you attach services to specific ports so that other computers can access those services. Typically, http traffic is on port 80 and https is on port 443. So if you visit a website, you are likely connected to a server on one of those two ports. But it’s not a requirement. You could create a website and put it on port 2097, or 532, or 47210; it doesn’t matter.
If you would compare a server to a building, with its own street address, then port would be an apartment number for every application (tenant) living there.
Ports are what allowing you to run multiple applications and all can communicate over the internet. Without ports you would need to have separate dedicated computer for every application.
A port is like an apartment number. Except instead of apartments, it’s just mailboxes. Bob’s mailbox is number 25. If you want to get a message to Bob, uou write “box 25” on the address.
A port number is just an additional piece of info that the operating system associates with a particular program. If something comes in on port 22, the sshd is going to handle it because it’s “listening on port 22”, meaning that it has registered itself with the OS as the recipient of anything that comes in marked “port 22”.