c#.net中的Telnet服务器 [英] Telnet Server in c#.net

查看:211
本文介绍了c#.net中的Telnet服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我创建了一个工作正常的telnet服务器。

现在我还想要一个Clear Screen的功能DOS提示符中的cls。



我已经尝试了谷歌和代码项目但都找不到任何东西。



有人可以告诉我,如何实现它?



问候

AR

Hi,

I have created a telnet server which is working fine.
now i want one more feature of Clear Screen like "cls" in DOS Prompt.

I have tried google and codeproject both but didn't find anything.

can somebody please tell, how to implement it?

Regards
AR

推荐答案

有一种简单的方法。当服务器获得'cls'(或任何你称之为命令的命令)时,然后发送300个空白行。 300足以应对大多数缓冲。



更复杂的解决方案要求您允许用户告诉您的服务器他们拥有什么样的终端类型。然后根据您发送适当的值,客户端映射到一个清晰的屏幕。这曾经工作,但它不太适用于Windows客户端(你仍然会做300空行)。这种方法存在问题,因为它经常看起来即使它声称它是一种终端,但它的行为并不像预期的那样。
There is one easy way. When the server gets a 'cls' (or whatever you call the command) then send 300 blank lines back. 300 is enough to deal with most buffering.

More complex solution require you to allow the user to tell your server what kind of 'terminal' type they have. Then based on that you send appropriate values back which the client maps to a clear screen. This used to work but it is unlikely to work for a windows client (you would still do the 300 blank lines). There are problems with this approach as it often seems that even though it claims it is one type of 'terminal' it doesn't behave as expected.


telnet只能返回文本。这就是服务器可以做的全部。



客户端可以随意使用该文本执行所需操作。客户只有两种选择

- 空行。

- 客户端接受特殊的文本序列,使其对显示采取行动。 />


Telnet客户端(不是服务器)通常允许选择模拟一个或多个终端类型。标准的Windows telnet允许选择以下选项之一。



vt100,vt52,ansi和vtnt仅



终端仿真有点不确定但屏幕很清晰很常见,以下链接可能适合定义VT100 / 52可能做的事情。





http://ascii-table.com/ansi-escape- sequences-vt-100.php [ ^ ]



现在,如果以下情况属实,那么您可以在服务器中进行终端仿真。

1. telnet客户端必须支持终端仿真

2.必须打开终端仿真。

3.必须将终端仿真设置为服务器支持的内容。

4.终端模拟实际上必须按照它声称做的事情。



如果所有这些如果是,那么您可以将服务器设置为模拟一个或多个终端。但是,您必须具有不模拟任何终端的模式,并且您必须具有明确启用它的方式(命令)。可能有一个'标准',telnet客户端会自动向服务器发送一些信息,以确定客户期望的终端,但我不打算重新研究它。



I会警告你,上面的问题是你会得到抱怨它不起作用的用户。而确定为什么它不起作用可能非常困难。因此,如果您要向您的用户保证它将起作用,那么它可能会起作用,您将会增加支持成本。
telnet can only return text. So that is all that the server can do.

The client is free to do what it wants with that text. There are only two options for the client
- Blank lines.
- The client accepts special sequences of text which cause it to take action in regards to the display.

Telnet clients (not servers) often allow for an option to emulate one or more 'terminal' types. The standard windows telnet allows for the OPTION of choosing one of the following.

vt100, vt52, ansi and vtnt only

Terminal emulation is a bit iffy but clear screen is pretty common and the following link might be suitable for defining what a VT100/52 might do.


http://ascii-table.com/ansi-escape-sequences-vt-100.php[^]

Now if and ONLY if the following is true then you could allow terminal emulation in your server.
1. The telnet client must support terminal emulation
2. Terminal emulation must be turned on.
3. Terminal emulation must be set to what the server supports.
4. The terminal emulation must actually do what it claims.

If all of that is true then you could set up your server to emulate one or more terminals. However you must have a mode that doesn't emulate any terminal and you must have a way (command) that explicitly turns it on). There might be a 'standard' in which telnet clients send some info to the server automatically identifying which terminal the client expects but I am not going to reasearch that.

I will warn you that the problem with the above is that you will get users that complain that it "doesn't work". And determinig why it doesn't work can be very difficult. So if you are going to guarantee to your users that it will work versus that it might work you are going to have increased support costs.


所以你想要它在客户端



这与服务器有什么关系?
So you want it in the "client".

What does that have to do with the "server"?


这篇关于c#.net中的Telnet服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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