date and time created 91/03/07 10:23:53 by bostic
[unix-history] / usr / src / lib / libc / net / getservent.3
CommitLineData
56e6bd55
KB
1.\" Copyright (c) 1983 The Regents of the University of California.
2.\" All rights reserved.
ed06f32e 3.\"
91cff1e1 4.\" %sccs.include.redist.man%
ed06f32e 5.\"
91cff1e1 6.\" @(#)getservent.3 6.5 (Berkeley) %G%
56e6bd55
KB
7.\"
8.TH GETSERVENT 3 ""
ed06f32e
KM
9.UC 5
10.SH NAME
56e6bd55
KB
11getservent, getservbyport, getservbyname, setservent,
12endservent \- get service entry
ed06f32e
KM
13.SH SYNOPSIS
14.nf
15.ft B
16#include <netdb.h>
17.PP
18.ft B
19struct servent *getservent()
20.PP
21.ft B
22struct servent *getservbyname(name, proto)
23char *name, *proto;
24.PP
25.ft B
26struct servent *getservbyport(port, proto)
27int port; char *proto;
28.PP
29.ft B
30setservent(stayopen)
31int stayopen
32.PP
33.ft B
34endservent()
35.fi
36.SH DESCRIPTION
37.IR Getservent ,
38.IR getservbyname ,
39and
40.I getservbyport
41each return a pointer to an object with the
42following structure
43containing the broken-out
44fields of a line in the network services data base,
45.IR /etc/services .
46.RS
47.PP
48.nf
49struct servent {
50 char *s_name; /* official name of service */
51 char **s_aliases; /* alias list */
50159ed7 52 int s_port; /* port service resides at */
ed06f32e
KM
53 char *s_proto; /* protocol to use */
54};
55.ft R
56.ad
57.fi
58.RE
59.PP
60The members of this structure are:
61.TP \w's_aliases'u+2n
62s_name
63The official name of the service.
64.TP \w's_aliases'u+2n
65s_aliases
66A zero terminated list of alternate names for the service.
67.TP \w's_aliases'u+2n
68s_port
69The port number at which the service resides.
70Port numbers are returned in network byte order.
71.TP \w's_aliases'u+2n
72s_proto
73The name of the protocol to use when contacting the
74service.
75.PP
76.I Getservent
77reads the next line of the file, opening the file if necessary.
78.PP
79.I Setservent
80opens and rewinds the file. If the
81.I stayopen
82flag is non-zero,
83the net data base will not be closed after each call to
ec178508
JL
84.I getservbyname
85or .IR getservbyport .
ed06f32e
KM
86.PP
87.I Endservent
88closes the file.
89.PP
90.I Getservbyname
91and
92.I getservbyport
93sequentially search from the beginning
94of the file until a matching
95protocol name or
96port number is found,
97or until EOF is encountered.
98If a protocol name is also supplied (non-NULL),
99searches must also match the protocol.
100.SH FILES
101/etc/services
102.SH "SEE ALSO"
56e6bd55 103getprotoent(3), services(5)
ed06f32e
KM
104.SH DIAGNOSTICS
105Null pointer
106(0) returned on EOF or error.
107.SH BUGS
108All information
109is contained in a static area
110so it must be copied if it is
111to be saved. Expecting port
112numbers to fit in a 32 bit
113quantity is probably naive.