Viewing a single comment thread. View all comments

insultant_ t1_j1zyqgd wrote

Why can’t port numbers below 49152 act like “Airbnb for applications?” Conversely, why can’t port 49153 and above have, per your analogy, “long-term tenants.” Or can they?

Furthermore, what event on the server would be equivalent to “evicting” a program from its “apartment?”

1

DragonFireCK t1_j20a7hk wrote

>Why can’t port numbers below 49152 act like “Airbnb for applications?” Conversely, why can’t port 49153 and above have, per your analogy, “long-term tenants.” Or can they?

Convention - the same as why a hotel room generally won't have a long-term occupant and an apartment won't have a short-term renter. With that, its also likely somebody else may be using them for their intended purpose, thus causing random failures if an application tries to use them incorrectly.

Firewalls will also frequently block or allow specific ports by number, though they will normally only block incoming connections, not outgoing. This may cause a program using an unexpected port to get incorrectly blocked, requiring users to manually open those ports.

>Furthermore, what event on the server would be equivalent to “evicting” a program from its “apartment?”

Generally, the operating system will have a method of force disconnecting a socket, though such APIs are normally tightly restricted in usage. In most cases, they are restricted to usage by debugging tools.

2

interwebz_2021 t1_j210clo wrote

>socket

Just in case anyone's not seen the term 'socket' before: this is a logical address comprised of the IP address and port. So, for instance, if you have a web server listening on port 80 on your local loopback interface with IP address 127.0.0.1, you can connect to the webserver via the socket with address 127.0.0.1:80

3

bbqroast t1_j210p6p wrote

Applications that are waiting for anyone to mail them (i.e. server apps) need to "bind" a port and listen for traffic.

They generally do this on a specific port, this is so applications that want to talk to them can find them.

Applications that just want to start a chat with someone (i.e. client apps) can use a random one of the temporary ports as a return address for the duration of the correspondence.

If they use a port outside that range, then potentially they might prevent one of the applications that needs to listen to a specific port from starting (only one app can use a port at once). Likewise, if you decide to use a specific port in the temporary range, you run the risk it's randomly in use by someone else

2