356 lines
9.3 KiB
HTML
356 lines
9.3 KiB
HTML
<!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>clnt_create()--Create a Generic Client Handle</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. -->
|
|
<!-- Change History: -->
|
|
<!-- YYMMDD USERID Change description -->
|
|
<!-- 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 language="Javascript" src="../rzahg/synch.js" type="text/javascript">
|
|
</script>
|
|
|
|
<h2>clnt_create()--Create a Generic Client Handle</h2>
|
|
|
|
<div class="box" style="width: 60%;">
|
|
<br>
|
|
Syntax<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
<pre>
|
|
#include <rpc/rpc.h>
|
|
|
|
CLIENT *clnt_create(const char *<em>host</em>,
|
|
const u_long <em>prognum</em>,
|
|
const u_long <em>versnum</em>,
|
|
const char *<em>nettype</em>);
|
|
</pre>
|
|
|
|
<br>
|
|
Service Program Name: QZNFTRPC<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Default Public Authority: *USE<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Threadsafe: No<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<p>The <strong>clnt_create()</strong> API creates and returns a generic client
|
|
handle for program <em>prognum</em> and version <em>versnum</em> on a remote
|
|
host where the server is located. This is done using an available transport of
|
|
the <em>nettype</em> class. The <strong>clnt_create()</strong> API tries all
|
|
the transports of the <em>nettype</em> class available from the /etc/netconfig
|
|
file, and chooses the first successful one. Transports are tried in
|
|
top-to-bottom order in the netconfig database. 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> (Input) </dt>
|
|
|
|
<dd>The name of the remote host where the server is located.<br>
|
|
<br>
|
|
</dd>
|
|
|
|
<dt><strong>prognum</strong> (Input) </dt>
|
|
|
|
<dd>The program number of the remote program.<br>
|
|
<br>
|
|
</dd>
|
|
|
|
<dt><strong>vernum</strong> (Input) </dt>
|
|
|
|
<dd>The version number of the remote program.<br>
|
|
<br>
|
|
</dd>
|
|
|
|
<dt><strong>nettype</strong> (Input) </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>clnt_create()</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 valign="top"><em>clnt</em></td>
|
|
<td valign="top">Upon successful completion, this API returns a client
|
|
handle.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>NULL</em></td>
|
|
<td valign="top"><strong>clnt_create()</strong> was not successful. The
|
|
<em>rpc_createerr</em> variable is set to indicate the reason.</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
<br>
|
|
|
|
|
|
<h3>Error Conditions</h3>
|
|
|
|
<p>Upon failure, <strong>clnt_create()</strong> sets the global structure
|
|
<em>rpc_createerr</em>. The <em>rpc_createerr.cf_stat</em> variable contains 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>
|
|
|
|
<table cellpadding="5">
|
|
<!-- cols="25 75" -->
|
|
<tr>
|
|
<td valign="top"><em>[RPC_INTR]</em></td>
|
|
<td valign="top">Interrupted RPC call. An exception has occurred in the RPC
|
|
API. The <em>rpc_createerr.cf_error.re_errno</em> variable is set to
|
|
EUNKNOWN.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>[RPC_N2AXLATEFAILURE]</em></td>
|
|
<td valign="top">Name-to-address translation failed. Cannot resolve the
|
|
hostname given in <em>host</em>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>[RPC_SYSTEMERROR]</em></td>
|
|
<td valign="top">An RPC error was returned from the system call. The
|
|
<em>rpc_createerr.cf_error.re_errno</em> variable is set to the value returned
|
|
from the failed call.
|
|
|
|
<table cellpadding="5">
|
|
<tr>
|
|
<td valign="top"><em>[EACCES]</em></td>
|
|
<td valign="top">Permission denied.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>[EADDRINUSE]</em></td>
|
|
<td valign="top">Local address is in use. This value is set when <em>host</em>
|
|
is not valid or the file descriptor associated with it cannot be bound to any
|
|
local address.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>[EADDRNOTAVAIL]</em></td>
|
|
<td valign="top">Address not available. This value is set when the address
|
|
obtained by the <strong>rpcb_getaddr()</strong> is rejected by the transport
|
|
layer.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>[EAGAIN]</em></td>
|
|
<td valign="top">Operation would have caused the process to be blocked.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>[EBADF]</em></td>
|
|
<td valign="top">Bad file descriptor. This value is set when <em>host</em> is
|
|
not valid or the file descriptor associated with it is already closed or
|
|
damaged.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>[ECONNREFUSED]</em></td>
|
|
<td valign="top">TI-RPC encountered a problem in the transport. The client
|
|
cannot connect to the server.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>[EFAULT]</em></td>
|
|
<td valign="top">The address created by the <strong>rpcb_getaddr()</strong> was
|
|
not available.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>[EIO]</em></td>
|
|
<td valign="top">Input/output error. This value is set as a result of network
|
|
transport failure. It indicates that RPC cannot handle an error that occurred
|
|
in lower transport levels.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>[ENOBUFS]</em></td>
|
|
<td valign="top">There is not enough buffer space available for the API.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>[ENOMEM]</em></td>
|
|
<td valign="top">Out of memory.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>[EOPNOTSUPP]</em></td>
|
|
<td valign="top">Operation is not supported. This value is set when
|
|
<em>host</em> is not valid or the file descriptor associated with it has
|
|
limited capabilities.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>[EUNKNOWN]</em></td>
|
|
<td valign="top">Unknown system state.</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>[RPC_UNKNOWNHOST]</em></td>
|
|
<td valign="top">Unknown <em>host</em>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top"><em>[RPC_UNKNOWNPROTO]</em></td>
|
|
<td valign="top">Unknown client/server protocol. The
|
|
<em>rpc_createerr.cf_error.re_errno</em> is set with the errno value returned
|
|
by <strong>setnetconfig()</strong> or <strong>getnetconfig()</strong> call.
|
|
This error is set when the <em>netconf</em> pointer is NULL.</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 valign="top">CPIA1B2 I</td>
|
|
<td valign="top">TI-RPC encountered a problem in the transport protocol.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top">CPIA1B5 I</td>
|
|
<td valign="top">An incorrect nettype was given.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top">CPE3418 E</td>
|
|
<td valign="top">Possible APAR condition or hardware failure.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top">CPF3CF2 E</td>
|
|
<td valign="top">Error(s) occurred during running of &1 API.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top">CPF9872 E</td>
|
|
<td valign="top">Program or service program &1 in library &2 ended.
|
|
Reason code &3.</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
<br>
|
|
|
|
|
|
<h3>Related Information</h3>
|
|
|
|
<ul>
|
|
<li><a href="clnt_tp_create.htm">clnt_tp_create()--Create a Client
|
|
Handle</a></li>
|
|
|
|
<li><a href="clnt_tli_create.htm">clnt_tli_create()--Create a Client
|
|
Handle</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>clnt_create()</strong> is used:</p>
|
|
|
|
<pre>
|
|
/* Define remote program number and version */
|
|
#define RMTPROGNUM (u_long)0x3fffffffL
|
|
#define RMTPROGVER (u_long)0x1
|
|
|
|
#include <stdio.h>
|
|
#include <rpc/rpc.h>
|
|
|
|
main()
|
|
{
|
|
CLIENT *client;
|
|
|
|
/* Service request to host RPCSERVER_HOST */
|
|
client = <strong>clnt_create</strong>("as400.somewhere.ibm.com", RMTPROGNUM,
|
|
RMTPROGVER, "TCP");
|
|
|
|
if (client == (CLIENT *)NULL) {
|
|
fprintf(stderr,"Couldn't create client\n");
|
|
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>
|
|
|