<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">

<erlref>
  <header>
    <copyright>
      <year>2020</year><year>2021</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
 
          http://www.apache.org/licenses/LICENSE-2.0

      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
    
    </legalnotice>

    <title>erpc</title>
    <prepared>Rickard Green</prepared>
    <docno>1</docno>
    <date>2020-02-20</date>
    <rev>A</rev>
  </header>
  <module since="OTP 23.0">erpc</module>
  <modulesummary>Enhanced Remote Procedure Call</modulesummary>
  <description>
    <p>
      This module provide services similar to Remote Procedure Calls.
      A remote procedure call is a method to call a function on a remote
      node and collect the answer. It is used for collecting information
      on a remote node, or for running a function with some specific side
      effects on the remote node.
    </p>
    <p>
      This is an enhanced subset of the operations provided by the
      <seeerl marker="rpc"><c>rpc</c></seeerl> module. Enhanced in the
      sense that it makes it possible to distinguish between returned
      value, raised exceptions, and other errors. <c>erpc</c> also has
      better performance and scalability than the original <c>rpc</c>
      implementation. However, current <c>rpc</c> module will utilize
      <c>erpc</c> in order to also provide these properties when
      possible.
    </p>
    <p>
      In order for an <c>erpc</c> operation to succeed, the remote
      node also needs to support <c>erpc</c>. Typically only ordinary
      Erlang nodes as of OTP 23 have <c>erpc</c> support.
    </p>
    <p>
      Note that it is up to the user to ensure that correct code to
      execute via <c>erpc</c> is available on the involved nodes.
    </p>
  </description>

  <datatypes>
    <datatype>
      <name name="request_id"/>
      <desc>
        <p>
	  An opaque type of call request identifiers. For more
	  information see
          <seemfa marker="#send_request/4"><c>send_request/4</c></seemfa>.
	</p>
      </desc>
    </datatype>
  </datatypes>

  <funcs>

    <func>
      <name name="call" arity="2" since="OTP 23.0"/>
      <name name="call" arity="3" since="OTP 23.0"/>
      <fsummary>Evaluate a function call on a node.</fsummary>
      <desc>
	<p>
	  The same as calling
	  <seemfa marker="#call/5"><c>erpc:call(<anno>Node</anno>,erlang,apply,[<anno>Fun</anno>,[]],<anno>Timeout</anno>)</c></seemfa>.
	  May raise all the same exceptions as <c>erpc:call/5</c>
	  plus an <c>{erpc, badarg}</c> <c>error</c>
	  exception if <c><anno>Fun</anno></c> is not a fun of
	  zero arity.
	</p>
	<p>
	  The call <c>erpc:call(<anno>Node</anno>,<anno>Fun</anno>)</c>
	  is the same as the call
	  <c>erpc:call(<anno>Node</anno>,<anno>Fun</anno>,infinity)</c>.
	</p>
      </desc>
    </func>

    <func>
      <name name="call" arity="4" since="OTP 23.0"/>
      <name name="call" arity="5" since="OTP 23.0"/>
      <fsummary>Evaluate a function call on a node.</fsummary>
      <desc>
        <p>
	  Evaluates <c>apply(<anno>Module</anno>, <anno>Function</anno>,
          <anno>Args</anno>)</c> on node <c><anno>Node</anno></c> and returns
          the corresponding value <c><anno>Result</anno></c>.
	  <c><anno>Timeout</anno></c> is an integer representing
	  the timeout in milliseconds or the atom <c>infinity</c>
	  which prevents the operation from ever timing out.
	</p>
	<p>The call <c>erpc:call(<anno>Node</anno>, <anno>Module</anno>,
	<anno>Function</anno>, <anno>Args</anno>)</c> is equivalent
	to the call <c>erpc:call(<anno>Node</anno>, <anno>Module</anno>,
	<anno>Function</anno>, <anno>Args</anno>, infinity)</c></p>
	<p>
	  The <c>call()</c> function only returns if the applied
	  function successfully returned without raising any uncaught
	  exceptions, the operation did not time out, and no failures
	  occurred. In all other cases an exception is raised. The
	  following exceptions, listed by exception class, can
	  currently be raised by <c>erpc:call()</c>:
	</p>
	<taglist>
	  <tag><c>throw</c></tag>
	  <item><p>
	    The applied function called <c>throw(Value)</c>
	    and did not catch this exception. The exception
	    reason <c>Value</c> equals the argument passed to
	    <c>throw/1</c>.
	  </p></item>
	  
	  <tag><c>exit</c></tag>
	  <item><p>
	    Exception reason:
	  </p>
	  <taglist>
	    <tag><c>{exception, ExitReason}</c></tag>
	    <item><p>
	      The applied function called <c>exit(ExitReason)</c>
	      and did not catch this exception. The exit
	      reason <c>ExitReason</c> equals the argument passed
	      to <c>exit/1</c>.
	    </p></item>
	    <tag><c>{signal, ExitReason}</c></tag>
	    <item><p>
	      The process that applied the function received an
	      exit signal and terminated due to this signal. The
	      process terminated with exit reason <c>ExitReason</c>.
	    </p></item>
	  </taglist>
	  </item>
	  
	  <tag><c>error</c></tag>
	  <item><p>
	    Exception reason:
	  </p>
	  <taglist>
	    
	    <tag><c>{exception, ErrorReason, StackTrace}</c></tag>
	    <item><p>
	      A runtime error occurred which raised and error
	      exception while applying the function,
	      and the applied function did not catch the
	      exception. The error reason <c>ErrorReason</c>
	      indicates the type of error that occurred.
	      <c>StackTrace</c> is formatted as when caught in a
	      <c>try/catch</c> construct. The <c>StackTrace</c>
	      is limited to the applied function and functions
	      called by it.
	    </p></item>
	    
	    <tag><c>{erpc, ERpcErrorReason}</c></tag>
	    <item><p>
	      The <c>erpc</c> operation failed. The following
	      <c>ERpcErrorReason</c>s are the most common ones:
	    </p>
	    
	    <taglist>
	      <tag><c>badarg</c></tag>
	      <item>
		<p>If any one of these are true:</p>
		<list>
		  <item><p><c><anno>Node</anno></c> is not an atom.</p></item>
		  <item><p><c><anno>Module</anno></c> is not an atom.</p></item>
		  <item><p><c><anno>Function</anno></c> is not an atom.</p></item>
		  <item><p><c><anno>Args</anno></c> is not a list.
		  Note that the list is not verified to be
		  a proper list at the client side.</p></item>
		  <item><p><c><anno>Timeout</anno></c> is not the
		  atom <c>infinity</c> or an integer in valid
		  range.</p></item>
		</list>
	      </item>
	      
	      <tag><c>noconnection</c></tag>
	      <item><p>
		The connection to <c>Node</c> was lost or could
		not be established. The function may or may not
		be applied.
	      </p></item>
	      
	      <tag><c>system_limit</c></tag>
	      <item><p>
		The <c>erpc</c> operation failed due to some system
		limit being reached. This typically due to failure
		to create a process on the remote node <c>Node</c>,
		but can be other things as well.
	      </p></item>
	      
	      <tag><c>timeout</c></tag>
	      <item><p>
		The <c>erpc</c> operation timed out. The function may
		or may not be applied.
	      </p></item>
	      
	      <tag><c>notsup</c></tag>
	      <item><p>
		The remote node <c>Node</c> does not support
		this <c>erpc</c> operation.
	      </p>
	      </item>
	      
	    </taglist>
	    </item>
	    
	  </taglist>
	  </item>
	</taglist>

	<p>
	  If the <c>erpc</c> operation fails, but it is unknown if
	  the function is/will be applied (that is, a timeout or
	  a connection loss), the caller will not receive any
	  further information about the result if/when the applied
	  function completes. If the applied function explicitly
	  communicates with the calling process, such communication
	  may, of course, reach the calling process.
        </p>

	<note>
	  <p>
	    You cannot make <em>any</em> assumptions about the
	    process that will perform the <c>apply()</c>. It may
	    be the calling process itself, a server, or a freshly
	    spawned process.
	  </p>
	</note>
      </desc>
    </func>

    <func>
      <name name="cast" arity="2" since="OTP 23.0"/>
      <fsummary>Evaluate a function call on a node.</fsummary>
      <desc>
	<p>
	  The same as calling
	  <seemfa marker="#cast/4"><c>erpc:cast(<anno>Node</anno>,erlang,apply,[<anno>Fun</anno>,[]])</c></seemfa>.
	</p>
	<p><c>erpc:cast/2</c> fails with an <c>{erpc, badarg}</c>
	<c>error</c> exception if:</p>
	<list>
	  <item><p><c><anno>Node</anno></c> is not an atom.</p></item>
	  <item><p><c><anno>Fun</anno></c> is not a a fun of zero arity.</p></item>
	</list>
      </desc>
    </func>

    <func>
      <name name="cast" arity="4" since="OTP 23.0"/>
      <fsummary>Evaluate a function call on a node ignoring the result.</fsummary>
      <desc>
        <p>
	  Evaluates <c>apply(<anno>Module</anno>, <anno>Function</anno>,
          <anno>Args</anno>)</c> on node
          <c><anno>Node</anno></c>. No response is delivered to the
	  calling process. <c>erpc:cast()</c> returns immediately
	  after the cast request has been sent. Any failures beside
	  bad arguments are silently ignored.
	</p>
	<p><c>erpc:cast/4</c> fails with an <c>{erpc, badarg}</c>
	<c>error</c> exception if:</p>
	<list>
	  <item><p><c><anno>Node</anno></c> is not an atom.</p></item>
	  <item><p><c><anno>Module</anno></c> is not an atom.</p></item>
	  <item><p><c><anno>Function</anno></c> is not an atom.</p></item>
	  <item><p><c><anno>Args</anno></c> is not a list. Note that
	  the list is not verified to be a proper list at the client
	  side.</p></item>
	</list>
	<note>
	  <p>
	    You cannot make <em>any</em> assumptions about the
	    process that will perform the <c>apply()</c>. It may
	    be a server, or a freshly spawned process.
	  </p>
	</note>
      </desc>
    </func>
    
    <func>
      <name name="check_response" arity="2" since="OTP 23.0"/>
      <fsummary>Check if a message is a response corresponding to a
      previously sent call request.</fsummary>
      <desc>
	<p>
	  Check if a message is a response to a <c>call</c> request
	  previously made by the calling process using
	  <seemfa marker="#send_request/4"><c>erpc:send_request/4</c></seemfa>.
	  <c><anno>RequestId</anno></c> should be the value returned
	  from the previously made <c>erpc:send_request()</c> call,
	  and the corresponding response should not already have been
	  received and handled to completion by <c>erpc:check_response()</c>,
	  <seemfa marker="#receive_response/2"><c>erpc:receive_response()</c></seemfa>, or
	  <seemfa marker="#wait_response/2"><c>erpc:wait_response()</c></seemfa>.
	  <c><anno>Message</anno></c> is the message to check.
	</p>
	<p>
	  If <c><anno>Message</anno></c> does not correspond to the
	  response, the atom <c>no_response</c> is returned. If
	  <c><anno>Message</anno></c> corresponds to the response, the
	  <c>call</c> operation is completed and either the result is
	  returned as <c>{response, Result}</c> where <c>Result</c>
	  corresponds to the value returned from the applied function
	  or an exception is raised. The exceptions that can be raised
	  corresponds to the same exceptions as can be raised by
	  <seemfa marker="#call/4"><c>erpc:call/4</c></seemfa>.
	  That is, no <c>{erpc, timeout}</c> <c>error</c> exception
	  can be raised. <c>erpc:check_response()</c> will fail with
	  an <c>{erpc, badarg}</c> exception if/when an invalid
	  <c><anno>RequestId</anno></c> is detected.
	</p>
	<p>
	  If the <c>erpc</c> operation fails, but it is unknown if
	  the function is/will be applied (that is, a connection loss),
	  the caller will not receive any further information about the
	  result if/when the applied function completes. If the applied
	  function explicitly communicates with the calling process,
	  such communication may, of course, reach the calling process.
        </p>
      </desc>
    </func>

    <func>
      <name name="multicall" arity="2" since="OTP 23.0"/>
      <name name="multicall" arity="3" since="OTP 23.0"/>
      <fsummary>Evaluate a function call on a node.</fsummary>
      <desc>
	<p>
	  The same as calling
	  <seemfa marker="#multicall/5"><c>erpc:multicall(<anno>Nodes</anno>,erlang,apply,[<anno>Fun</anno>,[]],<anno>Timeout</anno>)</c></seemfa>.
	  May raise all the same exceptions as <c>erpc:multicall/5</c>
	  plus an <c>{erpc, badarg}</c> <c>error</c>
	  exception if <c><anno>Fun</anno></c> is not a fun of
	  zero arity.
	</p>
	<p>
	  The call <c>erpc:multicall(<anno>Nodes</anno>,<anno>Fun</anno>)</c>
	  is the same as the call
	  <c>erpc:multicall(<anno>Nodes</anno>,<anno>Fun</anno>, infinity)</c>.
	</p>
      </desc>
    </func>

    <func>
      <name name="multicall" arity="4" since="OTP 23.0"/>
      <name name="multicall" arity="5" since="OTP 23.0"/>
      <fsummary>Evaluate a function call on a number of nodes.</fsummary>
      <type name="caught_call_exception"/>
      <type name="stack_item"/>
      <desc>
	<p>
	  Performs multiple <c>call</c> operations in parallel
	  on multiple nodes. That is, evaluates
	  <c>apply(<anno>Module</anno>, <anno>Function</anno>,
          <anno>Args</anno>)</c> on the nodes
	  <c><anno>Nodes</anno></c> in parallel.
	  <c><anno>Timeout</anno></c> is an integer representing
	  the timeout in milliseconds or the atom <c>infinity</c>
	  which prevents the operation from ever timing out.
	  The result is returned as a list where
	  the result from each node is placed at the same position
	  as the node name is placed in <c><anno>Nodes</anno></c>.
	  Each item in the resulting list is formatted as either:
	</p>
	<taglist>
	  <tag><c>{ok, Result}</c></tag>
	  <item><p>
	    The <c>call</c> operation for this specific node
	    returned <c>Result</c>.
	  </p></item>
	  <tag><c>{Class, ExceptionReason}</c></tag>
	  <item><p>
	    The <c>call</c> operation for this specific node
	    raised an exception of class <c>Class</c> with
	    exception reason <c>ExceptionReason</c>. These
	    corresponds the the exceptions that
	    <seemfa marker="#call/5"><c>erpc:call/5</c></seemfa>
	    can raise.
	  </p></item>
	</taglist>
	<p><c>erpc:multicall/5</c> fails with an <c>{erpc, badarg}</c>
	<c>error</c> exception if:</p>
	<list>
	  <item><p><c><anno>Nodes</anno></c> is not a proper list of
	  atoms. Note that some requests may already have
	  been sent when the failure occurs. That is, the function
	  may or may not be applied on some nodes.</p></item>
	  <item><p><c><anno>Module</anno></c> is not an atom.</p></item>
	  <item><p><c><anno>Function</anno></c> is not an atom.</p></item>
	  <item><p><c><anno>Args</anno></c> is not a list. Note that the
	  list is not verified to be a proper list at the client side.</p></item>
	</list>
	<p>
	  The call <c>erpc:multicall(<anno>Nodes</anno>, <anno>Module</anno>,
	  <anno>Function</anno>, <anno>Args</anno>)</c> is equivalent
	  to the call <c>erpc:multicall(<anno>Nodes</anno>, <anno>Module</anno>,
	  <anno>Function</anno>, <anno>Args</anno>, infinity)</c>. These
	  calls are also equivalent to calling <c>my_multicall(Nodes, Module,
	  Function, Args)</c> if one disregard performance and failure
	  behavior:
	</p>
	<pre>
