telnet协议的一些理解

   telnet协议的echo选项,也就是回显选项,在telnet中有很重要的作用。  

引用
T he NVT has a printer and a keyboard which are nominally
   interconnected so that "echoes" need never traverse the network; that
   is to say, the NVT nominally operates in a mode where characters
   typed on the keyboard are (by some means) locally turned around and
   printed on the printer.  In highly interactive situations it is
   appropriate for the remote process (command language interpreter,
   etc.) to which the characters are being sent to control the way they
   are echoed on the printer.  In order to support such interactive
   situations, it is necessary that there be a TELNET option to allow
   the parties at the two ends of the TELNET connection to agree that
   characters typed on an NVT keyboard are to be echoed by the party at
   the other end of the TELNET connection.
        ——摘自rfc 857


   nvt(网络虚拟终端)是带有键盘和打印机的字符设备。在一些交互性比较高的情况下,远程进程需要控制发送给它(远程进程)的字符在发送端的显示方法。比如说用telnet登录bbs时,用户要输入用户名,每输入一个字符,显示器上面都会有显示输入的字符;但是输入密码时,显示器上面就看不到输入的字符,是空白或者※号等。为什么有时看到自己输入的字符有时却看不到。这就是用echo选项来控制的。

   echo选项有几条命令:
  
引用
IAC WILL ECHO

      The sender of this command REQUESTS to begin, or confirms that it
      will now begin, echoing data characters it receives over the
      TELNET connection back to the sender of the data characters.

   IAC WON'T ECHO

      The sender of this command DEMANDS to stop, or refuses to start,
      echoing the data characters it receives over the TELNET connection
      back to the sender of the data characters.

   IAC DO ECHO

      The sender of this command REQUESTS that the receiver of this
      command begin echoing, or confirms that the receiver of this
      command is expected to echo, data characters it receives over the
      TELNET connection back to the sender.

   IAC DON'T ECHO

      The sender of this command DEMANDS the receiver of this command
      stop, or not start, echoing data characters it receives over the
      TELNET connection.
              ——摘自rfc 857


     以上几条命令如果翻译成中文反而比较复杂,这段话的关键点在于:echo选项有效(默认是无效)后,收到字符时,将返回给发送字符端一些字符,可以是收到的字符,也可以是其他字符。 还可以推出一点,echo选项的开启与否跟本地回显的状态无关(windows xp telnet 可以设置本地回显)。

   根据以上几条命令 就可以推出刚才输入用户名和密码时echo选项的使用情况:

             

引用
输入用户名时:服务器端回显字符(send will echo)(将接受到的字符直接发送回去)
              输入密码时:服务器端回显字符(send will echo)但不发送任何字符回去或者不回显字符(后者未测试)




  如果要自己编写程序与telnet客户端或服务端交互,有一个容易出错的地方:设置自己程序端可以回显时要手动写出回显的语句(只要send对方一个消息即可)!!没有人替你弄好回显!
如果要设置对方回显,就要接收对方的回显信息。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值