# File lib/network/protocol/telnetfilter.rb, line 308
  def init_subneg
    return if @init_tries > 20
    @init_tries += 1
    @wopts.each_key do |opt|
      next if !@sneg_opts.include?(opt)
      log.debug("(#{@pstack.conn.object_id}) Subnegotiation attempt for option #{opt}.")
      case opt
      when TTYPE
        who = :him
      else
        who = :us
      end
      if desired?(opt) == enabled?(opt, who)
        case opt
        when TTYPE
          @pstack.conn.sendmsg(IAC.chr + SB.chr + TTYPE.chr + 1.chr + IAC.chr + SE.chr)
        when ZMP
          log.info("(#{@pstack.conn.object_id}) ZMP successfully negotiated." )
          @pstack.conn.sendmsg("#{IAC.chr}#{SB.chr}#{ZMP.chr}" +
            "zmp.check#{NUL.chr}color.#{NUL.chr}" +
            "#{IAC.chr}#{SE.chr}")
          @pstack.conn.sendmsg("#{IAC.chr}#{SB.chr}#{ZMP.chr}" +
            "zmp.ident#{NUL.chr}TeensyMUD#{NUL.chr}#{Version}#{NUL.chr}A sexy mud server#{NUL.chr}" +
            "#{IAC.chr}#{SE.chr}")
          @pstack.conn.sendmsg("#{IAC.chr}#{SB.chr}#{ZMP.chr}" +
            "zmp.ping#{NUL.chr}" +
            "#{IAC.chr}#{SE.chr}")
          @pstack.conn.sendmsg("#{IAC.chr}#{SB.chr}#{ZMP.chr}" +
            "zmp.input#{NUL.chr}\n     I see you support...\n     ZMP protocol\n#{NUL.chr}" +
            "#{IAC.chr}#{SE.chr}")
        end
        @sneg_opts.delete(opt)
      end
    end

    if @init_tries > 20
      log.debug("(#{@pstack.conn.object_id}) Telnet init_subneg option - Timed out after #{@init_tries} tries.")
      @sneg_opts = []
      @pstack.conn.set_initdone
      if !@pstack.terminal or @pstack.terminal.empty?
        @pstack.terminal = "dumb"
      end
    end
  end