3 .\" Copyright 1998 by the Massachusetts Institute of Technology.
4 .\" Copyright (C) 2004-2009 by Daniel Stenberg
6 .\" Permission to use, copy, modify, and distribute this
7 .\" software and its documentation for any purpose and without
8 .\" fee is hereby granted, provided that the above copyright
9 .\" notice appear in all copies and that both that copyright
10 .\" notice and this permission notice appear in supporting
11 .\" documentation, and that the name of M.I.T. not be used in
12 .\" advertising or publicity pertaining to distribution of the
13 .\" software without specific, written prior permission.
14 .\" M.I.T. makes no representations about the suitability of
15 .\" this software for any purpose. It is provided "as is"
16 .\" without express or implied warranty.
18 .TH ARES_INIT 3 "26 May 2009"
20 ares_init, ares_init_options \- Initialize a resolver channel
25 .B int ares_init(ares_channel *\fIchannel\fP)
26 .B int ares_init_options(ares_channel *\fIchannel\fP,
27 .B struct ares_options *\fIoptions\fP, int \fIoptmask\fP)
32 The \fBares_init\fP function initializes a communications channel for name
33 service lookups. If it returns successfully, \fBares_init\fP will set the
34 variable pointed to by \fIchannel\fP to a handle used to identify the name
35 service channel. The caller should invoke
37 on the handle when the channel is no longer needed.
39 The \fBares_init_options\fP function also initializes a name service channel,
40 with additional options useful for applications requiring more control over
41 name service configuration. The \fIoptmask\fP parameter specifies which fields
42 in the structure pointed to by \fIoptions\fP are set, as follows:
47 Flags controlling the behavior of the resolver. See below for a
48 description of possible flag values.
53 The number of seconds each name server is given to respond to a query on the
54 first try. (After the first try, the timeout algorithm becomes more
55 complicated, but scales linearly with the value of \fItimeout\fP.) The
56 default is five seconds. This option is being deprecated by
57 \fIARES_OPT_TIMEOUTMS\fP starting in c-ares 1.5.2.
62 The number of milliseconds each name server is given to respond to a query on
63 the first try. (After the first try, the timeout algorithm becomes more
64 complicated, but scales linearly with the value of \fItimeout\fP.) The
65 default is five seconds. Note that this option is specified with the same
66 struct field as the former \fIARES_OPT_TIMEOUT\fP, it is but the option bits
67 that tell c-ares how to interpret the number. This option was added in c-ares
73 The number of tries the resolver will try contacting each name server
74 before giving up. The default is four tries.
79 The number of dots which must be present in a domain name for it to be
80 queried for "as is" prior to querying for it with the default domain
81 extensions appended. The default value is 1 unless set otherwise by
82 resolv.conf or the RES_OPTIONS environment variable.
85 .B unsigned short \fIport\fP;
87 The port to use for queries (both TCP and UDP), in network byte order.
88 The default value is 53 (in network byte order), the standard name
92 .B struct in_addr *\fIservers\fP;
94 .B int \fInservers\fP;
96 The list of servers to contact, instead of the servers specified in
97 resolv.conf or the local named.
100 .B char **\fIdomains\fP;
102 .B int \fIndomains\fP;
104 The domains to search, instead of the domains specified in resolv.conf
105 or the domain derived from the kernel hostname variable.
108 .B char *\fIlookups\fP;
110 The lookups to perform for host queries.
112 should be set to a string of the characters "b" or "f", where "b"
113 indicates a DNS lookup and "f" indicates a lookup in the hosts file.
115 .B ARES_OPT_SOCK_STATE_CB
116 .B void (*\fIsock_state_cb\fP)(void *data, int s, int read, int write);
118 .B void *\fIsock_state_cb_data\fP;
120 A callback function to be invoked when a socket changes state.
122 will be passed the socket whose state has changed;
124 will be set to true if the socket should listen for read events, and
126 will be set to true if the socket should listen for write events.
128 .I sock_state_cb_data
129 will be passed as the
135 field should be the bitwise or of some subset of the following values:
138 Always use TCP queries (the "virtual circuit") instead of UDP
139 queries. Normally, TCP is only used if a UDP query yields a truncated
143 Only query the first server in the list of servers to query.
146 If a truncated response to a UDP query is received, do not fall back
147 to TCP; simply continue on with the truncated response.
149 .B ARES_FLAG_NORECURSE
150 Do not set the "recursion desired" bit on outgoing queries, so that the name
151 server being contacted will not try to fetch the answer from other servers if
152 it doesn't know the answer locally. Be aware that ares will not do the
153 recursion for you. Recursion must be handled by the application calling ares
154 if \fIARES_FLAG_NORECURSE\fP is set.
156 .B ARES_FLAG_STAYOPEN
157 Do not close communications sockets when the number of active queries
160 .B ARES_FLAG_NOSEARCH
161 Do not use the default search domains; only query hostnames as-is or
164 .B ARES_FLAG_NOALIASES
165 Do not honor the HOSTALIASES environment variable, which normally
166 specifies a file of hostname translations.
168 .B ARES_FLAG_NOCHECKRESP
169 Do not discard responses with the SERVFAIL, NOTIMP, or REFUSED
170 response code or responses whose questions don't match the questions
171 in the request. Primarily useful for writing clients which might be
172 used to test or debug name servers.
177 can return any of the following values:
180 Initialization succeeded.
183 A configuration file could not be read.
186 The process's available memory was exhausted.
188 .B ARES_ENOTINITIALIZED
189 c-ares library initialization not yet performed.
193 .BR ares_library_init(3)
195 Greg Hudson, MIT Information Systems
197 Copyright 1998 by the Massachusetts Institute of Technology.
199 Copyright (C) 2004-2009 by Daniel Stenberg.