NIO CommKit Host Interface Installation and System Administration Manual

F-5
Example Programs
Introduction
/*
*
* Sample Datakit/Commkit TLI Application Program
* ----------------------------------------------
*
* This program can execute a command on a remote node
* using the tli library.
*
* To compile:
* cc -o tliserv tliserv.c -lnsl_s
*
* To run:
* ./tliserv <transport> <system> <service>
*
* transport - identifies a transport provider. Specific-
* caly, it is the path name of the entry under /dev for a
* given network. (i.e., "/dev/mx", "/dev/dktp0", etc.)
* system - specifies the remote node
* service - name of command to execute
*
* EXAMPLE that executes the "uname" command on host TPDDK09:
*
* ./tliserv /dev/mx TPDDK09 uname
*
*/
#include <stdio.h>
#include <sys/tiuser.h>
#include <fcntl.h>
#include <sys/stropts.h>
/*
* NLPS string sent to remote listener(1M) to request service"
*/
char NLPSx[] = "NLPS:000:002:";
main(ac, av)
int ac;
char *av[];
{
int fd, n ;
char instuff[1024];
if (ac != 4)
{
fprintf (stderr, "Usage: %s transport system service\n",
av[0]);
exit (1);
}
if ((fd = connect(av[1], av[2], av[3])) < 0)
exit(-1);
while ((n=read(fd,instuff,1024))>0) {
write (1,instuff,n);
(continues next page)