code: def write(self, buffer):
          
          if type(buffer) == type(0):
              buffer = chr(buffer)
          elif not isinstance(buffer, bytes):
              buffer = buffer.encode(self.encoding)
          if IAC in buffer:
              buffer = buffer.replace(IAC, IAC+IAC)
          self.msg("send %s", repr(buffer))
          self.sock.send(buffer)
docs: Write a string to the socket, doubling any IAC characters.
  
          Can block if the connection is blocked.  May raise
          socket.error if the connection is closed.