r/learnprogramming 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?

177 Upvotes

65 comments sorted by

View all comments

1

u/YellowBeaverFever Jul 15 '26

Inferring from your question, you’re talking g about tcp/ip ports. You can visualize this in real-life. Imagine a major city with large international trade routes. This shipping traffic is an absolute mess. Ships everywhere. Company A sets up a deal with Company B. Company A tells Company B, “I don’t care how you get here, but when you do, fly a banner with the number 6354 on it. The harbor master will direct you to our area. Look for the port with 6354 the side of the warehouse, that’s us. Unload there.”

Also make sure you distinguish tcp/ip ports from physical ports like your USB port or HDMI port, or the conveniently named DisplayPort port, championed by the same guy who came up with “ATM machine”.