C# telnet client如何向server端发送"Ctrl+P"组合键?

vivianfdlpw 2006-03-18 11:05:15
试了很多方法都不行,郁闷死了

telnet server端是通过下面的方式判断的(C写的):

#define Ctrl(c) ( c & 037 )
FILE *fp
int ch
ch=getc(fp)
if(ch==Ctrl('P'))
........

不知道客户端用C#怎么把Ctrl+P发送过去
...全文
193 点赞 收藏 10
写回复
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
vivianfdlpw 2006-03-20
ok now,many thanks:)
回复
saucer 2006-03-20
sorry, Charles Petzold is correct, 037 is 11111, so P & 037 gives you 10000, which is 16, so you can just send

char c = (char)16;

send c or the number 16
回复
vivianfdlpw 2006-03-20
(xxh) 表示 ASCII 字符 xx,指的是发送字符xx?
回复
vivianfdlpw 2006-03-20
多谢,我待会试试:)
回复
saucer 2006-03-20
P = 1010000 <-- the lower bits give you 10H, actually
回复
saucer 2006-03-20
again

just realize that,

A = 1000001
...
P = 1010000 <-- the lower bits give you 16H, actually
...
Z = 1011010

so the idea is similar, although 037 looks suspicious, because 'P' & 037 is 0
回复
saucer 2006-03-20
sorry, 11H
回复
saucer 2006-03-20
according to your server code, the answer seems to send

(YourKey & 037)

but according to Charles Petzold, the control key in combination with a letter key generates ASCII control codes from 01H (Ctrl-A) to 1AH (Ctrl-Z), so for your purpose, try 12H ?
回复
甜味牛牛 2006-03-19
http://www.programsalon.com/detail136953.html

Telnet的客户端c#源码

里面应该由你想要的东西
回复
vivianfdlpw 2006-03-19
源码我找了很多,都没我想要得的
回复
发动态
发帖子
C#
创建于2007-09-28

10.4w+

社区成员

.NET技术 C#
申请成为版主
社区公告

全世界最好的语言,没有之一.