使用 HTML5 Web 套接字可以获得哪些 AJAX 无法获得的功能?
伊恩·希克森 说:
我期待 iframe 沙箱功能 如果能够的话,对于开发者来说将会是一个很大的福音 起飞。我个人最喜欢的 功能可能是 Web Sockets API,允许双向 与服务器通信,以便 你可以实现游戏、聊天、 遥控器等。
使用 Web 套接字可以获得哪些 AJAX 无法获得的功能?这只是方便,还是更有效率?服务器是否可以向客户端发送数据,而无需等待消息才能响应?
Ian Hickson says:
I expect the iframe sandboxing feature
will be a big boon to developers if it
takes off. My own personal favorite
feature is probably the Web Sockets
API, which allows two-way
communication with a server so that
you can implement games, chatting,
remote controls, and so forth.
What can you get with web sockets that you can't get with AJAX? Is it just convenience, or is it somehow more efficient? Is it that the server can send data to the client, without having to wait for a message so it can respond?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这都是关于服务器能够将数据推送到客户端的。目前,在不使用 Flash/Silverlight/Java/ActiveX 的情况下模拟双向通信采用以下两种解决方法之一的形式:
借助 WebSocket,您可以获得长轮询的所有响应能力优势,同时显着减少服务器端开销。
Yes, it's all about the server being able to push data to the client. Currently, simulating bi-directional communication without Flash/Silverlight/Java/ActiveX takes the form of one of two workarounds:
With WebSockets, you get all of the responsiveness advantages of long polling, with dramatically less server-side overhead.
WebSocket 比 AJAX 调用更高效(并且“更实时”),因为您可以保持连接打开,并且在每次请求和响应后不会发送额外的协议标头和其他内容。看看 这篇文章:
WebSockets are more efficient (and "more real-time") than AJAX calls because you keep connection open and don't send extra protocol headers and other stuff after each request and response. Look at this article: