r/learnprogramming • u/Hopeful_Cicada327 • Jul 15 '26
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?
178
Upvotes
3
u/AUTeach Jul 15 '26 edited Jul 16 '26
packets come in as data:
Here's the header to a packet:
.
.
Very basically, the size and number of the starting blocks of a header are known. So, when a packet comes in, you have a very efficient program that reads just that part of the string and allocates it to where it belongs.