1GETPROTOENT(3N) GETPROTOENT(3N)
2
3
4
6 getprotoent, getprotobynumber, getprotobyname, setprotoent, endprotoent
7 - get protocol entry
8
10 #include <netdb.h>
11
12 struct protoent *getprotoent()
13
14 struct protoent *getprotobyname(name)
15 char *name;
16
17 struct protoent *getprotobynumber(proto)
18 int proto;
19
20 setprotoent(stayopen)
21 int stayopen
22
23 endprotoent()
24
26 Getprotoent, getprotobyname, and getprotobynumber each return a pointer
27 to an object with the following structure containing the broken-out
28 fields of a line in the network protocol data base, /etc/protocols.
29
30 struct protoent {
31 char *p_name; /* official name of protocol */
32 char **p_aliases; /* alias list */
33 int p_proto; /* protocol number */
34 };
35
36 The members of this structure are:
37
38 p_name The official name of the protocol.
39
40 p_aliases A zero terminated list of alternate names for the protocol.
41
42 p_proto The protocol number.
43
44 Getprotoent reads the next line of the file, opening the file if neces‐
45 sary.
46
47 Setprotoent opens and rewinds the file. If the stayopen flag is non-
48 zero, the net data base will not be closed after each call to getproto‐
49 byname or getprotobynumber.
50
51 Endprotoent closes the file.
52
53 Getprotobyname and getprotobynumber sequentially search from the begin‐
54 ning of the file until a matching protocol name or protocol number is
55 found, or until EOF is encountered.
56
58 /etc/protocols
59
61 protocols(5)
62
64 Null pointer (0) returned on EOF or error.
65
67 All information is contained in a static area so it must be copied if
68 it is to be saved. Only the Internet protocols are currently under‐
69 stood.
70
71
72
734.2 Berkeley Distribution May 19, 1986 GETPROTOENT(3N)