1GETPROTOENT(3) Linux Programmer's Manual GETPROTOENT(3)
2
3
4
6 getprotoent, getprotobyname, getprotobynumber, setprotoent, endprotoent
7 - get protocol entry
8
10 #include <netdb.h>
11
12 struct protoent *getprotoent(void);
13
14 struct protoent *getprotobyname(const char *name);
15 struct protoent *getprotobynumber(int proto);
16
17 void setprotoent(int stayopen);
18 void endprotoent(void);
19
21 The getprotoent() function reads the next entry from the protocols
22 database (see protocols(5)) and returns a protoent structure containing
23 the broken-out fields from the entry. A connection is opened to the
24 database if necessary.
25
26 The getprotobyname() function returns a protoent structure for the en‐
27 try from the database that matches the protocol name name. A connec‐
28 tion is opened to the database if necessary.
29
30 The getprotobynumber() function returns a protoent structure for the
31 entry from the database that matches the protocol number number. A
32 connection is opened to the database if necessary.
33
34 The setprotoent() function opens a connection to the database, and sets
35 the next entry to the first entry. If stayopen is nonzero, then the
36 connection to the database will not be closed between calls to one of
37 the getproto*() functions.
38
39 The endprotoent() function closes the connection to the database.
40
41 The protoent structure is defined in <netdb.h> as follows:
42
43 struct protoent {
44 char *p_name; /* official protocol name */
45 char **p_aliases; /* alias list */
46 int p_proto; /* protocol number */
47 }
48
49 The members of the protoent structure are:
50
51 p_name The official name of the protocol.
52
53 p_aliases
54 A NULL-terminated list of alternative names for the protocol.
55
56 p_proto
57 The protocol number.
58
60 The getprotoent(), getprotobyname(), and getprotobynumber() functions
61 return a pointer to a statically allocated protoent structure, or a
62 null pointer if an error occurs or the end of the file is reached.
63
65 /etc/protocols
66 protocol database file
67
69 For an explanation of the terms used in this section, see at‐
70 tributes(7).
71
72 ┌───────────────────┬───────────────┬──────────────────────────────────┐
73 │Interface │ Attribute │ Value │
74 ├───────────────────┼───────────────┼──────────────────────────────────┤
75 │getprotoent() │ Thread safety │ MT-Unsafe race:protoent │
76 │ │ │ race:protoentbuf locale │
77 ├───────────────────┼───────────────┼──────────────────────────────────┤
78 │getprotobyname() │ Thread safety │ MT-Unsafe race:protobyname │
79 │ │ │ locale │
80 ├───────────────────┼───────────────┼──────────────────────────────────┤
81 │getprotobynumber() │ Thread safety │ MT-Unsafe race:protobynumber │
82 │ │ │ locale │
83 ├───────────────────┼───────────────┼──────────────────────────────────┤
84 │setprotoent(), │ Thread safety │ MT-Unsafe race:protoent locale │
85 │endprotoent() │ │ │
86 └───────────────────┴───────────────┴──────────────────────────────────┘
87 In the above table, protoent in race:protoent signifies that if any of
88 the functions setprotoent(), getprotoent(), or endprotoent() are used
89 in parallel in different threads of a program, then data races could
90 occur.
91
93 POSIX.1-2001, POSIX.1-2008, 4.3BSD.
94
96 getnetent(3), getprotoent_r(3), getservent(3), protocols(5)
97
99 This page is part of release 5.13 of the Linux man-pages project. A
100 description of the project, information about reporting bugs, and the
101 latest version of this page, can be found at
102 https://www.kernel.org/doc/man-pages/.
103
104
105
106GNU 2021-03-22 GETPROTOENT(3)