NIO CommKit Host Interface Installation and System Administration Manual
F-3
Example Programs
Introduction
uname (&utsname);
hostname = argc > 1 ? argv[1] : utsname.nodename ;
sprintf (&dialstr, "%s.uname", hostname);
if ( (dkfd = dkdial (dialstr)) < 0) exit(1);
while ( (rlen = read (dkfd, inbuf, 100)) > 0 ) {
write (1,inbuf,rlen);
}
}
Example 2
This code segment outlines a program written to copy data to a Datakit
channel using the CommKit library libdk.a.
/*
*
* Sample Datakit/Commkit Application Program
* ------------------------------------------
*
* Perform a simple PUSH service using libdk. Local
* program copies data from stdin to a Datakit channel.
* Remote program writes data received from a Datakit channel
* to a file.
*
* To compile client:
* cc -DCLIENT -o dkappush_c dkappush.c -ldk
*
* To compile service:
* cc -DSERVICE -o dkappush_s dkappush.c -ldk
*
* To run:
* dkappush_c <system> <file to push>
*
* EXAMPLE:
* ./dkappush_c tpddk09 < /tmp/afile
*
* Add following tab-delimited entry to the server
* table/dksrvtab on the destination host:
*
* * dkappush b *n /usr/local/bin/dkappush_s dkappush_s
*
*
* -------------------------------------------------------- */
#ifdef CLIENT
#include <sys/utsname.h>
(continues next page)