def options_handler(self, sock, cmd, opt):
if cmd == NOP:<EOL><INDENT>self.sendcommand(NOP)<EOL><DEDENT>elif cmd == WILL or cmd == WONT:<EOL><INDENT>if self.WILLACK.has_key(opt):<EOL><INDENT>self.sendcommand(self.WILLACK[opt], opt)<EOL><DEDENT>else:<EOL><INDENT>self.sendcommand(DONT, opt)<EOL><DEDENT>if cmd == WILL and opt == TTYPE:<EOL><INDENT>self.writecooked(IAC + SB + TTYPE + SEND + IAC + SE)<EOL><DEDENT><DEDENT>elif cmd == DO or cmd == DONT:<EOL><INDENT>if self.DOACK.has_key(opt):<EOL><INDENT>self.sendcommand(self.DOACK[opt], opt)<EOL><DEDENT>else:<EOL><INDENT>self.sendcommand(WONT, opt)<EOL><DEDENT>if opt == ECHO:<EOL><INDENT>self.DOECHO = (cmd == DO)<EOL><DEDENT><DEDENT>elif cmd == SE:<EOL><INDENT>subreq = self.read_sb_data()<EOL>if subreq[<NUM_LIT:0>] == TTYPE and subreq[<NUM_LIT:1>] == IS:<EOL><INDENT>try:<EOL><INDENT>self.setterm(subreq[<NUM_LIT:2>:])<EOL><DEDENT>except:<EOL><INDENT>log.debug("<STR_LIT>")<EOL><DEDENT><DEDENT>elif subreq[<NUM_LIT:0>] == NAWS:<EOL><INDENT>self.setnaws(subreq[<NUM_LIT:1>:])<EOL><DEDENT><DEDENT>elif cmd == SB:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>log.debug("<STR_LIT>" % (cmdtxt, opttxt, ))<EOL><DEDENT>
Negotiate options