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