<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _exec_appcommand_post(self, command, param):
 """ Prepare xml command for AVR """

        xml = """<?xml version="1.0" encoding="UTF-8"?>
        <harman>
            <avr>
                <common>
                    <control>
                        <name>""" + command + """</name>
                        <zone>""" + self._zone + """</zone>
                        <para>""" + param + """</para>
                    </control>
                </common>
            </avr>
        </harman>"""
        command = """POST AVR HTTP/1.1\r\nHost: :""" + str(self._port) \
                  + """\r\nUser-Agent: Harman Kardon AVR Remote """\
                  + """Controller /2.0""" \
                  + """\r\nContent-Length: """ + str(xml.__len__()) \
                  + """\r\n\r\n""" + xml

        if self._socket is None:
            self._socket = self._get_new_socket()
        if self._socket is None:
            _LOGGER.warning("Cannot connect to AVR")
            return
        try:
            resp = self._socket.sendto(command.encode(),
                                       (self._host, self._port))
            if resp == 0:
                self._socket.close()
                self._socket = None
                _LOGGER.warning("Send fail, disconnecting from AVR")
        except (BrokenPipeError, ConnectionError) as connect_error:
            _LOGGER.warning("Connection error, retrying. %s", connect_error)
            self._socket = None
            self._socket = self._get_new_socket()
            if self._socket is not None:
                # retrying after broken pipe error
                self._socket.sendto(command.encode(), (self._host, self._port))