Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do Web browsers use different port numbers for open tabs?

Tags:

I'm wondering how browsers internally works. Now, connecting to different Web sites using 'Tabs' within the same browser can be handled in one of two ways: 1 - Using threads 2 - Using Different Source Port Numbers for each open tab

I know there might not be a single answer for this question, and it might differ from one browser to another, however all responses are appreciated.

Thanks


Thanks for everyone.I really appreciate that. My question relates to the Source Port at the client side. I'm asking if the browser uses different source ports for each tab it opens, or the same source port for the entire process 'I mean window that includes different tabs', or the same source port for the entire windows?

Or, do web browsers use threads?

like image 924
Haitham A. El-Ghareeb Avatar asked Jul 09 '11 04:07

Haitham A. El-Ghareeb


People also ask

Do different tabs have different port numbers?

Each tab might be using different port numbers to facilitate different traffic types and perform different functions.

What port does web browsing use?

Port 80 and 443 are the two standard ports used by web servers to communicate with the web clients. When data is exchanged through the Internet between a web client and a web server, they need to establish a mutual connection between them.

Does the second browser use the same source port number?

They always use the same remote port unless you physically specify otherwise (for example, connecting to a website using https:// instead of http:// uses a separate port because that's how that protocol was made). You can specify a port to use in modern browsers with :# after the name, too.

Do browsers use port 80?

if a scheme isn't specified, Chrome defaults to http:// because that's what web browsers expect. that's port 80 by default. if you explicitly put in https:// then it will default to port 443.


2 Answers

Threads and ports are separate and mostly unrelated concepts.

Threads are what the local computer processor does to handle computations, such as drawing to the screen or waiting for Internet traffic. There's probably a separate thread (and more) for those operations in each tab.

Ports are what the traffic itself is identified by (in TCP and UDP). In order to communicate your browser would open a local port (usually something big like ~5000, and that doesn't matter as long as its unique) and connect to the server on usually port 80 (the one the server is listening on). If your computer didn't know the remote port it couldn't connect, but its standard to use 80 for HTTP, for example.

Browsers open tabs in separate threads (and new ones even in separate processes for security and reliability reasons), and use separate ports on the client side. So yes, the answer is both threads and ports. They always use the same remote port unless you physically specify otherwise (for example, connecting to a website using https:// instead of http:// uses a separate port because that's how that protocol was made). You can specify a port to use in modern browsers with :# after the name, too. (example: http://www.google.com:81/, however that will fail because that's not what port they listen on!)

like image 185
Ribose Avatar answered Sep 22 '22 20:09

Ribose


A quick check using netstat (or sockstat on BSD machines) reveals that different source port numbers are used for different connections. In that regard, you are right.

Firefox uses at least one thread for each tab. Each thread could open multiple connections for different data (for example, loading images from a media server and content from the web server). Each connection should have its own source port.

like image 31
vinod Avatar answered Sep 21 '22 20:09

vinod