Javascript 中的 UDP 用于本地主机上的进程间通信
UDP in Javascript for interprocess communication on localhost
是否可以使用 Javascript 将 UDP 数据包发送到本地端口(并从本地端口接收 UDP 数据包)?
我不想 运行 node.js,尽管那里有一个 datagram
对象。我正在使用 IE,所以不能使用 Mozsockets 或 chrome.udp.sockets 对象。
例如,我可以在 iFrame 中托管 swf 并使用 flash 从 javascript(通过 Flash)发送到本地端口吗?目前就只有这个想法了。
简短回答:不,出于安全原因,无法在 Java脚本中执行此操作。
长答案:一些插件支持 UDP 通信。例如,您可以使用 Flash 的 Adobe AIR 的 DatagramSocket。如果您要与无法更改的现有 API 交互,这可能是您唯一的选择。
但是,如果您是从头开始构建此应用程序并打算将其部署到 Web 上,我强烈建议您考虑其他传输方式。看看LocalStorage or Shared Workers for browser-based IPC, Websockets for asynchronous client-server communication and WebRTC for peer-to-peer communication (although support for this standard is still a work in progress). This will allow you to support Apple devices and Linux as Adobe drops flash support on the platform,以及提供比Flash或Java小程序更好的安全保证。
是否可以使用 Javascript 将 UDP 数据包发送到本地端口(并从本地端口接收 UDP 数据包)?
我不想 运行 node.js,尽管那里有一个 datagram
对象。我正在使用 IE,所以不能使用 Mozsockets 或 chrome.udp.sockets 对象。
例如,我可以在 iFrame 中托管 swf 并使用 flash 从 javascript(通过 Flash)发送到本地端口吗?目前就只有这个想法了。
简短回答:不,出于安全原因,无法在 Java脚本中执行此操作。
长答案:一些插件支持 UDP 通信。例如,您可以使用 Flash 的 Adobe AIR 的 DatagramSocket。如果您要与无法更改的现有 API 交互,这可能是您唯一的选择。
但是,如果您是从头开始构建此应用程序并打算将其部署到 Web 上,我强烈建议您考虑其他传输方式。看看LocalStorage or Shared Workers for browser-based IPC, Websockets for asynchronous client-server communication and WebRTC for peer-to-peer communication (although support for this standard is still a work in progress). This will allow you to support Apple devices and Linux as Adobe drops flash support on the platform,以及提供比Flash或Java小程序更好的安全保证。