如何实现在Telnet客户端选项卡完成 [英] How to implement tab completion on the telnet client side

查看:113
本文介绍了如何实现在Telnet客户端选项卡完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有打开的连接为一个telnet客户端的服务器,像
例如:
我运行服务器 ./服务器,并在另一个窗口我运行Telnet客户端远程登录为本地主机9999,
当我运行Telnet客户端,我会得到新的命令行提示符的CLI >>

I have a server which opens a connections for a telnet client, like for example: I run the server ./server and in another window I run telnet client as telnet localhost 9999, as I run the telnet client, I will get new CLI prompt as CLI>>.

从这个提示我需要自定义选项卡完成,但很多的博客说,我们可以真的没有的Telnet端实现readline的功能,如果让我们去为我们自己的客户。

From this prompt I need custom tab completion, but many of the blog says we can really dont have readline feature implemented on the telnet side, if so we have go for our own client.

我该如何实现呢?任何相关的帮助将是很大的AP preciated。我使用的Linux(Ubuntu的)和C语言。

How do I achieve it? Any related help would be greatly appreciated. I am using linux(Ubuntu) and C language.

推荐答案

您可以在客户端或服务器上实现这一点。

You can implement this either on the client or on the server.

有关的客户端实现有两种方式(其基本上是相同的):

For the client-side implementation there are two ways (which are basically the same):


  1. 当客户端连接,服务器发送命令和它们的参数的列表,并且在客户端高速缓存。当用户presses的<大骨节病> TAB 键,则客户机搜索该缓存数据。

  1. When the client connects, the server sends a list of commands and their arguments, and that is cached in the client. When a user presses the TAB key the client searches this cached data.

在客户端注意到了<大骨节病> TAB 键pressed,它要求在服务器上为尽可能完整的列表。对于速度此清单应在客户端进行缓存。

When the client notices the TAB key being pressed, it asks the server for a list of possible completions. For speed this list should be cached on the client side.

因此​​,这里的基本方案是:服务器将数据发送到客户端,客户端显示的数据。

So the basic solution here is: Server sends data to client, client shows data.

对于服务器端执行,你必须使用telnet协商来告诉客户端发送原始未煮过的字符和按键,无需到服务器的任何干扰。然后服务器可以检查<大骨节病> TAB 键并执行完成。

For a server-side implementation, you have to use telnet negotiation to tell the client to send raw uncooked characters and keys without any interference to the server. Then the server can check for the TAB key and perform completion.

这里的问题是,那么你必须添加的所有命令行编辑,并在服务器code提示,并且可以不依赖于客户端上的是什么,但一个哑终端。

The problem here is that then you have to add all command line editing and prompting in the server code, and can't rely on the client be anything but a "dumb terminal".

拥有所有处理完成服务器端具有您可以使用几乎所有的Telnet客户端的上行空间(只要它能够处理的telnet谈判),并没有使自己的自定义客户端。其缺点是,你接下来要实现整个命令行编辑功能在自己的服务器上,而且,由于每个按键都有被发送到服务器,然后从回显的键盘presses潜伏期可高服务器

Having all processing done server-side has the upside that you can use almost any telnet client (as long as it can handle the telnet negotiations) and don't have to make your own custom client. The drawback is that you then have to implement the whole command-line editing features yourself in the server, and that the latencies for key-presses can be high as each key has to be sent to the server and then echoed back from the server.

有一个定制的客户端,有哪些可以轻松处理命令行编辑和完成帮助图书馆上行。这里的主要缺点是,你必须做出一个自定义的客户端。

Having a custom client has the upside that there are libraries which can easily handle command-line editing and help with the completion. The major downside here is that you have to make a custom client.

这篇关于如何实现在Telnet客户端选项卡完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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