source: trunk/athena/lib/ares/ares_init.3 @ 19979

Revision 19979, 5.4 KB checked in by ghudson, 21 years ago (diff)
port seems to have been split into udp_port and tcp_port more recently than this was written; document the two separate fields.
Line 
1.\" $Id: ares_init.3,v 1.2 2003-11-05 19:36:22 ghudson Exp $
2.\"
3.\" Copyright 1998 by the Massachusetts Institute of Technology.
4.\"
5.\" Permission to use, copy, modify, and distribute this
6.\" software and its documentation for any purpose and without
7.\" fee is hereby granted, provided that the above copyright
8.\" notice appear in all copies and that both that copyright
9.\" notice and this permission notice appear in supporting
10.\" documentation, and that the name of M.I.T. not be used in
11.\" advertising or publicity pertaining to distribution of the
12.\" software without specific, written prior permission.
13.\" M.I.T. makes no representations about the suitability of
14.\" this software for any purpose.  It is provided "as is"
15.\" without express or implied warranty.
16.\"
17.TH ARES_INIT 3 "21 July 1998"
18.SH NAME
19ares_init, ares_init_options \- Initialize a resolver channel
20.SH SYNOPSIS
21.nf
22.B #include <ares.h>
23.PP
24.B int ares_init(ares_channel *\fIchannel\fP)
25.B int ares_init_options(ares_channel *\fIchannel\fP,
26.B      struct ares_options *\fIoptions\fP, int \fIoptmask\fP)
27.PP
28.B cc file.c -lares
29.fi
30.SH DESCRIPTION
31The
32.B ares_init
33function initializes a communications channel for name service
34lookups.  If it returns successfully,
35.B ares_init
36will set the variable pointed to by
37.I channel
38to a handle used to identify the name service channel.  The caller
39should invoke
40.BR ares_destroy (3)
41on the handle when the channel is no longer needed.
42.PP
43The
44.B ares_init_options
45function also initializes a name service channel, with additional
46options useful for applications requiring more control over name
47service configuration.  The
48.I optmask
49parameter specifies which fields in the structure pointed to by
50.I options
51are set, as follows:
52.PP
53.TP 19
54.B ARES_OPT_FLAGS
55.B int \fIflags\fP;
56.br
57Flags controlling the behavior of the resolver.  See below for a
58description of possible flag values.
59.TP 19
60.B ARES_OPT_TIMEOUT
61.B int \fItimeout\fP;
62.br
63The number of seconds each name server is given to respond to a query
64on the first try.  (After the first try, the timeout algorithm becomes
65more complicated, but scales linearly with the value of
66\fItimeout\fP.)  The default is five seconds.
67.TP 19
68.B ARES_OPT_TRIES
69.B int \fItries\fP;
70.br
71The number of tries the resolver will try contacting each name server
72before giving up.  The default is four tries.
73.TP 19
74.B ARES_OPT_NDOTS
75.B int \fIndots\fP;
76.br
77The number of dots which must be present in a domain name for it to be
78queried for "as is" prior to querying for it with the default domain
79extensions appended.  The default value is 1 unless set otherwise by
80resolv.conf or the RES_OPTIONS environment variable.
81.TP 19
82.B ARES_OPT_UDP_PORT
83.B unsigned short \fIudp_port\fP;
84.br
85The port to use for queries UDP queries, in network byte order.  The
86default value is 53 (in network byte order), the standard name service
87port.
88.TP 19
89.B ARES_TCP_PORT
90.B unsigned short \fItcp_port\fP;
91.br
92The port to use for TCP queries, in network byte order.  The default
93value is 53 (in network byte order), the standard name service port.
94.TP 19
95.B ARES_OPT_SERVERS
96.B struct in_addr *\fIservers\fP;
97.br
98.B int \fInservers\fP;
99.br
100The list of servers to contact, instead of the servers specified in
101resolv.conf or the local named.
102.TP 19
103.B ARES_OPT_DOMAINS
104.B char **\fIdomains\fP;
105.br
106.B int \fIndomains\fP;
107.br
108The domains to search, instead of the domains specified in resolv.conf
109or the domain derived from the kernel hostname variable.
110.TP 19
111.B ARES_OPT_LOOKUPS
112.B char *\fIlookups\fP;
113.br
114The lookups to perform for host queries. 
115.I lookups
116should be set to a string of the characters "b" or "f", where "b"
117indicates a DNS lookup and "f" indicates a lookup in the hosts file.
118.PP
119The
120.I flags
121field should be the bitwise or of some subset of the following values:
122.TP 23
123.B ARES_FLAG_USEVC
124Always use TCP queries (the "virtual circuit") instead of UDP
125queries.  Normally, TCP is only used if a UDP query yields a truncated
126result.
127.TP 23
128.B ARES_FLAG_PRIMARY
129Only query the first server in the list of servers to query.
130.TP 23
131.B ARES_FLAG_IGNTC
132If a truncated response to a UDP query is received, do not fall back
133to TCP; simply continue on with the truncated response.
134.TP 23
135.B ARES_FLAG_NORECURSE
136Do not set the "recursion desired" bit on outgoing queries, so that
137the name server being contacted will not try to fetch the answer from
138other servers if it doesn't know the answer locally.
139.TP 23
140.B ARES_FLAG_STAYOPEN
141Do not close communciations sockets when the number of active queries
142drops to zero.
143.TP 23
144.B ARES_FLAG_NOSEARCH
145Do not use the default search domains; only query hostnames as-is or
146as aliases.
147.TP 23
148.B ARES_FLAG_NOALIASES
149Do not honor the HOSTALIASES environment variable, which normally
150specifies a file of hostname translations.
151.TP 23
152.B ARES_FLAG_NOCHECKRESP
153Do not discard responses with the SERVFAIL, NOTIMP, or REFUSED
154response code or responses whose questions don't match the questions
155in the request.  Primarily useful for writing clients which might be
156used to test or debug name servers.
157.SH RETURN VALUES
158.I ares_init
159or
160.I ares_init_options
161can return any of the following values:
162.TP 14
163.B ARES_SUCCESS
164Initialization succeeded.
165.TP 14
166.B ARES_EFILE
167A configuration file could not be read.
168.TP 14
169.B ARES_ENOMEM
170The process's available memory was exhausted.
171.SH SEE ALSO
172.BR ares_destroy (3)
173.SH AUTHOR
174Greg Hudson, MIT Information Systems
175.br
176Copyright 1998 by the Massachusetts Institute of Technology.
Note: See TracBrowser for help on using the repository browser.