Users can control the loop by setting the NETPATH
environment variable to a colon-separated list of transport names. If NETPATH
is set as follows:
NETPATH=tcp:udp |
The loop first returns the tcp entry, then the udp entry. If NETPATH
is not defined, the loop returns all visible entries in the netconfig file in the order in which they are stored. The NETPATH
environment variable lets users define the order in which client-side applications try to connect to a service. It also lets the server administrator limit transports on which a service can listen.
Use getnetpath() and setnetpath() to obtain or modify the network path variable. Example 4-6 shows the form and use, which are similar to the getnetconfig() and setnetconfig() routines.
void *handlep; struct netconfig *nconf; if ((handlep = setnetconfig() == (void *) NULL) { nc_perror("setnetconfig"); exit(1); } while (nconf = getnetconfig(handlep)) if (nconf->nc_flag & NC_VISIBLE) doit(nconf); (void) endnetconfig(handlep); |