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

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       endservent, getservbyname, getservbyport, getservent, setservent — net‐
14       work services database functions
15

SYNOPSIS

17       #include <netdb.h>
18
19       void endservent(void);
20       struct servent *getservbyname(const char *name, const char *proto);
21       struct servent *getservbyport(int port, const char *proto);
22       struct servent *getservent(void);
23       void setservent(int stayopen);
24

DESCRIPTION

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

RETURN VALUE

66       Upon successful completion, getservbyname(), getservbyport(), and  get‐
67       servent()  return  a  pointer  to  a servent structure if the requested
68       entry was found, and a null pointer if the  end  of  the  database  was
69       reached  or  the  requested  entry  was  not  found.  Otherwise, a null
70       pointer is returned.
71
72       The application shall not modify the  structure  to  which  the  return
73       value  points,  nor any storage areas pointed to by pointers within the
74       structure. The returned pointer, and  pointers  within  the  structure,
75       might  be  invalidated  or  the structure or the storage areas might be
76       overwritten by a subsequent call to  getservbyname(),  getservbyport(),
77       or getservent().
78

ERRORS

80       No errors are defined.
81
82       The following sections are informative.
83

EXAMPLES

85       None.
86

APPLICATION USAGE

88       The  port  argument  of getservbyport() need not be compatible with the
89       port values of all address families.
90

RATIONALE

92       None.
93

FUTURE DIRECTIONS

95       None.
96

SEE ALSO

98       endhostent(), endprotoent(), htonl(), inet_addr()
99
100       The Base Definitions volume of POSIX.1‐2008, <netdb.h>
101
103       Portions of this text are reprinted and reproduced in  electronic  form
104       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
105       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
106       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
107       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
108       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
109       event of any discrepancy between this version and the original IEEE and
110       The  Open Group Standard, the original IEEE and The Open Group Standard
111       is the referee document. The original Standard can be  obtained  online
112       at http://www.unix.org/online.html .
113
114       Any  typographical  or  formatting  errors that appear in this page are
115       most likely to have been introduced during the conversion of the source
116       files  to  man page format. To report such errors, see https://www.ker
117       nel.org/doc/man-pages/reporting_bugs.html .
118
119
120
121IEEE/The Open Group                  2013                       ENDSERVENT(3P)
Impressum