96 lines
4.4 KiB
HTML
96 lines
4.4 KiB
HTML
|
<?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 intermediate-level service API" />
|
||
|
<meta name="abstract" content="This code example illustrates an intermediate-level service API that is used in developing TI-RPC services." />
|
||
|
<meta name="description" content="This code example illustrates an intermediate-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="rzahpintservice" />
|
||
|
<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 intermediate-level service API</title>
|
||
|
</head>
|
||
|
<body id="rzahpintservice"><a name="rzahpintservice"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Example: TI-RPC intermediate-level service API</h1>
|
||
|
<div><p>This code example illustrates an intermediate-level service API
|
||
|
that is used in developing TI-RPC services.</p>
|
||
|
<div class="section"><p>The dispatch function can be reused without any changes.
|
||
|
The only difference between the top and intermediate levels is the use of
|
||
|
the network selection APIs. This level also creates, binds, and registers
|
||
|
the service with the rpcbind daemon.</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 <stdio.h>
|
||
|
#include <netconfig.h>
|
||
|
#include <rpc/rpc.h>
|
||
|
#include <errno.h>
|
||
|
#include "myapp.h"
|
||
|
|
||
|
int main(int argc, char *argv[]) {
|
||
|
|
||
|
struct netconfig *nconf; /* pointer to nettype data */
|
||
|
SVCXPRT *svc; /* pointer to service handle */
|
||
|
|
||
|
/* unregister any existing copy of this service */
|
||
|
/* (void)svc_unreg(program, version) */
|
||
|
svc_unreg(PROGNUM, VERSNUM);
|
||
|
|
||
|
/* (struct netconfig *)getnetconfigent(nettype) */
|
||
|
nconf = getnetconfigent(NETTYPE);
|
||
|
if (nconf == (struct netconfig *)NULL) {
|
||
|
fprintf(stderr, "Error calling getnetconfigent(%s)\n", NETTYPE);
|
||
|
fprintf(stderr, "errno: %d\n", errno);
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
/* (SVCXPRT *)svc_tp_create(dispatch, prognum, versnum, netconf) */
|
||
|
svc = svc_tp_create(myapp_dispatch, PROGNUM, VERSNUM, nconf);
|
||
|
|
||
|
/* check for errors calling svc_tp_create() */
|
||
|
if (svc == (SVCXPRT *)NULL) {
|
||
|
/* print error messages and exit */
|
||
|
fprintf(stderr, "Error calling %s.\n", "svc_tp_create");
|
||
|
fprintf(stderr, "PROG: %lu\tVERS: %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>
|