1getprotoent(3)             Library Functions Manual             getprotoent(3)
2
3
4

NAME

6       getprotoent, getprotobyname, getprotobynumber, setprotoent, endprotoent
7       - get protocol entry
8

LIBRARY

10       Standard C library (libc, -lc)
11

SYNOPSIS

13       #include <netdb.h>
14
15       struct protoent *getprotoent(void);
16
17       struct protoent *getprotobyname(const char *name);
18       struct protoent *getprotobynumber(int proto);
19
20       void setprotoent(int stayopen);
21       void endprotoent(void);
22

DESCRIPTION

24       The getprotoent() function reads the  next  entry  from  the  protocols
25       database (see protocols(5)) and returns a protoent structure containing
26       the broken-out fields from the entry.  A connection is  opened  to  the
27       database if necessary.
28
29       The  getprotobyname() function returns a protoent structure for the en‐
30       try from the database that matches the protocol name name.   A  connec‐
31       tion is opened to the database if necessary.
32
33       The  getprotobynumber()  function  returns a protoent structure for the
34       entry from the database that matches the  protocol  number  number.   A
35       connection is opened to the database if necessary.
36
37       The setprotoent() function opens a connection to the database, and sets
38       the next entry to the first entry.  If stayopen is  nonzero,  then  the
39       connection  to  the database will not be closed between calls to one of
40       the getproto*() functions.
41
42       The endprotoent() function closes the connection to the database.
43
44       The protoent structure is defined in <netdb.h> as follows:
45
46           struct protoent {
47               char  *p_name;       /* official protocol name */
48               char **p_aliases;    /* alias list */
49               int    p_proto;      /* protocol number */
50           }
51
52       The members of the protoent structure are:
53
54       p_name The official name of the protocol.
55
56       p_aliases
57              A NULL-terminated list of alternative names for the protocol.
58
59       p_proto
60              The protocol number.
61

RETURN VALUE

63       The getprotoent(), getprotobyname(), and  getprotobynumber()  functions
64       return  a  pointer  to  a statically allocated protoent structure, or a
65       null pointer if an error occurs or the end of the file is reached.
66

FILES

68       /etc/protocols
69              protocol database file
70

ATTRIBUTES

72       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
73       tributes(7).
74
75       ┌───────────────────┬───────────────┬──────────────────────────────────┐
76Interface          Attribute     Value                            
77       ├───────────────────┼───────────────┼──────────────────────────────────┤
78getprotoent()      │ Thread safety │ MT-Unsafe race:protoent          │
79       │                   │               │ race:protoentbuf locale          │
80       ├───────────────────┼───────────────┼──────────────────────────────────┤
81getprotobyname()   │ Thread safety │ MT-Unsafe race:protobyname       │
82       │                   │               │ locale                           │
83       ├───────────────────┼───────────────┼──────────────────────────────────┤
84getprotobynumber() │ Thread safety │ MT-Unsafe race:protobynumber     │
85       │                   │               │ locale                           │
86       ├───────────────────┼───────────────┼──────────────────────────────────┤
87setprotoent(),     │ Thread safety │ MT-Unsafe race:protoent locale   │
88endprotoent()      │               │                                  │
89       └───────────────────┴───────────────┴──────────────────────────────────┘
90       In  the above table, protoent in race:protoent signifies that if any of
91       the functions setprotoent(), getprotoent(), or endprotoent()  are  used
92       in  parallel  in  different threads of a program, then data races could
93       occur.
94

STANDARDS

96       POSIX.1-2008.
97

HISTORY

99       POSIX.1-2001, 4.3BSD.
100

SEE ALSO

102       getnetent(3), getprotoent_r(3), getservent(3), protocols(5)
103
104
105
106Linux man-pages 6.05              2023-07-20                    getprotoent(3)
Impressum