的WebSockets VS在Flash原始TCP套接字 [英] WebSockets vs raw TCP sockets in Flash

查看:171
本文介绍了的WebSockets VS在Flash原始TCP套接字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么的WebSockets添加到原始的TCP连接? 为什么要使用的WebSockets?

What WebSockets add to raw TCP connection? Why should I use WebSockets?

我想听听缺点和优点,如:

I'd like to hear cons and pros like:

  • 好:WebSockets的增加一些有用的东西像autoreconnection,会话ID等。
  • 错误:WebSockets的增添了不少的开销

我只有闪存的客户,没有必要支持Javascript客户。

I'll have only Flash clients, no need to support Javascript clients.

推荐答案

您无法在浏览器中的Web应用程序做原始套接字。即使从Flash原始套接字连接是不是真的生,因为你必须回答一个策略文件请求,以获得 CORS 安全性(为的WebSockets握手的原因之一)。

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 CORS security (part of the reason for the WebSockets handshake).

初​​始WebSocket的握手之后,WebSocket的消息具有两个字节每帧成帧开销(Hixie- *具有'\ x00的... \ XFF'和HyBi-07具有两个字节的头),所以开销pretty的可以忽略不计相比于普通插座。

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.

WebSocket的握手是一个HTTP兼容升级的要求,所以很容易集成的WebSockets支持到现有的Web服务器,并利用现有的网络端口(80/443),这意味着WebSocket连接也可以更方便地集成到现有的防火墙规则。

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.

中的HTTP兼容的握手也意味着现有的HTTP认证机制可以使用WebSockets透明地工作。此外,的WebSockets可以通过现有的Web代理很少或根本没有修改被代理。

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.

在的WebSockets协议REV(HyBi-07)的下一个版本,它们是防止使用客户的有效载荷数据的服务器XOR屏蔽行为异常的网络中介。

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.

之类的东西自动重新连接,会话ID等不在的WebSockets定义虽然建在WebSockets的几个JavaScript框架有这个如 Socket.IO 。如果您是从Flash应用程序做的WebSockets,那么你需要做你自己的会话管理,或将现有的会话管理库使用的WebSockets,而不是闪存插槽(例如是pretty的轻松转换)。

Things like auto-reconnection, session ids, etc aren't defined in WebSockets although several Javascript frameworks built on WebSockets have this such as Socket.IO. 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).

更新

几个环节,可能对您有所帮助或其他人谁的土地位置:

Couple of links that might be useful to you or others who land here:

  • AS3WebSocket :WebSockets的客户端库的Flash应用程序
  • 网络插座JS :WebSockets的后备/ polyfill实现在Flash中的JavaScript应用程序(如添加的WebSockets支持以浏览器与Flash,但没有本地的WebSockets)。
  • AS3WebSocket: WebSockets client library for Flash applications.
  • web-socket-js: WebSockets fallback/polyfill implemented in Flash for Javascript applications (to add WebSockets support to browsers with Flash but without native WebSockets).

这篇关于的WebSockets VS在Flash原始TCP套接字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