HTTP Polling, Long Polling, HTTP streaming and WebSockets

Source: Internet
Author: User
Tags silverlight

I have read many posts on so and the web regarding the keywords in my question title and learned a lot from them. Some of the questions I read is related to specific implementation challenges while others focus on general concepts. I just want to make sure I understood all of the concepts and the reasoning why technology X is invented over technology Y and so on. So here goes:

Http Polling: Basically AJAX, using XMLHttpRequest.

Http Long Polling: AJAX But the server holds the response unless the server have an update, as soon as the server have an update, it send s it and then the client can send another request. Disadvantage is the additional header data, needs to being sent back and forth causing additional overhead.

Http Streaming: Similar to long polling but the server responds with a header with "Transfer encoding:chunked" and hence we don't need t o Initiate a new request every time the server sends some data (and hence save the additional header overhead). The drawback here is, we have to ' understand ' and figure out the ' structure of the data to distinguish between multiple Chunks sent by the server.

Java Applet, Flash, Silverlight: They provide the ability to connect to sockets servers over TCP/IP but since they is plugins, developers don ' t want to DEP End on them.

WebSockets: They is the new API which tries to address the short comings of above methods in the following Manne R:

    • The only advantage of WebSockets over plugins like Java Applets, Flash or Silverlight was that WebSockets be natively Buil T into browsers and does not rely on plugins.
    • The only advantage of WebSockets over HTTP streaming is so you don ' t has a effort to "understand" and a parse th E data received.
    • The only advantage of WebSockets over Long Polling are that of elimination of extra headers size & opening and closing of socket connection for request.

Is there any and significant differences that I am missing? I ' m sorry if I am re-asking or combining many of the questions already on so into a single question, but I just want to Ma Ke perfect sense out of a all the info that's out there on so and the web regarding these concepts.

There is more differences than the ones you have identified.

Duplex/directional:

    • Uni-directional:http poll, long poll, streaming.
    • Bi-direcitonal:websockets, plugin Networking

In order of increasing latency (approximate):

    • WebSockets
    • Plugin Networking
    • HTTP Streaming
    • HTTP Long-poll
    • HTTP Polling

CORS (Cross-origin support):

    • Websockets:yes
    • Plugin Networking:flash via policy request (not sure about others)
    • HTTP * (some recent support)

Native binary data (typed arrays, blobs):

    • Websockets:yes
    • Plugin Networking:not with Flash (requires URL encoding across Externalinterface)
    • HTTP *: Recent proposal to enable binary type support

Bandwidth in decreasing efficiency:

    • Plugin Networking:flash sockets is raw except for initial policy request
    • Websockets:connection Setup handshake and a few bytes per frame
    • HTTP Streaming (re-use of server connection)
    • HTTP long-poll:connection for every message
    • HTTP poll:connection for every message + No data messages

Mobile Device Support:

    • Websocket:ios 4.2 and up. Some Android via Flash emulation or using Firefox for Android or Google Chrome for Android which both provide native WEBSO Cket support.
    • Plugin networking:some Android. Not on IOS
    • HTTP *: Mostly Yes

Javascript usage complexity (from simplest to most complicated). Admittedly complexity measures is somewhat subjective.

    • WebSockets
    • HTTP poll
    • Plugin Networking
    • HTTP Long poll, streaming

Also Note that there are a proposal for standardizing HTTP streaming called Server-sent Events. It is currently fairly early in it's evolution and is designed to provide a standard Javascript API with comparable simpli City to WebSockets.

HTTP Polling, Long Polling, HTTP streaming and WebSockets

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.