本文介绍了从 WebSocket 开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 WebSockets 感到非常困惑.我读了一些关于 WebSockets 的博客,它需要 node websocket 服务器,我下载了演示文件,但聊天应用程序似乎不起作用.总结一下,我需要什么才能使用 WebSockets?我需要下载 node 服务器还是什么?什么是与 socket.io 相互关联的东西?

I had a huge confusion in WebSockets. I read some blog about WebSockets and it requires node websocket server, I downloaded the demo files and the chat application didn't seem to work. To summarize this, what do I need to use WebSockets? Do I need to download node server or something? And what is something to relate with socket.io to one another?

推荐答案

WebSockets?

WebSockets 是一种通过网络实现套接字通信(到服务器)的标准.

WebSockets?

WebSockets is a standard for implementing socket communication (to a server) over the web.

现在这个以套接字通信为主的服务器可以以任何方式实现.Node 无疑是实现服务器端的流行选择,但它不是唯一的选择,您可以使用 python、erlang、ruby 或任何其他可以绑定套接字连接的语言.

Now this server which the socket communication prevails between can be implemented in any way whatsoever. Node is surely a popular option to implement the server side in however its not the only, you can use python, erlang, ruby, or any other language where you can bind a socket connection.

socket.io 是一个 javascript 库,它使 socketsocket-like 网络连接成为可能.看到 WebSockets 是一个最新标准,并非所有浏览器都支持它,只有现代浏览器支持(证明:http://caniuse.com/#search=websockets).是什么让 socket.io 如此受欢迎,像彩虹和童话一样(也是您在研究 WebSockets 时偶然发现它的主要原因之一)是它将使所有浏览器中的套接字/类套接字通信成为可能.

socket.io is javascript library which makes it possible for socket OR socket-like connections over the web. See the WebSockets is a recent standard, not all browsers support it, only the modern ones do (proof: http://caniuse.com/#search=websockets). What makes socket.io so popular, rainbow and fairy tale like (and one of the main reasons why you happened to stumble upon it while researching WebSockets) is that it will make socket/socket-like communications possible in all browsers.

  • socket:当 socket.io 检测到支持 WebSockets 的浏览器时,它会使用此 WebSockets 实现进行套接字通信.
  • socket-like:但是,当 socket.io 检测到不支持 WebSockets 的浏览器时,它仍会为您提供类似 socket 的通信.花絮:此功能的内部使用 AJAX 轮询.
  • socket: when socket.io detects a browser supporting WebSockets, in which case it uses this WebSockets implementation for the socket communications.
  • socket-like: however when socket.io detects a browser which does NOT support WebSockets it will still provide you with socket-like communication. Tid bit: the internals of this feature use AJAX polling.

这篇关于从 WebSocket 开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 17:01