是否有用于JavaScript的Telnet库? [英] Is there a Telnet library for JavaScript?

查看:295
本文介绍了是否有用于JavaScript的Telnet库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有网络摄像头。它有一个HTTP服务器来提供当前图像。还有一个用于控制摄像机的Telnet接口(即触发器,焦点等)。我想在相机中添加一个HTML页面,它提供了一个简单的界面(我们已经有了我们编写的客户端软件)。我可以获取图像并显示它,但我也希望有控件使用Telnet接口来控制相机。因此,按钮后面可能有JavaScript代码,通过Telnet连接到摄像头(登录)并发出触发摄像头的命令。

We have a network camera. It has an HTTP server to provides the current image. There is also a Telnet interface for controlling the camera (i.e. trigger, focus, etc.). I would like to add an HTML page to the camera that would provide a simple interface (we already have client software we write). I can "GET" the image and display that, but I would also like to have controls that use the Telnet interface to control the camera. So a button might have JavaScript code behind it that connects to the camera via Telnet (logs in) and issues the command to trigger the camera.

我知道JavaScript /浏览器支持通过 XMLHttpRequest的。在这种情况下,我将寻找在端口23上打开一个套接字并发送文本。我也知道我可以通过Flash,Java或其他技术来实现这一点,但我更愿意只使用JavaScript。如果可能的话。

I know that JavaScript/browsers support connecting to the same host via XMLHttpRequest. In this case I would be looking to open a socket on port 23 and send text. I also know that I can do this through Flash, Java, or some other technology, but I would prefer to use JavaScript only. If that is possible.

推荐答案

Thomaschaaf是正确的,而HTML5引入了websockets,你会发现他们仍然需要特殊的服务器支持,因为他们打开套接字后发布HTTP样式信息:

Thomaschaaf is correct, while HTML5 introduces websockets you'll find they still require special server support as they post HTTP style information upon opening the socket:

JS / HTML5 WebSocket:无HTTP呼叫连接

目前,拥有真正套接字的最佳方法是

The best way, currently, to have true sockets is to either


  • 在执行实际套接字工作的网页上使用flash或Java组件。

  • 使用带有websockets的代理服务器,可以处理websockets的额外协议开销,并使用普通套接字连接到真正的tcp / ip端口。

mat链接的jsterm示例执行后者,如果您的网络摄像头位于防火墙后面,那么在没有实现其他服务器的情况下它将不适用于您的情况。

The jsterm example Matt linked does the latter, and if your webcans are behind a firewall it will not work in your situation without also implementing another server.

有些库实现了第一种方法,其中两种是为方便起见而链接的,其他很多都是使用搜索引擎找到的:

There are libraries that implement the first method, two are linked here for convenience, many others can be found using a search engine:

http://stephengware.com/proj/javasocketbridge/ (Java)

http:// matthaynes.net/blog/2008/07/17/socketbridge-flash-javascript-socket-bridge/ (Flash)

这篇关于是否有用于JavaScript的Telnet库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