[英]How does Telnet server communicate to the client?
I want to write a C# application where it connects to a telnet server and communicates to the server. 我想编写一个C#应用程序,它连接到telnet服务器并与服务器通信。 I was wondering how a telnet server sends information to the client. 我想知道telnet服务器如何向客户端发送信息。 I have looked (skimmed) over the Telnet RFC and looked at the incoming packets coming in from the server and still a bit confused. 我查看(浏览过) Telnet RFC并查看从服务器进来的传入数据包,但仍然有点困惑。 Can somebody give me an example how the server moves the cursor around in the telnet client and how it can change colors of characters? 有人能给我一个例子,说明服务器如何在telnet客户端中移动光标以及它如何改变字符的颜色? (An example would be most appreciated) (最值得赞赏的一个例子)
Update I 更新我
Here's some additional VT100 resources: 这是一些额外的VT100资源:
Update II 更新II
With much research and time, here what I found out: Telnet Programming with C# 经过大量的研究和时间,我发现了这一点: 使用C#进行Telnet编程
Moving the cursor and changing the color isn't done by the telnet protocol. 移动光标并更改颜色不是由telnet协议完成的。
Your telnet client is emulating a terminal , most probably a VT-100 variant. 您的telnet客户端正在模拟终端 ,很可能是VT-100变体。 To move the cursor and change the color, the server sends escape sequences especific to the type of terminal being emulated (which one is sent in the telnet protocol negotiation). 要移动光标并更改颜色,服务器会发送转义序列,特别是要模拟的终端类型(哪一个是在telnet协议协商中发送的)。
If you don't want these escape sequences, telling the server on the telnet protocol negotiation you are a "dumb" terminal should be enough. 如果你不想要这些转义序列,告诉服务器telnet协议协商你是一个“哑”终端应该就够了。 If you want them (or if the server assumes everyone has a VT-100 and always sends them) you will have to implement a VT-100 terminal emulator (or at least enough of it to discard what you don't want). 如果你想要它们(或者如果服务器假设每个人都有VT-100并且总是发送它们),你将不得不实现VT-100终端模拟器(或者至少足以丢弃你不想要的东西)。
A simple Google search reveals many open source Telnet (and other network protocol) clients written in C#. 一个简单的谷歌搜索揭示了许多用C#编写的开源Telnet(和其他网络协议)客户端。 You could just download the source code to one and see how they implement connection negotiation and commands. 您可以将源代码下载到一个,看看它们如何实现连接协商和命令。
With respect to handling the cursor and text colours, etc., now you are talking about terminal emulation. 关于处理光标和文本颜色等,现在你谈论终端仿真。 For that you will need a library. 为此你需要一个图书馆。 This looks like a good place to start. 这看起来是个好地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.