javascript 从 chrome 发送 udp 数据包
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13964972/
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
Send udp packet from chrome
提问by Tono Nam
Researching on the internet ( How to send udp to udp node.js server?, JavaScript WebSockets with UDP?) I have found that it is not possible to send udp packets with javascript.
在互联网上研究(如何将 udp 发送到 udp node.js 服务器?,使用 UDP 的 JavaScript WebSockets?)我发现无法使用 javascript 发送 udp 数据包。
On the other hand some pages claim that chrome browser is able to do so. For example the link:
另一方面,一些页面声称 chrome 浏览器能够这样做。例如链接:
http://blog.alexmaccaw.com/chrome-tcp-udp
http://blog.alexmaccaw.com/chrome-tcp-udp
claims that google chrome is able to send udp packets. Maybe I am doing something wrong. If it is true that chrome can send udp packets I will appreciate if someone can post a hello worldexample. I have tried the example from the link I showed and it does not work. Maybe I am doing something wrong.
声称谷歌浏览器能够发送 udp 数据包。也许我做错了什么。如果 chrome 确实可以发送 udp 数据包,如果有人可以发布一个hello world示例,我将不胜感激。我已经尝试了我展示的链接中的示例,但它不起作用。也许我做错了什么。
回答by Bergi
From the linked page:
从链接页面:
Chrome Canary now has support for raw TCP and UDP sockets in its ‘experimental' APIs. These features are only available for extensionsand, although documented, are hidden for the moment.
Chrome Canary 现在在其“实验性”API 中支持原始 TCP 和 UDP 套接字 。这些功能仅适用于扩展程序,尽管有文档记载,但目前处于隐藏状态。
So, develop an extension and it should work. Actually, that article from May '12 seems to be outdated as the chrome.socket
modulenow has lost its experimental
status. For the HelloWorld, you might check out their udp samplewhich is linked from the official pages.
所以,开发一个扩展,它应该可以工作。实际上,12 年 5 月的那篇文章似乎已经过时,因为该chrome.socket
模块现在已经失去了它的experimental
地位。对于 HelloWorld,您可以查看从官方页面链接的他们的udp 示例。