Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can an application use port 80/HTTP without conflicting with browsers?

If I understand right, applications sometimes use HTTP to send messages, since using other ports is liable to cause firewall problems. But how does that work without conflicting with other applications such as web-browsers? In fact how do multiple browsers running at once not conflict? Do they all monitor the port and get notified... can you share a port in this way?

I have a feeling this is a dumb question, but not something I ever thought of before, and in other cases I've seen problems when 2 apps are configured to use the same port.

like image 981
Mr. Boy Avatar asked Jun 02 '10 12:06

Mr. Boy


People also ask

Does browser use port 80?

Yes, they do. Notes: You can see that the local ports are all different. The remote ports are usually 80 (HTTP), 443 (HTTPS) or 8080 (HTTP Alternate).

What does port 80 HTTP do?

On a Web server or Hypertext Transfer Protocol daemon, port 80 is the port that the server "listens to" or expects to receive from a Web client, assuming that the default was taken when the server was configured or set up.

Can we use a port other than 80 for HTTP protocol?

Since port 80 is not an option, you need to find an alternative port. There is no official HTTP alternative port. When port 80 is used for one address/webserver, it's fairly common to use port 8080 or 8000 for another site on the same address/webserver.


1 Answers

There are 2 ports: a source port (browser) and a destination port (server). The browser asks the OS for an available source port (let's say it receives 33123) then makes a socket connection to the destination port (usually 80/HTTP, 443/HTTPS).

When the web server receives the answer, it sends a response that has 80 as source port and 33123 as destination port.

So if you have 2 browsers concurrently accessing stackoverflow.com, you'd have something like this:

Firefox (localhost:33123) <-----------> stackoverflow.com (69.59.196.211:80) Chrome  (localhost:33124) <-----------> stackoverflow.com (69.59.196.211:80) 
like image 170
Flavius Stef Avatar answered Sep 23 '22 03:09

Flavius Stef