my_multicall(Nodes, Module, Function, Args) ->
  ReqIds = lists:map(fun (Node) ->
                       <seemfa marker="#send_request/4">erpc:send_request(Node, Module, Function, Args)</seemfa>
                     end,
                     Nodes),
  lists:map(fun (ReqId) ->
              try
                {ok, <seemfa marker="#receive_response/2">erpc:receive_response(ReqId, infinity)</seemfa>}
              catch
                Class:Reason ->
                  {Class, Reason}
              end
            end,
            ReqIds).
</pre>

        <p>
	  The <c><anno>Timeout</anno></c> value in milliseconds
	  sets an upper time limit for all <c>call</c> operations
	  to complete.
	</p>

	<p>
	  If an <c>erpc</c> operation fails, but it is unknown if
	  the function is/will be applied (that is, a timeout,
	  connection loss, or an improper <c><anno>Nodes</anno></c>
	  list), the caller will not receive any further information
	  about the result if/when the applied function completes.
	  If the applied function communicates
	  with the calling process, such communication may, of
	  course, reach the calling process.
	</p>

	<note>
	  <p>
	    You cannot make <em>any</em> assumptions about the
	    process that will perform the <c>apply()</c>. It may
	    be the calling process itself, a server, or a freshly
	    spawned process.
	  </p>
	</note>
      </desc>
      
    </func>

    <func>
      <name name="multicast" arity="2" since="OTP 23.0"/>
      <fsummary>Evaluate a function call on a set nodes.</fsummary>
      <desc>
	<p>
	  The same as calling
	  <seemfa marker="#multicast/4"><c>erpc:multicast(<anno>Nodes</anno>,erlang,apply,[<anno>Fun</anno>,[]])</c></seemfa>.
	</p>
	<p><c>erpc:multicast/2</c> fails with an <c>{erpc, badarg}</c>
	<c>error</c> exception if:</p>
	<list>
	  <item><p><c><anno>Nodes</anno></c> is not a proper list of atoms.</p></item>
	  <item><p><c><anno>Fun</anno></c> is not a a fun of zero arity.</p></item>
	</list>
      </desc>
    </func>

    <func>
      <name name="multicast" arity="4" since="OTP 23.0"/>
      <fsummary>Evaluate a function call on a set of nodes ignoring the result.</fsummary>
      <desc>
        <p>
	  Evaluates <c>apply(<anno>Module</anno>, <anno>Function</anno>,
          <anno>Args</anno>)</c> on the nodes
          <c><anno>Nodes</anno></c>. No response is delivered to the
	  calling process. <c>erpc:multicast()</c> returns immediately
	  after the cast requests have been sent. Any failures beside
	  bad arguments are silently ignored.
	</p>
	<p><c>erpc:multicast/4</c> fails with an <c>{erpc, badarg}</c>
	<c>error</c> exception if:</p>
	<list>
	  <item><p><c><anno>Nodes</anno></c> is not a proper list of
	  atoms. Note that some requests may already have
	  been sent when the failure occurs. That is, the function
	  may or may not be applied on some nodes.</p></item>
	  <item><p><c><anno>Module</anno></c> is not an atom.</p></item>
	  <item><p><c><anno>Function</anno></c> is not an atom.</p></item>
	  <item><p><c><anno>Args</anno></c> is not a list. Note that the
	  list is not verified to be a proper list at the client side.</p></item>
	</list>
	<note>
	  <p>
	    You cannot make <em>any</em> assumptions about the
	    process that will perform the <c>apply()</c>. It may
	    be a server, or a freshly spawned process.
	  </p>
	</note>
      </desc>
    </func>
    
    <func>
      <name name="receive_response" arity="1" since="OTP 23.0"/>
      <name name="receive_response" arity="2" since="OTP 23.0"/>
      <fsummary>Receive a call response corresponding to a
      previously sent call request.</fsummary>
      <desc>
	<p>
	  Receive a response to a <c>call</c> request previously
	  made by the calling process using
	  <seemfa marker="#send_request/4"><c>erpc:send_request/4</c></seemfa>.
	  <c><anno>RequestId</anno></c> should be the value returned from
	  the previously made <c>erpc:send_request()</c> call, and
	  the corresponding response should not already have been received
	  and handled to completion by
	  <seemfa marker="#check_response/2"><c>erpc:check_response()</c></seemfa>,
	  <c>erpc:receive_response()</c>, or
	  <seemfa marker="#wait_response/2"><c>erpc:wait_response()</c></seemfa>.
	  <c><anno>Timeout</anno></c> is an integer representing
	  the timeout in milliseconds or the atom <c>infinity</c>
	  which prevents the operation from ever timing out. The <c>call</c>
	  operation is completed once the <c>erpc:receive_response()</c> call
	  returns or raise an exception.
	</p>
	<p>
	  The call <c>erpc:receive_response(<anno>RequestId</anno>)</c> is
	  equivalent to the call
	  <c>erpc:receive_response(<anno>RequestId</anno>, infinity)</c>.
	</p>
	<p>
	  A call to the function
	  <c>my_call(Node, Module, Function, Args, Timeout)</c>
	  below is equivalent to the call
	  <seemfa marker="#call/5"><c>erpc:call(Node, Module, Function, Args,
	  Timeout)</c></seemfa> if one disregards performance. <c>erpc:call()</c>
	  can utilize a message queue optimization which removes the need to scan
	  the whole message queue which the combination
	  <c>erpc:send_request()/erpc:receive_response()</c> cannot.
	</p>
	<pre>
