ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahp_5.4.0.1/rzahpexpertservice.htm

113 lines
5.0 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Example: TI-RPC expert-level service API" />
<meta name="abstract" content="This code example illustrates an expert-level service API that is used in developing TI-RPC services." />
<meta name="description" content="This code example illustrates an expert-level service API that is used in developing TI-RPC services." />
<meta name="DC.Relation" scheme="URI" content="rzahpservicecode.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzahpexpertservice" />
<meta name="DC.Language" content="en-us" />
<!-- 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. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Example: TI-RPC expert-level service API</title>
</head>
<body id="rzahpexpertservice"><a name="rzahpexpertservice"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example: TI-RPC expert-level service API</h1>
<div><p>This code example illustrates an expert-level service API that
is used in developing TI-RPC services.</p>
<div class="section"><p>The expert level allows the programmer to specify Send and Receive
buffer sizes for services. Calling svc_tli_create() creates the service handle,
but it does not register or bind it with the rpcbind daemon. The programmer
must call svc_reg() before the service works properly. Similar to the intermediate
level, you have the option to use the network selection APIs to retrieve the
transport information for the service.</p>
<div class="note"><span class="notetitle">Note:</span> By using the code example,
you agree to the terms of the <a href="codedisclaimer.htm">Code license and disclaimer information</a>.</div>
<pre>#include &lt;stdio.h&gt;
#include &lt;netconfig.h&gt;
#include &lt;rpc/rpc.h&gt;
#include &lt;errno.h&gt;
#include "myapp.h"
int main(int argc, char *argv[]) {
struct netconfig *nconf; /* pointer to nettype data */
SVCXPRT *svc; /* pointer to service handle */
bool_t rslt; /* return value for svc_reg() */
/* unregister any existing copy of this service */
/* (void)svc_unreg(program, version) */
svc_unreg(PROGNUM, VERSNUM);
/* (struct netconfig *)getnetconfigent(nettype) */
nconf = getnetconfigent(NETTYPE);
/* check for errors calling getnetconfigent() */
if (nconf == (struct netconfig *)NULL) {
/* print error messages and exit */
fprintf(stderr, "Error calling getnetconfigent(%s)\n", NETTYPE);
fprintf(stderr, "errno: %d\n", errno);
return 1;
}
/* (SVCXPRT *)svc_tli_create(filedes, netconfig, bindaddr, sendsz, recvsz) */
svc = svc_tli_create(RPC_ANYFD, nconf, NULL, 0, 0);
/* check for errors calling svc_tli_create() */
if (svc == (SVCXPRT *)NULL) {
/* print error messages and exit */
fprintf(stderr, "Error calling %s.\n", "svc_tli_create");
fprintf(stderr, "errno: %d\n", errno);
return 1;
}
/* (bool_t)svc_reg(svcxprt, prognum, versnum, dispatch, netconf) */
rslt = svc_reg(svc, PROGNUM, VERSNUM, myapp_dispatch, nconf);
/* check for errors calling svc_reg() */
if (rslt == FALSE) {
/* print error messages and exit */
fprintf(stderr, "Error calling svc_reg\n");
fprintf(stderr, "PROG: %lu\nVERS: %lu\tNET: %s\n",
PROGNUM, VERSNUM, NETTYPE);
fprintf(stderr, "errno: %d\n", errno);
return 1;
}
/* this should loop indefinitely waiting for client connections */
svc_run();
/* if we get here, svc_run() returned */
fprintf(stderr, "svc_run() returned. ERROR has occurred.\n");
fprintf(stderr, "errno: %d\n", errno);
/* clean up by unregistering. then, exit */
svc_unreg(PROGNUM, VERSNUM);
return 1;
} /* end of main() */</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzahpservicecode.htm" title="Transport independent remote procedure call (TI-RPC) programming provides an effective method for developing distributed client-server based applications on i5/OS.">Examples: Develop service applications based on TI-RPC code</a></div>
</div>
</div>
</body>
</html>