NIO CommKit Host Interface Installation and System Administration Manual
F-4
Example Programs
Introduction
main(argc,argv) /* reads from stdin; writes to DK */
int argc;
char *argv[];
{
int dkfd, rlen, wlen;
char *hostname, dialstr[20], inbuf[100];
struct utsname utsname;
uname (&utsname);
hostname = argc > 1 ? argv[1] : utsname.nodename ;
sprintf (&dialstr, "%s.dkappush", hostname);
if ( (dkfd = dkdial (dialstr)) < 0) exit(1);
while (rlen = read(0,inbuf,sizeof(inbuf)))
write (dkfd, inbuf, rlen);
dkeof(dkfd);
exit(0);
}
#endif
/* -------------------------------------------------------- */
#ifdef SERVICE
#include <fcntl.h>
main() /* read from DK, write to file */
{
int fd, rlen;
char inbuf[100];
if ( (fd = open ("/tmp/dkappush.in",\xxxxxxxxxxxxxxxxxxxxxx
O_WRONLY|O_CREAT|O_TRUNC)) < 0)
exit(1);
while ((rlen = read(0,inbuf,100)) > 0)
write (fd,inbuf,rlen);
(rlen < 0) ? exit(1) : exit(0);
}
#endif
Example 3
This code segment outlines a program written to execute commands on a
remote machine using the Transport Level Interface library stored in
/usr/lib/libnsl_s.a.