1endservent(3XNET)X/Open Networking Services Library Functionsendservent(3XNET)
2
3
4

NAME

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

SYNOPSIS

10       cc [ flag ... ] file ... -lxnet [ library ... ]
11       #include <netdb.h>
12
13       void endservent(void)
14
15
16       struct servent *getservbyname(const char *name, const char *proto);
17
18
19       struct servent *getservbyport(int port, const char *proto);
20
21
22       struct servent *getservent(void)
23
24
25       void setservent(int stayopen);
26
27

DESCRIPTION

29       The getservbyname(), getservbyport() and  getservent()  functions  each
30       return  a  pointer to a servent structure, the members of which contain
31       the fields of an entry in the network services database.
32
33
34       The getservent() function reads the next entry of the database, opening
35       a connection to the database if necessary.
36
37
38       The  getservbyname()  function searches the database from the beginning
39       and finds the first entry for which the service name specified by  name
40       matches  the  s_name  member  and  the protocol name specified by proto
41       matches the s_proto member, opening a connection  to  the  database  if
42       necessary.  If proto is a null pointer, any value of the s_proto member
43       will be matched.
44
45
46       The getservbyport() function searches the database from  the  beginning
47       and  finds the first entry for which the port specified by port matches
48       the s_port member and the protocol name specified by proto matches  the
49       s_proto  member, opening a connection to the database if necessary.  If
50       proto is a null pointer, any  value  of  the  s_proto  member  will  be
51       matched.  The port argument must be in network byte order.
52
53
54       The  setservent() function opens a connection to the database, and sets
55       the next entry to the first entry.  If the stayopen  argument  is  non-
56       zero,  the  net database will not be closed after each call to the get‐
57       servent() function, either directly, or indirectly through one  of  the
58       other getserv*() functions.
59
60
61       The endservent() function closes the database.
62

USAGE

64       The  port  argument  of getservbyport() need not be compatible with the
65       port values of all address families.
66
67
68       The getservent(), getservbyname()  and  getservbyport()  functions  may
69       return  pointers to static data, which may be overwritten by subsequent
70       calls to any of these functions.
71
72
73       These functions are generally used with the Internet address family.
74

RETURN VALUES

76       On successful completion, getservbyname(), getservbyport() and  getser‐
77       vent()  return  a pointer to a servent structure if the requested entry
78       was found, and a null pointer if the end of the database was reached or
79       the  requested  entry  was  not  found.   Otherwise,  a null pointer is
80       returned.
81

ERRORS

83       No errors are defined.
84

ATTRIBUTES

86       See attributes(5) for descriptions of the following attributes:
87
88
89
90
91       ┌─────────────────────────────┬─────────────────────────────┐
92       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
93       ├─────────────────────────────┼─────────────────────────────┤
94       │Interface Stability          │Standard                     │
95       ├─────────────────────────────┼─────────────────────────────┤
96       │MT-Level                     │MT-Safe                      │
97       └─────────────────────────────┴─────────────────────────────┘
98

SEE ALSO

100       endhostent(3XNET), endprotoent(3XNET), htonl(3XNET),  inet_addr(3XNET),
101       attributes(5), standards(5)
102
103
104
105SunOS 5.11                        14 Jun 2002                endservent(3XNET)
Impressum