def send(self, cmd, *payload):
<EOL>if not self._sock:<EOL><INDENT>raise ConnectionClosed("<STR_LIT>")<EOL><DEDENT>msg = json.dumps(dict(cmd=cmd, payload=payload)) + '<STR_LIT:\n>'<EOL>try:<EOL><INDENT>self._sock.sendall(msg)<EOL><DEDENT>except socket.error:<EOL><INDENT>e_type, e_value, e_tb = sys.exc_info()<EOL>self.close()<EOL>raise e_type(e_value).with_traceback(e_tb)<EOL><DEDENT>
Send a command message to the other end.

:param cmd: The command to send to the other end.
:param payload: The command payload.  Note that all elements
                of the payload must be serializable to JSON.