javascript HTML5 中的 TCP/IP 套接字通信

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18050494/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 10:35:27  来源:igfitidea点击:

TCP/IP socket communication in HTML5

javascripthtmlsocketstcp-ip

提问by Mark

I'd like to know if my idea is even possible, but based on everything I've searched for so far, it seems like it's not possible. I would love to hear what the experts think.

我想知道我的想法是否可行,但根据我迄今为止搜索的所有内容,似乎不可能。我很想听听专家们的意见。

Goal: Interface with laboratory equipment via TCP/IP sockets using HTML/Javascript.

目标:使用 HTML/Javascript 通过 TCP/IP 套接字与实验室设备接口。

One problem is that I have no control to program the server. Therefore, I can't use HTML5 websockets. The vendor has not implemented websockets. The equipment server waits for a socket connection, and then communicates via API.

一个问题是我无法控制对服务器进行编程。因此,我不能使用 HTML5 websockets。供应商尚未实施 websockets。设备服务器等待socket连接,然后通过API进行通信。

Because HTML5 and Javascript are relatively OS-independent and are 'built' for user display, I'd like to create a browser-based program. I've found related questions and answers on SO, but they are older now, so I'm wondering what is the current technology.

因为 HTML5 和 Javascript 相对独立于操作系统并且是为用户显示而“构建”的,所以我想创建一个基于浏览器的程序。我在 SO 上找到了相关的问题和答案,但它们现在更旧了,所以我想知道当前的技术是什么。

Thanks in advance, and please let me know if you have any questions.

提前致谢,如果您有任何问题,请告诉我。

回答by Tudmotu

The W3C published a first draft for a 'Raw Socket' standard:
http://www.w3.org/TR/raw-sockets/

W3C 发布了“原始套接字”标准的初稿:http:
//www.w3.org/TR/raw-sockets/

I think this might be what you're looking for, but I wouldn't count on it being implemented by vendors in the near future, since it's only a first draft.

我认为这可能是您正在寻找的内容,但我不指望供应商在不久的将来会实施它,因为它只是初稿。

Another thing I found out while searching, is that chrome apparently enables tcp/ip communications in extensions (did not check this myself, so can't gurantee):
http://developer.chrome.com/apps/app_network.html

我在搜索时发现的另一件事是,chrome 显然在扩展中启用了 tcp/ip 通信(我自己没有检查过,所以不能保证):http:
//developer.chrome.com/apps/app_network.html

If possible, you might consider writing a chrome extension (though it's not really "HTML5").

如果可能,您可以考虑编写一个 chrome 扩展程序(尽管它不是真正的“HTML5”)。

回答by PaulProgrammer

I read this as needing essentially a telnet session to your equipment.

我认为这基本上需要与您的设备进行 telnet 会话。

Currently, there's no way to do this from the browser without a plugin.

目前,没有插件就无法从浏览器执行此操作。

This question has some similar discussion: Best way to display high-speed data from a telnet interface on a web view?

这个问题有一些类似的讨论:Best way to display high speed data from a telnet interface on a web view?

回答by Jiri

Why not use the server where the HTML5/Javascript code is created. To create to connection to the device and convert this to something you can use, like websockets.

为什么不使用创建 HTML5/Javascript 代码的服务器。创建与设备的连接并将其转换为您可以使用的内容,例如 websockets。