setprotoent(3) — Subroutines
NAME
setprotoent, setprotoent_r − Open or rewind the protocols file
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <netdb.h> int setprotoent(
int stay_open); int setprotoent_r(
int stay_open,
struct protoent_data ∗proto_data);
PARAMETERS
stay_openIndicates when to close the protocols file. Specifying a value of 0 (zero) closes the file after each call to the setprotoent() function. Specifying a nonzero value allows the /etc/protocols file to remain open after each function.
proto_dataPoints at a structure where setprotoent_r() stores information about the protocols file.
DESCRIPTION
The setprotoent() (set protocol entry) function opens the /etc/protocols file and sets the file marker to the beginning of the file.
The setprotoent_r() function is the reentrant version of the setprotoent() function. Note that before calling the setprotoent_r() function for the first time, you must zero-fill the protoent_data structure. The netdb.h header file defines the protoent_data structure.
The system searches either the local /etc/protocols file or the NIS distributed networks file for the requested information. To determine which file or files to search, and in which order, the system uses the switches in the /etc/svc.conf file.
RETURN VALUES
Upon successful completion, the setprotoent() function returns a value of 1. Otherwise, it returns a value of 0 (zero).
Upon successful completion, the setprotoent_r() function returns a value of 0 (zero). Otherwise, it returns a value of -1.
ERRORS
If any of the following conditions occurs, the setprotoent_r() function sets errno to the corresponding value:
[EINVAL]The proto_data parameter is invalid.
In addition, the setprotoent() and setprotoent_r() functions can fail to open the file. In this case, errno will be set to the failure.
FILES
/etc/protocols
Contains the protocol names.
RELATED INFORMATION
Functions: endprotoent(3), getprotobyname(3), getprotobynumber(3), getprotoent(3).