'Writes data from socket and switch state.'

@socket_exception
def write(self):

    assert (self.status == SEND_ANSWER)
    sent = self.socket.send(self.message)
    if (sent == len(self.message)):
        self.status = WAIT_LEN
        self.message = ''
        self.len = 0
    else:
        self.message = self.message[sent:]
