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

271 lines
7.0 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_reg()--Register a Procedure with RPC Service Package</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_reg()--Register a Procedure with RPC Service Package</h2>
<div class="box" style="width: 60%;">
<br>
&nbsp;&nbsp;Syntax<br>
<!-- iddvc RMBR -->
<br>
<pre>
=
#include &lt;rpc/rpc.h&gt;
bool_t rpc_reg(const u_long <em>prognum</em>,
const u_long <em>versnum</em>,
const u_long <em>procnum</em>,
char *(*<em>procname</em>)(char *),
const xdrproc_t <em>inproc</em>,
const xdrproc_t <em>outproc</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_reg()</strong> function registers a procedure with the RPC
service package (<strong>RPCBind</strong>). If a request arrives that matches
the values of the <em>prognum</em> parameter, the <em>versnum</em> parameter,
and the <em>procnum</em> parameter, then the <em>procname</em> parameter is
called with a pointer to its parameters. The <em>procname</em> returns a
pointer to its static results.</p>
<p>The procedure is registered for each transport of the specified type (the
<em>nettype</em> parameter). If the <em>nettype</em> parameter is (char *)NULL,
the procedure is registered for all transports that are specified in the
/etc/netconfig file with a corresponding flag value visible. After registering
the local procedure, the server program's main procedure calls
<strong>svc_run()</strong>, the RPC library's remote procedure dispatcher.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong>prognum</strong> &nbsp;(Input)&nbsp;</dt>
<dd>The program number of the remote program.<br>
<br>
</dd>
<dt><strong>versnum</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 procedure number to be called.<br>
<br>
</dd>
<dt><strong>procname</strong> &nbsp;(Input)&nbsp;</dt>
<dd>The procedure name.<br>
<br>
</dd>
<dt><strong>inproc</strong> &nbsp;(Input)&nbsp;</dt>
<dd>The eXternal Data Representation (XDR) subroutine that decodes the
procedure parameters.<br>
<br>
</dd>
<dt><strong>outproc</strong> &nbsp;(Input)&nbsp;</dt>
<dd>The XDR subroutine that encodes the procedure results.<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_reg()</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>TRUE (1)</em> </td>
<td align="left" valign="top"><strong>rpc_reg()</strong> was successful.</td>
</tr>
<tr>
<td align="left" valign="top"><em>FALSE (0)</em> </td>
<td align="left" valign="top"><strong>rpc_reg()</strong> was not successful. The
<em>errno</em> variable is set to indicate the reason.</td>
</tr>
</table>
<br>
<br>
<h3>Error Conditions</h3>
<p>This API inherits all error conditions from the
<strong>setnetconfig()</strong> and <strong>getnetconfig()</strong> APIs. It
also inherits all error conditions from the <strong>svc_tli_create()</strong>
and <strong>svc_reg()</strong> APIs.</p>
<br>
<h3>Error Messages</h3>
<table width="100%" cellpadding="5">
<!-- cols="15 85" -->
<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">CPE3418 E</td>
<td width="85%" 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>
<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">CPIA1B3 I</td>
<td align="left" valign="top">TI-RPC encountered a problem in the server.</td>
</tr>
<tr>
<td align="left" valign="top">CPIA1B5 I</td>
<td align="left" valign="top">An incorrect nettype was given.</td>
</tr>
</table>
<br>
<br>
<h3>Related Information</h3>
<ul>
<li><a href="svc_reg.htm">svc_reg()--Associate Program and Version with
Dispatch</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_reg()</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;
int *rmtproc(int *param) /* remote procedure */
{
static int result;
result = *param + *param;
return(&amp;result);
}
main()
{
int *rmtprog();
/* Register remote program with RPCBind */
if (<strong>rpc_reg</strong>(RMTPROGNUM, RMTPROGVER, RMTPROCNUM, rmtprog,
xdr_int, xdr_int, &quot;VISIBLE&quot;) == -1) {
fprintf(stderr, &quot;Could not Register\n&quot;);
exit(1);
}
svc_run();
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>