NIO CommKit Host Interface Installation and System Administration Manual
F-2
Example Programs
Introduction
Introduction
This section provides several useful examples of CommKit Host Interface
application programs, to illustrate the descriptions provided in Chapter 5
"Programming With the CommKit Library".
Example 1
This code segment outlines a program written to run a standard Unix service
on either a local host or other user-speciļ¬ed host using the CommKit library
libdk.a.
/*
*
* Sample Datakit/Commkit Application Program
* ------------------------------------------
* Runs "uname" service on either local or user-specified host
* using libdk.
* Only local (client) side is Datakit aware.
* Remote (service) side is a standard UNIX application writing
* to STDOUT.
*
* To compile:
* cc -o dkapserv dkapserv.c -ldk
*
* To run:
* ./dkapserv <system>
*
* EXAMPLE:
* ./dkapserv tpddk09
*
* Add following tab-delimited entry to the server
* table/dksrvtab on the destination host:
*
* * uname t *n /usr/bin/uname uname:-a
------------------------------------------------------------*/
#include <sys/utsname.h>
main(argc,argv)
int argc;
char *argv[];
{
int dkfd, rlen;
char *hostname, dialstr[20], inbuf[100];
struct utsname utsname;
(continues next page)