HTTP is an application protocol which is transmitted over a TCP connection.
TCP/IP packets contain the following information:
- Destination address (IP): public Internet of the web server, e.g. 104.16.37.249 for stackoverflow.com
- Source address (IP): your public Internet address
- TCP destination port: port to reach the web server application after reaching the web server computer, 80 for HTTP, 443 for HTTPS
- TCP source port: port to reach the web browser, after the packet reaches your computer, e.g. 43505
The source port and address then become the destination port and address and vice-versa when the server sends responses to the requests from the client.
The web browser (or any TCP client) does not need to know the source port, as it is chosen automatically by the operating system. The OS provides a programmatic interface to communicate using TCP. This interface will then provide what is called a "socket" to represent this connection. The socket provides an output channel (to send requests) and an input channel (to receive responses), which is interesting as communicating over the network this way doesn't look much different as reading and writing from files.
To answer your question more specifically, the OS keeps track of which process (PID) is using which source port, so when it receives a TCP packet where the destination port matches that source port (e.g. 34505), it will know where to forward that packet. Many UNIX systems ship with netstat, that shows you exactly this:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 172.16.123.140:34034 38.127.167.38:443 ESTABLISHED 3153/chromium-browser
tcp 0 0 172.16.123.140:50309 162.125.32.129:443 ESTABLISHED 2945/chromium-browser
You can see here that there are two established / opened TCP connections to web servers 38.127.167.38 and 162.125.32.129 using HTTPs on port 443. The source address and source port are described here as "local address".
In your example, the web browser forks into multiple child processes. The operating system forwards the packets to the child processes directly. As the browser seems to create one child process per tab, then you could say the packets are being sent directly to the tab, instead of being "routed" by some kind of choreographer in the browser.
However, this would assume the browser uses one connection per tab, which is never the case, it will create many of them, even for the same host, and nothing prevents it to share a connection accross multiple tabs.
I strongly advise you to refer to a book such as Computer Networks, A. Tanenbaum, 5th Edition, Pearson.
Port for.. what? All outgoing are still your standard HTTP (80), and HTTPS (443) - unless you specifically requested otherwise. You will need to clarify your question to get a proper answer. – Darius – 2016-05-05T13:56:03.343