my_call(Node, Module, Function, Args, Timeout) ->
  RequestId = <seemfa marker="#send_request/4">erpc:send_request(Node, Module, Function, Args)</seemfa>,
  erpc:receive_response(RequestId, Timeout).
</pre>
	<p>
	  If the <c>erpc</c> operation fails, but it is unknown if
	  the function is/will be applied (that is, a timeout, or
	  a connection loss), the caller will not receive any
	  further information about the result if/when the applied
	  function completes. If the applied function explicitly
	  communicates with the calling process, such communication
	  may, of course, reach the calling process.
        </p>
	
	<p>
	  <c>erpc:receive_response()</c> will return or raise exceptions the
	  same way as <seemfa marker="#call/5"><c>erpc:call/5</c></seemfa>
	  does with the exception of <c>{erpc, badarg}</c>. An
	  <c>{erpc, badarg}</c> exception will be raised if/when an invalid
	  <c><anno>RequestId</anno></c> is detected or if an invalid
	  <c><anno>Timeout</anno></c> is passed.
	</p>
      </desc>
    </func>

    <func>
      <name name="send_request" arity="2" since="OTP 23.0"/>
      <fsummary>Send a request to evaluate a function call on a node.</fsummary>
      <desc>
	<p>
	  The same as calling
	  <seemfa marker="#send_request/4"><c>erpc:send_request(<anno>Node</anno>,erlang,apply,[<anno>Fun</anno>,[]])</c></seemfa>.
	</p>
	<p><c>erpc:send_request/2</c> fails with an <c>{erpc, badarg}</c>
	<c>error</c> exception if:</p>
	<list>
	  <item><p><c><anno>Node</anno></c> is not an atom.</p></item>
	  <item><p><c><anno>Fun</anno></c> is not a fun of
	  zero arity.</p></item>
	</list>
	<note>
	  <p>
	    You cannot make <em>any</em> assumptions about the
	    process that will perform the <c>apply()</c>. It may
	    be a server, or a freshly spawned process.
	  </p>
	</note>
      </desc>
    </func>
    
    <func>
      <name name="send_request" arity="4" since="OTP 23.0"/>
      <fsummary>Send a request to evaluate a function call on a node.</fsummary>
      <desc>
	<p>
	  Send an asynchronous <c>call</c> request to the node
	  <c><anno>Node</anno></c>. <c>erpc:send_request()</c>
	  returns a request identifier that later is to be passed
	  as argument to either
	  <seemfa marker="#receive_response/1"><c>erpc:receive_response()</c></seemfa>,
	  <seemfa marker="#wait_response/1"><c>erpc:wait_response()</c></seemfa>,
	  or,
	  <seemfa marker="#check_response/2"><c>erpc:check_response()</c></seemfa>
	  in order to get the response of the call request.
	</p>
	<p><c>erpc:send_request()</c> fails with an <c>{erpc, badarg}</c>
	<c>error</c> exception if:</p>
	<list>
	  <item><p><c><anno>Node</anno></c> is not an atom.</p></item>
	  <item><p><c><anno>Module</anno></c> is not an atom.</p></item>
	  <item><p><c><anno>Function</anno></c> is not an atom.</p></item>
	  <item><p><c><anno>Args</anno></c> is not a list. Note that the
	  list is not verified to be a proper list at the client side.</p></item>
	</list>
      </desc>
    </func>

    <func>
      <name name="wait_response" arity="1" since="OTP 23.0"/>
      <name name="wait_response" arity="2" since="OTP 23.0"/>
      <fsummary>Wait or poll for a call response corresponding to a previously
      sent call request.</fsummary>
      <desc>
	<p>
	  Wait or poll for a response message to a <c>call</c> request
	  previously made by the calling process using
	  <seemfa marker="#send_request/4"><c>erpc:send_request/4</c></seemfa>.
	  <c><anno>RequestId</anno></c> should be the value returned from
	  the previously made <c>erpc:send_request()</c> call, and the
	  corresponding response should not already have been received and handled
	  to completion by
	  <seemfa marker="#check_response/2"><c>erpc:check_response()</c></seemfa>,
	  <seemfa marker="#receive_response/2"><c>erpc:receive_response()</c></seemfa>,
	  or <c>erpc:wait_response()</c>. <c><anno>WaitTime</anno></c> equals the
	  time to wait in milliseconds (or the atom <c>infinity</c>) during the wait.
	  <c><anno>WaitTime</anno></c> is an integer representing time to wait
	  in milliseconds or the atom <c>infinity</c> which will cause
	  <c>wait_response/2</c> to wait for a response until it appears
	  regardless of how long time that is.
	</p>
	<p>
	  The call <c>erpc:wait_response(<anno>RequestId</anno>)</c> is equivalent
	  to the call <c>erpc:wait_response(<anno>RequestId</anno>, 0)</c>. That is,
	  poll for a response message to a <c>call</c> request previously made by
	  the calling process.
	</p>
	<p>
	  If no response is received before <c><anno>WaitTime</anno></c> milliseconds,
	  the atom <c>no_response</c> is returned. It is valid to continue waiting
	  for a response as many times as needed up until a response has
	  been received and completed by <c>erpc:check_response()</c>,
	  <c>erpc:receive_response()</c>, or <c>erpc:wait_response()</c>. If a
	  response is received, the <c>call</c> operation is completed and either
	  the result is returned as <c>{response, Result}</c> where <c>Result</c>
	  corresponds to the value returned from the applied function or an
	  exception is raised. The exceptions that can be raised corresponds to the
	  same exceptions as can be raised by
	  <seemfa marker="#call/4"><c>erpc:call/4</c></seemfa>.
	  That is, no <c>{erpc, timeout}</c> <c>error</c> exception can be raised.
	  <c>erpc:wait_response()</c> will fail with an <c>{erpc, badarg}</c>
	  exception if/when an invalid <c><anno>RequestId</anno></c> is detected
	  or if an invalid <c><anno>WaitTime</anno></c> is passed.
	</p>
	<p>
	  If the <c>erpc</c> operation fails, but it is unknown if
	  the function is/will be applied (that is, a too large wait time
	  value, or a connection loss), the caller will not receive any
	  further information about the result if/when the applied function
	  completes. If the applied function explicitly communicates with the
	  calling process, such communication may, of course, reach the
	  calling process.
        </p>
      </desc>
    </func>

  </funcs>
</erlref>

