1GETSERVENT(3N)                                                  GETSERVENT(3N)
2
3
4

NAME

6       getservent,  getservbyport, getservbyname, setservent, endservent - get
7       service entry
8

SYNOPSIS

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

DESCRIPTION

26       Getservent, getservbyname, and getservbyport each return a  pointer  to
27       an object with the following structure containing the broken-out fields
28       of a line in the network services data base, /etc/services.
29
30              struct    servent {
31                   char *s_name;  /* official name of service */
32                   char **s_aliases;   /* alias list */
33                   int  s_port;        /* port service resides at */
34                   char *s_proto; /* protocol to use */
35              };
36
37       The members of this structure are:
38
39       s_name     The official name of the service.
40
41       s_aliases  A zero terminated list of alternate names for the service.
42
43       s_port     The port number at which the service resides.  Port  numbers
44                  are returned in network byte order.
45
46       s_proto    The name of the protocol to use when contacting the service.
47
48       Getservent  reads the next line of the file, opening the file if neces‐
49       sary.
50
51       Setservent opens and rewinds the file.  If the stayopen  flag  is  non-
52       zero,  the  net  data  base  will not be closed after each call to get‐
53       servbyname or .IR getservbyport .
54
55       Endservent closes the file.
56
57       Getservbyname and getservbyport sequentially search from the  beginning
58       of  the file until a matching protocol name or port number is found, or
59       until EOF is encountered.  If a protocol name is  also  supplied  (non-
60       NULL), searches must also match the protocol.
61

FILES

63       /etc/services
64

SEE ALSO

66       getprotoent(3N), services(5)
67

DIAGNOSTICS

69       Null pointer (0) returned on EOF or error.
70

BUGS

72       All  information  is contained in a static area so it must be copied if
73       it is to be saved.  Expecting port numbers to fit in a 32 bit  quantity
74       is probably naive.
75
76
77
784.2 Berkeley Distribution        May 19, 1986                   GETSERVENT(3N)
Impressum