'Formats and sends a message to the control socket. For more information see
the :func:`~stem.socket.send_message` function.
:param str message: message to be formatted and sent to the socket
:param bool raw: leaves the message formatting untouched, passing it to the socket as-is
:raises:
* :class:`stem.SocketError` if a problem arises in using the socket
* :class:`stem.SocketClosed` if the socket is known to be shut down'

def send(self, message, raw=False):

    with self._send_lock:
        try:
            if (not self.is_alive()):
                raise stem.SocketClosed()
            send_message(self._socket_file, message, raw)
        except stem.SocketClosed as exc:
            if self.is_alive():
                self.close()
            raise exc
