1ENDSERVENT(P)              POSIX Programmer's Manual             ENDSERVENT(P)
2
3
4

NAME

6       endservent, getservbyname, getservbyport, getservent, setservent - net‐
7       work services database functions
8

SYNOPSIS

10       #include <netdb.h>
11
12       void endservent(void);
13       struct servent *getservbyname(const char *name, const char *proto);
14       struct servent *getservbyport(int port, const char *proto);
15       struct servent *getservent(void);
16       void setservent(int stayopen);
17
18

DESCRIPTION

20       These functions shall  retrieve  information  about  network  services.
21       This  information  is considered to be stored in a database that can be
22       accessed sequentially or randomly. The implementation of this  database
23       is unspecified.
24
25       The  setservent() function shall open a connection to the database, and
26       set the next entry to the first entry. If the stayopen argument is non-
27       zero,  the net database shall not be closed after each call to the get‐
28       servent() function (either directly, or indirectly through one  of  the
29       other  getserv*()  functions),  and  the implementation may maintain an
30       open file descriptor for the database.
31
32       The getservent() function shall read the next entry  of  the  database,
33       opening and closing a connection to the database as necessary.
34
35       The  getservbyname() function shall search the database from the begin‐
36       ning and find the first entry for which the service name  specified  by
37       name matches the s_name member and the protocol name specified by proto
38       matches the s_proto member, opening and closing  a  connection  to  the
39       database  as  necessary.  If  proto is a null pointer, any value of the
40       s_proto member shall be matched.
41
42       The getservbyport() function shall search the database from the  begin‐
43       ning  and  find  the  first  entry for which the port specified by port
44       matches the s_port member and the  protocol  name  specified  by  proto
45       matches  the  s_proto  member,  opening and closing a connection to the
46       database as necessary. If proto is a null pointer,  any  value  of  the
47       s_proto  member shall be matched. The port argument shall be in network
48       byte order.
49
50       The getservbyname(), getservbyport(), and getservent() functions  shall
51       each  return  a  pointer  to  a servent structure, the members of which
52       shall contain the fields of an entry in the network services database.
53
54       The endservent() function shall close the database, releasing any  open
55       file descriptor.
56
57       These  functions need not be reentrant. A function that is not required
58       to be reentrant is not required to be thread-safe.
59

RETURN VALUE

61       Upon successful completion, getservbyname(), getservbyport(), and  get‐
62       servent()  return  a  pointer  to  a servent structure if the requested
63       entry was found, and a null pointer if the  end  of  the  database  was
64       reached or the requested entry was not found. Otherwise, a null pointer
65       is returned.
66

ERRORS

68       No errors are defined.
69
70       The following sections are informative.
71

EXAMPLES

73       None.
74

APPLICATION USAGE

76       The port argument of getservbyport() need not be  compatible  with  the
77       port values of all address families.
78
79       The  getservbyname(),  getservbyport(),  and getservent() functions may
80       return pointers to static data, which may be overwritten by  subsequent
81       calls to any of these functions.
82

RATIONALE

84       None.
85

FUTURE DIRECTIONS

87       None.
88

SEE ALSO

90       endhostent() , endprotoent() , htonl() , inet_addr() , the Base Defini‐
91       tions volume of IEEE Std 1003.1-2001, <netdb.h>
92
94       Portions of this text are reprinted and reproduced in  electronic  form
95       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
96       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
97       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
98       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
99       event of any discrepancy between this version and the original IEEE and
100       The Open Group Standard, the original IEEE and The Open Group  Standard
101       is  the  referee document. The original Standard can be obtained online
102       at http://www.opengroup.org/unix/online.html .
103
104
105
106IEEE/The Open Group                  2003                        ENDSERVENT(P)
Impressum