Telnet C中的单个数据字符 [英] Telnet single data characters in C

查看:106
本文介绍了Telnet C中的单个数据字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用C编写一个简单的telnet程序.当我检查cmd telnet时,我意识到它发送单个字符,一个字符一个字符.我的第一个问题是为什么?第二个问题是我必须在C程序中做同样的事情吗?而且,如何在C中使用输入而不按ENTER键?

Hi, I''ve been trying to write a simple telnet program using C. When I examined the cmd telnet I realised that it sends single characters, meaning char by char. My first question is why is that? Second question is do I have to do the same in my C program? And also, how to I use input in C without pressing ENTER?

推荐答案

Telnet可以用于连接到远程Shell.对于shell,您希望每个键入的字符都在屏幕上回显.要通过远程连接实现此目的,必须将每个单个字符发送到服务器,服务器将其回显到客户端以在客户端的屏幕上显示.

如果要编写符合标准的Telnet客户端,则必须执行相同的操作.

要从键盘读取单个字符,请使用getch()函数(对于Visual Studio编译器为_getch()).
Telnet can be used to connect to a remote shell. With shells, you expect that each typed character is echoed on the screen. To achieve this with remote connections, each single character must be send to the server which will echo it back to the client for display on the client''s screen.

If you want to write a standard compliant Telnet client, you have to do the same.

To read single characters from the keyboard, use the getch() function (_getch() with Visual Studio compilers).


仅回答第三个问题
关于不按Enter捕获字符的情况,我相信抓取"或获取"可以做到这一点,看看吧.

http://msdn.microsoft.com/en-us/library/kswce429 (v = vs.80).aspx [ http://www.codeproject.com/search.aspx? q = telnet& sbo = kw& x = 0& y = 0 [
Answer to the third question only
Regarding the capture of chars without pressing enter, I believe "getch" or "getche" do that, take a look at it.

http://msdn.microsoft.com/en-us/library/kswce429(v=vs.80).aspx[^]

Regarding the other questions...
http://www.codeproject.com/search.aspx?q=telnet&sbo=kw&x=0&y=0[^]
I''ve found several articles about telnet apps here in CP... probably some of them will give you pointers on how to proceed.

Good luck.


这篇关于Telnet C中的单个数据字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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