ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/rpc_call.htm

305 lines
7.8 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>rpc_call()--Call a Remote Procedure on the Specified System</title>
<!-- Begin Header Records ========================================== -->
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- RPCMST SCRIPT A converted by B2H R4.1 (346) (CMS) by PMHALL at -->
<!-- RCHVMW2 on 7 Oct 1998 at 23:43:14 -->
<!-- Edited by Kersten Feb 02 -->
<!--End Header Records -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!-- Java sync-link -->
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
</script>
<a name="Top_Of_Page"></a>
<h2>rpc_call()--Call a Remote Procedure on the Specified System</h2>
<div class="box" style="width: 60%;">
<br>
&nbsp;&nbsp;Syntax<br>
<!-- iddvc RMBR -->
<br>
<pre>
#include &lt;rpc/rpc.h&gt;
enum clnt_stat rpc_call(const char *<em>host</em>,
const u_long <em>prognum</em>,
const u_long <em>versnum</em>,
const u_log <em>procnum</em>,
const xdrproc_t <em>inproc</em>,
const char *<em>in</em>,
const xdrproc_t <em>outproc</em>,
char *<em>out</em>,
const char *<em>nettype</em>);
</pre>
<br>
&nbsp;&nbsp;Service Program Name: QZNFTRPC<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: No<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong>rpc_call()</strong> API calls the remote procedure that is
associated with <em>prognum, versnum,</em> and <em>procnum</em> on the machine,
<em>host</em>. <strong>rpc_call()</strong> tries all the transports of the
nettype class available from the netconfig database file, and chooses the first
successful one. Transports are tried in top-to-bottom order in the netconfig
database file. A default time-out is set and can be modified using
<strong>clnt_control()</strong>.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong>host</strong> &nbsp;(Input)&nbsp;</dt>
<dd>A pointer to the program name of the remote machine.<br>
<br>
</dd>
<dt><strong>prognum</strong> &nbsp;(Input)&nbsp;</dt>
<dd>The program number of the remote program.<br>
<br>
</dd>
<dt><strong>vernum</strong> &nbsp;(Input)&nbsp;</dt>
<dd>The version number of the remote program.<br>
<br>
</dd>
<dt><strong>procnum</strong> &nbsp;(Input)&nbsp;</dt>
<dd>The number of the procedure that is associated with the remote program
being called.<br>
<br>
</dd>
<dt><strong>inproc</strong> &nbsp;(Input)&nbsp;</dt>
<dd>The name of the XDR procedure that encodes the procedure parameters.<br>
<br>
</dd>
<dt><strong>in</strong> &nbsp;(Input)&nbsp;</dt>
<dd>The address of the procedure arguments.<br>
<br>
</dd>
<dt><strong>outproc</strong> &nbsp;(Input)&nbsp;</dt>
<dd>The name of the XDR procedure that decodes the procedure results.<br>
<br>
</dd>
<dt><strong>out</strong> &nbsp;(Output)&nbsp;</dt>
<dd>The address where results are placed.<br>
<br>
</dd>
<dt><strong>nettype</strong> &nbsp;(Input)&nbsp;</dt>
<dd>The following classes of transport protocol are valid and are represented
as a string either in lowercase or in uppercase: NETPATH, VISIBLE, CIRCUIT_V,
DATAGRAM_V, CIRCUIT_N, DATAGRAM_N, TCP, and UDP. When this parameter is NULL,
NETPATH is assumed.</dd>
</dl>
<br>
<h3>Authorities</h3>
<p>The caller of the <strong>rpc_call()</strong> API must have execute (*X)
authority to the /etc directory and must have read (*R) authority to the
netconfig file.</p>
<br>
<h3>Return Value</h3>
<table cellpadding="5">
<!-- cols="15 85" -->
<tr>
<td align="left" valign="top"><em>RPC_SUCCESS (0)</em> </td>
<td align="left" valign="top">Successful</td>
</tr>
<tr>
<td align="left" valign="top"><em>Non-zero value</em> </td>
<td align="left" valign="top">rpc_call() was not successful. The
<em>rpc_createerr</em> global structure is set to indicate the error.</td>
</tr>
</table>
<br>
<br>
<h3>Error Conditions</h3>
<p>Upon failure, <strong>rpc_call()</strong> sets the global structure
<em>rpc_createerr</em>. The <em>rpc_createerr.cf_stat</em> variable has a
status value that indicates the error reason. The
<em>rpc_createerr.cf_error.re_errno</em> variable is meaningful when some
status values are set.</p>
<p>The <em>rpc_createerr.cf_stat</em> variable can be set to one of the
following values:</p>
<p>This API calls <strong>clnt_create()</strong> and
<strong>clnt_call()</strong> APIs in order to perform its task. All error
conditions from those APIs are inherited except RPC_FAILED from
<strong>clnt_call()</strong>.</p>
<table cellpadding="5">
<!-- cols="25 75" -->
<tr>
<td align="left" valign="top"><em>[RPC_SYSTEMERROR]</em> </td>
<td align="left" valign="top">RPC error returned from system call. The
<em>rpc_createerr.cf_error.re_errno</em> variable can be set to one of the
following values:
<table cellpadding="5">
<tr>
<td align="left" valign="top"><em>[ENOMEM]</em> </td>
<td align="left" valign="top">Out of memory.</td>
</tr>
<tr>
<td align="left" valign="top"><em>[RPC_UNKNOWNHOST]</em> </td>
<td align="left" valign="top">Unknown host.</td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<br>
<h3>Error Messages</h3>
<table width="100%" cellpadding="5">
<tr>
<th align="left" valign="top">Message ID</th>
<th align="left" valign="top">Error Message Text</th>
</tr>
<tr>
<td width="15%" valign="top">CPIA1B1 I</td>
<td width="85%" valign="top">A problem was encountered in the RPC client.</td>
</tr>
<tr>
<td align="left" valign="top">CPIA1B2 I</td>
<td align="left" valign="top">TI-RPC encountered a problem in the transport
protocol.</td>
</tr>
<tr>
<td align="left" valign="top">CPE3418 E</td>
<td align="left" valign="top">Possible APAR condition or hardware failure.</td>
</tr>
<tr>
<td align="left" valign="top">CPF3CF2 E</td>
<td align="left" valign="top">Error(s) occurred during running of &amp;1
API.</td>
</tr>
<tr>
<td align="left" valign="top">CPF9872 E</td>
<td align="left" valign="top">Program or service program &amp;1 in library
&amp;2 ended. Reason code &amp;3.</td>
</tr>
</table>
<br>
<br>
<h3>Related Information</h3>
<ul>
<li><a href="clnt_call.htm">clnt_call()--Call a Remote Procedure Associated
with the Client</a></li>
</ul>
<br>
<h3>Example</h3>
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
for information pertaining to code examples.</p>
<p>The following example shows how <strong>rpc_call()</strong> is used:</p>
<pre>
/* Define remote program number and version */
#define RMTPROGNUM (u_long)0x3fffffffL
#define RMTPROGVER (u_long)0x1
#define RMTPROCNUM (u_long)0x1
#include &lt;stdio.h&gt;
#include &lt;rpc/rpc.h&gt;
main()
{
int inproc=100, outproc;
enum clnt_stat rstat;
...
/* Service request to host RPCSERVER_HOST */
if (rstat = <strong>rpc_call</strong>(&quot;as400.somewhere.ibm.com&quot;, RMTPROGNUM,
RMTPROGVER, RMTPROCNUM, xdr_int, (char *)&amp;inproc,
xdr_int, (char *)&amp;outproc, &quot;VISIBLE&quot;)
!= RPC_SUCCESS){
fprintf(stderr,&quot;rpc_call() failed\n&quot;);
exit(1);
}
...
}
</pre>
<br>
<hr>
API introduced: V4R2
<hr>
<table cellpadding="2" cellspacing="2" align="center">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"rpc1.htm">Remote Procedure Call (RPC) APIs</a> | <a href="aplist.htm">APIs by
category</a></td>
</tr>
</table>
</body>
</html>