Send an OpenFlow message and wait for reply messages.

    :param app: Client RyuApp instance
    :param msg: An OpenFlow controller-to-switch message to send
    :param reply_cls: OpenFlow message class for expected replies.
        None means no replies are expected.  The default is None.
    :param reply_multi: True if multipart replies are expected.
        The default is False.

    If no replies, returns None.
    If reply_multi=False, returns OpenFlow switch-to-controller message.
    If reply_multi=True, returns a list of OpenFlow switch-to-controller
    messages.

    Raise an exception on error.

    Example::

        # ...(snip)...
        import ryu.app.ofctl.api as ofctl_api


        class MyApp(app_manager.RyuApp):

            def _my_handler(self, ev):
                # ...(snip)...
                msg = parser.OFPPortDescStatsRequest(datapath=datapath)
                result = ofctl_api.send_msg(
                    self, msg,
                    reply_cls=parser.OFPPortDescStatsReply,
                    reply_multi=True)

def send_msg(app, msg, reply_cls=None, reply_multi=False):
    """
    Send an OpenFlow message and wait for reply messages.

    :param app: Client RyuApp instance
    :param msg: An OpenFlow controller-to-switch message to send
    :param reply_cls: OpenFlow message class for expected replies.
        None means no replies are expected.  The default is None.
    :param reply_multi: True if multipart replies are expected.
        The default is False.

    If no replies, returns None.
    If reply_multi=False, returns OpenFlow switch-to-controller message.
    If reply_multi=True, returns a list of OpenFlow switch-to-controller
    messages.

    Raise an exception on error.

    Example::

        # ...(snip)...
        import ryu.app.ofctl.api as ofctl_api


        class MyApp(app_manager.RyuApp):

            def _my_handler(self, ev):
                # ...(snip)...
                msg = parser.OFPPortDescStatsRequest(datapath=datapath)
                result = ofctl_api.send_msg(
                    self, msg,
                    reply_cls=parser.OFPPortDescStatsReply,
                    reply_multi=True)
    """
    return app.send_request(event.SendMsgRequest(msg=msg,
                                                 reply_cls=reply_cls,
                                                 reply_multi=reply_multi))()