强制 telnet 客户端进入字符模式
我有一个应用程序,我接受来自 telnet 客户端的套接字连接,并建立一个简单的键盘驱动的字符 GUI。
telnet 客户端(至少在 Linux 上)默认为一次一行模式,因此我总是必须手动执行 ^]mode char
。
浏览相关 RFC 表明,如果我的应用程序只是在客户端连接后立即发送字符 IAC DONT LINEMODE (\377\376\042)
,则应强制客户端进入字符模式。 然而,这没有任何区别。
完成这项工作的最简单的代码是什么? 理想情况下只是要发送的字符串。 我的应用程序可以吸收客户端发回的任何垃圾。
I have an application where I accept a socket connection from a telnet client and put up a simple, keyboard driven character GUI.
The telnet client, at least on Linux, defaults into line-at-a-time mode, so I always have to do ^]mode char
manually.
A skim of the relevant RFCs suggests that if my application simply sent the characters IAC DONT LINEMODE (\377\376\042)
as soon as the client connects, the client should be forced into character mode. However, it doesn't make any difference.
What's the simplest bit of code that would do the job? Ideally just a string to be sent. My application can absorb whatever junk the client sends back.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有趣的。 我更幸运地发送了
IAC WONT LINEMODE 似乎是多余的:我的 telnet 客户端似乎在没有它的情况下达到了正确的状态,但为了完整性我将其保留。
Interesting. I had more luck sending
The IAC WONT LINEMODE seems to be redundant: my telnet client seems to get to the right state without it, but I left it in for completeness.
为了它的价值,我自己解决了它。
让远程(至少是从 Linux 机器上的 Xterm 远程登录)进入正确的状态。
For what it's worth, solved it myself.
gets the remote (at least telnet from an Xterm on a Linux box) into the right state.
凯文的解决方案效果很好:
尽管评论略有错误。 它应该说“DO LINEMODE”,而不是“WONT LINEMODE”,即:(
来源:rfc854)
Kevin's solution works great:
Although the comment is slightly wrong. It should say "DO LINEMODE", not "WONT LINEMODE", ie:
(Source: rfc854)
LINEMODE 与旧的逐行模式不同。 如果没有协商任何内容,连接默认为“旧的逐行模式”。 您想要启用字符模式,服务器可以通过发送 IAC WILL GA IAC WILL ECHO 来实现。 LINEMODE 是另一个选项,它将字符模式与本地回显相结合,并且还指定您可以协商 LINEMODE 的子选项。
LINEMODE is not the same as old line-by-line mode. If nothing is negotiated, the connection defaults to "old line-by-line mode". You want to enable character mode, which the server can do by sending
IAC WILL GA IAC WILL ECHO
. LINEMODE is another option, which kind of combines character mode with local echo and also specifies, that you are able to negotiate the suboptions of the LINEMODE.