title: How does Port Number really work in TCP?
body: <p><a href="https://serverfault.com/questions/296603/understanding-ports-how-do-multiple-browser-tabs-communicate-at-the-same-time">https://serverfault.com/questions/296603/understanding-ports-how-do-multiple-browser-tabs-communicate-at-the-same-time</a></p>
  
  <p><a href="https://stackoverflow.com/questions/2957757/how-can-an-application-use-port-80-http-without-conflicting-with-browsers?rq=1">how can an application use port 80/HTTP without conflicting with browsers?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/3329641/how-do-multiple-clients-connect-simultaneously-to-one-port-say-80-on-a-server">How do multiple clients connect simultaneously to one port, say 80, on a server?</a></p>
  
  <p>I have read the above questions but it seems the answers are inconsistent. </p>
  
  <p>I want to know what exactly defines a socket connection, is it:</p>
  
  <p><code>(sockid, source ip, source port, dest ip, dest port)</code></p>
  
  <p>or only:</p>
  
  <p><code>(source ip, source port, dest ip, dest port)</code></p>
  
  <p>Can two different processes (e.g, two different browsers) communicate with a web server on the same source port?  (the dest port would be the same by default)</p>
  
  <p>What will happen in the case of different tabs in the same browser?</p>
  
  <p>Also, as mentioned in one of the answers, a single web page can connect to multiple servers (e.g., ad servers) simultaneously. When connecting to multiple servers simultaneously, does the web browser (e.g., Chrome, Firefox) connect to each server using the same port, or does it use a different port for each server?</p>