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

NAME

12       endservent, getservbyname, getservbyport, getservent, setservent - net‐
13       work services database functions
14

SYNOPSIS

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

DESCRIPTION

26       These  functions  shall  retrieve  information  about network services.
27       This 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 in  network
54       byte order.
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 reentrant. A function that is not  required
64       to be reentrant is not required to be thread-safe.
65

RETURN VALUE

67       Upon  successful completion, getservbyname(), getservbyport(), and get‐
68       servent() return a pointer to a  servent  structure  if  the  requested
69       entry  was  found,  and  a  null pointer if the end of the database was
70       reached or the requested entry was not found. Otherwise, a null pointer
71       is returned.
72

ERRORS

74       No errors are defined.
75
76       The following sections are informative.
77

EXAMPLES

79       None.
80

APPLICATION USAGE

82       The  port  argument  of getservbyport() need not be compatible with the
83       port values of all address families.
84
85       The getservbyname(), getservbyport(), and  getservent()  functions  may
86       return  pointers to static data, which may be overwritten by subsequent
87       calls to any of these functions.
88

RATIONALE

90       None.
91

FUTURE DIRECTIONS

93       None.
94

SEE ALSO

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