如何使用 HTML5 与 UDP 套接字通信? [英] How to talk to UDP sockets with HTML5?
问题描述
我所拥有的:正在运行的 C++ 应用程序服务器,准备将数据发送到应该发送到 HTML5 页面或应用程序的客户端.
What I have : A C++ application server running, Ready to send data to client which is supposed to a HTML5 page or app.
我想要的是:如果 C++ 服务器和 HTML5 应用程序都是系统本地的,那么有什么方法可以使用 udp 端口与 HTML5 进行通信?
What I want : Is there any way to communicate using udp port with HTML5 given both c++ server and HTML5 app are local to system ?
我所知道的:
- 出于安全考虑,JS 不允许来自浏览器的 UDP 端口通信.
- 在很多地方都看过,答案是否定的.但答案是旧的.
答案还是不"吗?
有什么可能的解决方法吗?
Is there any work-around possible ?
感谢任何线索.
推荐答案
是的,答案仍然是否".Websockets 是基于 TCP 的.请注意,WebSocket 不是普通的 TCP 连接,存在 HTTP 协商和帧协议.所以你也不能在 Javascript 中创建一个普通的 TCP 连接.
Yes, the answer is still 'no'. Websockets are TCP based. Note that a WebSocket is not a plain TCP connection, there is HTTP negotiation and a framing protocol in place. So you also cannot create a plain TCP connection in Javascript.
WebRTC 基于 UDP,它可能涵盖您的用例:http://www.html5rocks.com/en/tutorials/webrtc/datachannels/
WebRTC is based on UDP, it may cover your use cases: http://www.html5rocks.com/en/tutorials/webrtc/datachannels/
这篇关于如何使用 HTML5 与 UDP 套接字通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!