Jump to content

How does the client know which server-sent page goes to which tab/window?


ocpaul20

Recommended Posts

I think this is a server issue but feel free to move it if you think it belongs somewhere else.

 

I think I recall that servers are stateless which I assume means that each request and response is in effect as if it is 'the first' one ever received.

 

If there are two tabs open pointing to the same web site, how does a browser know which tab gets the response from the server? If one server page takes longer than another, potentially, they could return to the client in reverse order.

 

 

Is there some kind of sent code which says to the browser which request goes where?

Link to comment
Share on other sites

OK, so if I was writing a browser program, how would I match up the requests for pages from the server and the pages received.

 

There has to be some way if the browser has two pages open from the same website being served from the same server. It is a basic browser function surely?

Link to comment
Share on other sites

Short version - The port number determines which response matches which request.

 

The HTTP request contains a port number (incremented for each request) that the request was made from. When the server sends the response back, it carries the port number of that request.

 

To find out what happens if you have two tabs open in one browser, I recommend echoing the $_SERVER['REMOTE_PORT'] on your page. If the different tabs have wildly different series of port numbers, then it is probably using the port number. If they have the same series of port numbers, then something else either in the protocol or the headers is being used to identify where the response should go.

Link to comment
Share on other sites

I put it in apache because I thought it might have something to do with the server, but from the answers it seems that the server just gets the page and sends it back with the relevant information that was send from the client.

 

 

Short version - The port number determines which response matches which request.

Does this mean that if I save the IP number and the remote port number I can determine how many different tabs/instances of the browser have a page from my website opened? I guess it does then.

Link to comment
Share on other sites

I have done a quick investigation by displaying REMOTE_PORT on different pages loaded in different tabs, and sometimes they are the same and sometimes they change, so as you say, it seems to be using this somehow, but it may be not as simple as one tab = one port number. I have asked on the firefox forum and hopefully someone will be able to give a definitive answer. I would not know where to begin to look throught the source code of FF for this kind of thing. I will report back on this if I get any interesting information. Thanks for your help.

Link to comment
Share on other sites

Thank you. I have read this and it is a useful description and background information on tabs in all their various forms.It also gives examples of various sorts and where they can be found, when they were originally used, etc.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.