'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.'

def write(self, buffer):

    if (IAC in buffer):
        buffer = buffer.replace(IAC, (IAC + IAC))
    self.msg('send    %r', buffer)
    self.sock.sendall(buffer)
