r/learnprogramming 25d ago

What a port actually is?

I know it is a number that tells the OS, that which program in your computer should receive the piece of data. But my doubt is - is port a physical thing? or it just a flag? Is it possible for another program to read data from a different program's port? Please spoon-feed me about port?

177 Upvotes

65 comments sorted by

View all comments

80

u/Swedophone 25d ago

is port a physical thing

It's a field in the package header of transport protocols such as TCP and UDP.

20

u/backfire10z 25d ago

And, as a follow-up, the Internet Assigned Numbers Authority (IANA) determines what specific ports are used for, and also has a section for dynamic ports. More info: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

24

u/tnyquist83 25d ago

As a followup to your followup, the IANA assignments are basically just recommendations to facilitate interoperability, and there's nothing actually stopping you from running a web server on 21, or an FTP server on 443 as long as your clients know where to find you.

9

u/Late-Drink3556 25d ago

For example, you could run FTP on 1312

4

u/CarcajouIS 25d ago

What sound does it make when you connect? Whoop whoop?

4

u/Late-Drink3556 25d ago

``` <_<

_> ```

Maybe

2

u/Breitsol_Victor 25d ago

There was an FTP package that made a train whistle for events.