Link to home
Start Free TrialLog in
Avatar of Johny_Brav0
Johny_Brav0

asked on

Comet for xmlhttprequest (XHR) streaming and a JSON explanation

Although I have used AJAX my Comet (general word for technology allowing web server push) theory is very weak.

When using XHR object can you use multiple instances on the same connection (I imagine yes like websockets) and if you can how is this possible on one connection and one port, is it multiplexing?

How does XHR streaming work and could I have a very simple bit of AJAX code to see.

JSON explanation i.e. compared to XML and how has it anything to do with being an alternative to comet as I thought it was just like XML - a way to describe data?

Cheers
ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Johny_Brav0
Johny_Brav0

ASKER

So would synchronous AJAX option be suitable for long polling for something like chat - guess it would?

I got a bit confused with multiplexing - got the wrong end of the stick in the lecture!

Last related question: is the following understanding correct?
Usually a TCP connection requires a socket i.e. ip:port. Web sockets does not work like that, it uses one port (80) for many connections, but this is multiplexed...



Sorry, but I do not begin to understand what your meaning is, or what you want clarification for - when you say - "So would synchronous AJAX option be suitable for long polling for something like chat - guess it would?"

You can set an ajax to "Wait" for the server response before going to the next line of javascript, ( I guess as termed "synchronous AJAX") however, if the server stays active, as in a long polling set up, then you do NOT get any response data to use until the server sends the "finished" data transfer sign, again I have simplified the methodology for clarity, but I would not think that this is used for the long polling ajax, but I will admit that I have never tried it, so I'm in theory mode, you can actually try it for your self and see what kind of results you get in the "Wait" for response setting.

I might ask you - WHY are you interested in Ajax Comet, long polling exchange? ? What do you hope to do with it ? ?

On your last inquiry about multiplexed TCP connection, I did not understand your concerns or point of reference? I went to Wikipedia and looked up multiplexing, to make sure I had a correct reference for your question. It is true that a Web server uses the port address of 80 for many connections from the web interface to browsers, there's no question about that, that's just how it is.

And Wikipedia  has this = "multiplexing (also known as muxing) is a method by which multiple analog message signals or digital data streams are combined into one signal over a shared medium."

So the short answer for your last question is = NO

as far as I know, each data "socket" connection is a separate connection with only ONE data stream being sent to the receiver (usually a web browser), I am not certain from experimentation, but I believe your browser only does one data transfer at a time, I.E.. .  image data transfers are separate transfers from HTML data transfers, but are not done at the same time, but in a sequence, one after the next.

You seem to not understand the difference of a server PORT connection data transfer, and multiple data streams ,being combined and streamed as a multiplexed data transfer as an asynchronous mode time-domain multiplexing which resembles time-division multiplexing.

I really do not understand what any of this has to do with PHP and ajax? ? so sorry about my mis understanding?