What is the logical port of the user in PHP?

Asked

Viewed 263 times

3

1 answer

6

Physical ports are the physical connections of devices, such as a RJ-45 connector from a router or modem.

Logic ports are gates of logical connections identified by a number, which serve to connect to a service, TCP or UDP on a device (server, computer, etc).

A good analogy would be, imagine that you have a commercial building. It has an address (XXX Street, nr 1). This would be for example the IP address of the server. Once you enter the building, you can go to several places, with several rooms. Each room or apartment would be a logical door (XXX Street, Nr1, Room 10).

When accessing a web service (HTTP) from a website, in general it responds by logical port 80, a service FTP, on logic gate 21, and so on.

Logic gates range from 0 to 65535, and are divided into three groups:

  • Well-Known Ports: from 0 to 1023. These are the most common services used by default, such as port 80 for HTTP web services and port 443 for HTTPS web services.
  • Registered Ports: from 1024 to 49151. They are generally internal services of the servers, are registered for services such as authentication, proxy, and databases among others. The SQL Server for example use port 1433 by default.
  • Dynamic Ports: They range from 49152 to 65535. They are dynamic ports that usually vary for each connection. They are used for temporary connections, such as when connecting to a game, or peers of Torrent when downloading/uploading.

Here is a complete list of the "well known doors": https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

Now back to PHP. In your example you are using $_SERVER['REMOTE_PORT']. This will return you to the port you are connected to on the server.

  • the logical port is not user, it is server! remember that php runs on the server side, so it will show the port that the server made available for the user to connect to it. I don’t know if it’s clear, in practice it’s the port where the server and the user are communicating

Browser other questions tagged

You are not signed in. Login or sign up in order to post.