强制 telnet 客户端进入字符模式

发布于 2024-07-08 17:44:29 字数 332 浏览 10 评论 0原文

我有一个应用程序,我接受来自 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

爱给你人给你 2024-07-15 17:44:29

有趣的。 我更幸运地发送了

IAC WILL ECHO IAC WILL SUPPRESS_GO_AHEAD IAC WONT LINEMODE
255  251    1 255  251                 3 255  252       34

IAC WONT LINEMODE 似乎是多余的:我的 telnet 客户端似乎在没有它的情况下达到了正确的状态,但为了完整性我将其保留。

Interesting. I had more luck sending

IAC WILL ECHO IAC WILL SUPPRESS_GO_AHEAD IAC WONT LINEMODE
255  251    1 255  251                 3 255  252       34

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.

难理解 2024-07-15 17:44:29

为了它的价值,我自己解决了它。

// IAC WONT LINEMODE IAC WILL ECHO

write(s,"\377\375\042\377\373\001",6);

让远程(至少是从 Linux 机器上的 Xterm 远程登录)进入正确的状态。

For what it's worth, solved it myself.

// IAC WONT LINEMODE IAC WILL ECHO

write(s,"\377\375\042\377\373\001",6);

gets the remote (at least telnet from an Xterm on a Linux box) into the right state.

朮生 2024-07-15 17:44:29

凯文的解决方案效果很好:

write(s,"\377\375\042\377\373\001",6);

尽管评论略有错误。 它应该说“DO LINEMODE”,而不是“WONT LINEMODE”,即:(

// IAC DO LINEMODE IAC WILL ECHO

来源:rfc854)

Kevin's solution works great:

write(s,"\377\375\042\377\373\001",6);

Although the comment is slightly wrong. It should say "DO LINEMODE", not "WONT LINEMODE", ie:

// IAC DO LINEMODE IAC WILL ECHO

(Source: rfc854)

等风也等你 2024-07-15 17:44:29

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文