Understanding Ports: How do multiple browser tabs communicate at the same time? [closed]

I realized today that I fundamentally don't understand how port communication works.

If I fire up an instance of a webserver listening on port 80, it can respond to many requests from many different browser tabs, all communicating over port 80.

However, I cannot start up two instances of the server, both listening on port 80, as it results in a port conflict.

I've always taken this as a given, (only one process can bind to a specific port at any given time) without ever really thinking it through -- aren't there multiple processes communicating on port 80? (ie., each of the tabs running in the browser?)


Basically, only one process can LISTEN on a port at a time (technically, one socket is dedicated to listening). But, a port can handle many sockets transferring data, a socket is a combination of local IP / port and remote IP address / remote port. In that way, once the server accepts the incoming connection while LISTENing it opens a new socket dedicated to that conversation and hands the processing off to something else, then goes back to LISTENing.

More detail here.


Browser connects from a random high (i.e. > 1024) port on your computer to a remote server's port 80. Therefore there's no port conflict on your machine.

If you use many tabs to connect to the same remote server (or there are many users connecting to the server) they all go to the same port and are serviced by the same process (i.e. the web server of the site).