'Write a raw msg to the socket'

def _write(self, msg, timeout):

    sent = 0
    msg_length = len(msg)
    with self._socket_error_handling():
        while (sent < msg_length):
            s = self.handler.select([], [self._socket], [], timeout)[1]
            if (not s):
                raise self.handler.timeout_exception('socket    time-out')
            msg_slice = buffer(msg, sent)
            bytes_sent = self._socket.send(msg_slice)
            if (not bytes_sent):
                raise ConnectionDropped('socket    connection    broken')
            sent += bytes_sent
