带有 UDP 的 JavaScript WebSockets?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4657033/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JavaScript WebSockets with UDP?
提问by
I'm writing a JavaScript Application that has to receive a huge amount of data from other users. It is not important if some of this data gets lost. Is there some way of using JavaScript WebSockets with UDP instead of TCP?
我正在编写一个 JavaScript 应用程序,它必须从其他用户那里接收大量数据。如果这些数据中的一些丢失,这并不重要。有什么方法可以将 JavaScript WebSockets 与 UDP 而不是 TCP 一起使用吗?
采纳答案by Pablo Santa Cruz
No, it's not possible to have UDP communication within JavaScript. Sorry.
不,不可能在 JavaScript 中进行 UDP 通信。对不起。
回答by Chad
回答by Nick Benes
Sounds like the question is meant for client-side UDP, but since I ended up here...
听起来这个问题是针对客户端 UDP 的,但自从我结束了这里......
You can do UDP in JavaScript on the server using the node.jsdgram
package.
回答by kanaka
The WebSockets protocol is over TCP only as currently defined.
WebSockets 协议仅在当前定义的 TCP 上。
You could do UDP with Flashif you are willing to use a RTMFP (Real Time Messaging Flow Protocol) server.
回答by Klaus
If this question is still pending: I found a project called JNEXT and there is an example using UDP. The project itself seems to be paused but at least in Firefox it works (it doesn't work with Chrome and Opera). May be it is worth to look for it.
如果这个问题仍然悬而未决:我找到了一个名为 JNEXT 的项目,并且有一个使用 UDP 的示例。该项目本身似乎已暂停,但至少在 Firefox 中它可以工作(它不适用于 Chrome 和 Opera)。也许值得寻找它。
回答by John
I think you can leverage Silverliht 4 technology. You can create a Silverlight 4 application to communicate with server and then enbamdded it to html page. Then your JavaScript can build TCP connections via Silverlight 4 application!
我认为您可以利用 Silverliht 4 技术。您可以创建一个 Silverlight 4 应用程序来与服务器通信,然后将其绑定到 html 页面。然后您的 JavaScript 可以通过 Silverlight 4 应用程序建立 TCP 连接!
回答by Tim R.
You could write a WebSocket server to serve as proxy/bridge between TCP/UDP.
您可以编写一个 WebSocket 服务器来充当 TCP/UDP 之间的代理/桥梁。