Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't do raw sockets from a web application in a browser. Even "raw" socket connections from Flash are not really raw because you have to answer a policy file request to get <a href="http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing">CORS</a> security (part of the reason for the WebSockets handshake).</p> <p>After the initial WebSocket handshake, WebSocket messages have two bytes of framing overhead per frame (Hixie-* has '\x00...\xff' and HyBi-07 has two byte header), so the overhead is pretty negligible compared to regular sockets.</p> <p>The WebSocket handshake is an HTTP compatible Upgrade request so it is easy to integrate WebSockets support into existing web servers and to use existing Web ports (80/443) which means that WebSocket connection can also more easily integrate into existing firewall rules.</p> <p>The HTTP compatible handshake also means that existing HTTP authentication mechanisms can work transparently with WebSockets. Also, WebSockets can be proxied by existing web proxies with little or no modification.</p> <p>In the next revision of the WebSockets protocol rev (HyBi-07), their is protection against misbehaving web intermediaries using client to server XOR masking of the payload data.</p> <p>Things like auto-reconnection, session ids, etc aren't defined in WebSockets although several Javascript frameworks built on WebSockets have this such as <a href="http://socket.io">Socket.IO</a>. If you are doing WebSockets from Flash applications then you would need to do your own session management or convert an existing session management library to use WebSockets rather than Flash sockets (such be pretty easy conversion).</p> <p><strong>Update</strong>:</p> <p>Couple of links that might be useful to you or others who land here:</p> <ul> <li><a href="https://github.com/Worlize/AS3WebSocket">AS3WebSocket</a>: WebSockets client library for Flash applications.</li> <li><a href="https://github.com/gimite/web-socket-js">web-socket-js</a>: WebSockets fallback/polyfill implemented in Flash for Javascript applications (to add WebSockets support to browsers with Flash but without native WebSockets).</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. CORegarding overhead, it is 2 bytes Minimum, but usually more. From client to server it is additional 4 bytes for mask. As well when data is longer then 126 bytes, you have to add another 4 bytes for uint for length. So it is usually about 10 bytes overhead of data to send. But there is more important thing, is to process this header and do demasking on server side for each message, so you use much more CPU to process data. As well if you create nice serialization from data straight to binary, then it will be much better then using utf8 messages for as example JSON. For flash use raw.
      singulars
    2. COMaksims, the HyBi working group was very intentional in which mechanism was selected for masking client -> server traffic. Because the mask is included in the frame there is no state to remember, and the running 4 byte XOR is just about the fastest (and efficient) streaming operation across lots or architectures. Also important to note is that server -> client traffic is not ever masked and large data is usually server -> client. Also, 126 -> 65535 byte frames have 2 bytes extra NOT 4 bytes more. Over 65535 is 8 extra bytes. This header overhead will not make measurable real world difference.
      singulars
    3. COWell what about: "Every new technology comes with a new set of problems. In the case of WebSocket it is the compatibility with proxy servers which mediate HTTP connections in most company networks. The WebSocket protocol uses the HTTP upgrade system (which is normally used for HTTP/SSL) to "upgrade" an HTTP connection to a WebSocket connection. Some proxy servers do not like this and will drop the connection. Thus, even if a given client uses the WebSocket protocol, it may not be possible to establish a connection." - http://www.html5rocks.com/en/tutorials/websockets/basics/
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload