如何使用HTML5与UDP套接字通信? [英] How to talk to UDP sockets with HTML5?
问题描述
正在运行的C ++应用程序服务器,准备将数据发送到客户端,这应该是HTML5页面或应用程序。
我想要什么:有什么方法可以使用udp端口与HTML5进行通信,因为c ++服务器和HTML5应用程序都是系统本地的?
我知道:
答案仍然是'NO'?
有没有可行的解决办法?
任何领导都表示赞赏。
是的,答案仍然是'不'。 Websockets基于TCP。请注意,WebSocket不是普通的TCP连接,有HTTP协商和成帧协议。所以你也不能在Javascript中创建一个普通的TCP连接。
WebRTC基于UDP,它可能覆盖你的用例: http://www.html5rocks.com/en/tutorials/webrtc/datachannels/
What I have : A C++ application server running, Ready to send data to client which is supposed to a HTML5 page or app.
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 ?
What I know :
- Because of Security Concern, JS doesn't allow UDP port communication from browser.
- Have read in many places, Answer is no. But answers are old.
Is the answer still 'NO' ?
Is there any work-around possible ?
Any lead is appreciated.
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 is based on UDP, it may cover your use cases: http://www.html5rocks.com/en/tutorials/webrtc/datachannels/
这篇关于如何使用HTML5与UDP套接字通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!