Telnet服务器->退格/删除不起作用
我正在用 C# 实现一个简单的概念证明 Telnet 服务器,并通过内置的 telnet 客户端 Windows 对其进行 telnet。 我将所有非 IAC 数据回显给客户端。但是,我不知道如何让退格键/删除键正常工作。 我尝试了从 telnet 客户端作用于“BS”的几种组合:
- “BS”(将光标向后移动一位但不删除字符)
- “BS”“DEL”(仅与“BS”相同的结果)
- “BS”“DEL” ''ESC[3~'(相同的结果)
任何人都可以指出我退格并从屏幕上删除字符的正确控制序列是什么?
谢谢,
汤姆
I'm implementing a simple proof of concept Telnet server in C# and telnet to it via the windows built in telnet client.
I echo all non IAC data back to the client. However, I can't figure out how to get backspace/delete to work correctly.
I tried several combinations acting on 'BS' from the telnet client:
- 'BS' (moves cursor back by one but doesn't delete character)
- 'BS''DEL' (same result as 'BS' only)
- 'BS''DEL''ESC[3~' (same result)
Can anyone please point me to what's the correct control sequence to backspace and remove the character from the screen?
Thanks,
Tom
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
多年来我一直试图弄清楚这一点,但如果回声打开,它实际上非常简单。当检测到
\b
(退格键)时。您可以发送(通过套接字):0x08
发送退格键,这是一种非破坏性退格键,它只是将光标移动到左侧。0x20
发送一个空格来删除该字符,然后再次按退格键将光标移回左侧。效果就像一个魅力!干杯
I was stuck trying to figure this out for ages but its actually extremely simple if echo is on. When a
\b
(backspace) is detected. You can send (through socket):0x08
sends the backspace, which is a non destructive backspace at it just moves the cursor to the left one.0x20
sends a space which the deletes that character, and then the backspace again moving the cursor back to the left. Works like a charm!Cheers
删除和退格的行为取决于服务器的终端仿真。此外,在客户端中按退格键和/或删除键可能会也可能不会将实际的退格键和删除键代码发送到服务器,具体取决于服务器认为的模拟是什么。我不相信有一个与终端无关的命令可以后移一个字符并删除最后一个字符。 这里对此问题进行了很好的讨论。
最后,不要使用windows内置的telnet客户端。太糟糕了。我更喜欢Van Dyke的SecureCRT,但如果你不想花钱,PuTTY 是一个流行的免费客户端。
Behavior of delete and backspace are dependent on the terminal emulation of the server. Further, hitting backspace and or delete in the client may or may not send the actual backspace and delete keycodes to the server, depending on what it believes the emulation to be. I don't believe there is a terminal agnostic command for moving back one character and removing the last character. Here's a good discussion of the problem.
Finally, don't use the windows built in telnet client. It sucks. I prefer Van Dyke's SecureCRT, but if you don't want to spend money, PuTTY is a popular free client.
我刚刚连接到 Cisco 交换机并跟踪 IOS 是如何实现它的。
IOS 在来自客户端的传入“BS”上发送“BS”“SPACE”“BS”。所以,这就是我现在实现它的方式并且效果很好。
I just connected to a Cisco switch and traced how IOS is implementing it.
IOS is sending 'BS' 'SPACE' 'BS' on an incoming 'BS' from the client. So, that's how I implemented it now and works great.
它会删除您在终端和缓冲区中回显的数据。
首先检查退格键并减少缓冲区,然后使用 BS 和空格键。它非常适合 Telnet。您不必更改 terterm 或 putty 中的任何内容。
Its delete the data which you echo on your terminal and also in your buffer.
first check for backspace and decrement your buffer and then use BS and Space. Its work perfectly for Telnet. You donot have to change anything in teraterm or putty.