Is there a Telnet library for JavaScript?

元气小坏坏 提交于 2019-11-29 01:19:13
Adam Davis

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: Connect without HTTP call

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

  • use a flash or Java component on the webpage that does the actual socket work.
  • use a proxy server with websockets that can handle the additional protocol overhead of websockets and connect to the real tcp/ip port with plain sockets.

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)

Matthew Cook

jsTerm is an HTML5 implementation of a Telnet client.

You'll need a browser that supports HTML5 WebSockets. WebSockets is the only method of doing non-HTTP requests with pure JavaScript.

Currently there is no way to do socket connections with JavaScript only.

But what you are searching for is a socket connection ;)

https://developer.mozilla.org/en/XML_Extras

If I interpret the question liberally as "is there a remote connectivity library for Javascript", then the answer is yes (quoting from https://xtermjs.org/):

I've tried WebSSH2 with node.js briefly, it worked for me - I managed to connect to a Linux-based server with it.

(I know this probably doesn't help the OP but this is a 7-year old question anyway. Maybe it helps others who are needing an answer to a similar problem.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!