Using the highest layer
Suppose you are writing a program that needs to know how many
users are logged into a remote machine.
You might do this by
calling a library routine named
rnusers, as illustrated here:
#include <stdio.h>The rnusers routine is not included with this release of the software, but is shown as an example only.main(argc, argv) int argc; char **argv; { unsigned num;
if (argc < 2) { fprintf(stderr, "usage: rnusers hostname\n"); exit(1); } if ((num = rnusers(argv[1])) < 0) { fprintf(stderr, "error: rnusers\n"); exit(-1); } printf("%d users on %s\n", num, argv[1]); exit(0); }
The program above could be compiled with:
cc program.c -lrpcsvc -lsocket