Make the query callbacks return the number of timeouts that happened during the execu...
[platform/upstream/c-ares.git] / ares_send.3
1 .\" $Id$
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_SEND 3 "25 July 1998"
18 .SH NAME
19 ares_send \- Initiate a DNS query
20 .SH SYNOPSIS
21 .nf
22 .B #include <ares.h>
23 .PP
24 .B typedef void (*ares_callback)(void *\fIarg\fP, int \fIstatus\fP,
25 .B      int \fItimeouts\fP, unsigned char *\fIabuf\fP, int \fIalen\fP)
26 .PP
27 .B void ares_send(ares_channel \fIchannel\fP, const unsigned char *\fIqbuf\fP,
28 .B      int \fIqlen\fP, ares_callback \fIcallback\fP, void *\fIarg\fP)
29 .fi
30 .SH DESCRIPTION
31 The
32 .B ares_send
33 function initiates a DNS query on the name service channel identified
34 by
35 .IR channel .
36 The parameters
37 .I qbuf
38 and
39 .I qlen
40 give the DNS query, which should already have been formatted according
41 to the DNS protocol.  When the query is complete or has failed, the
42 ares library will invoke
43 .IR callback .
44 Completion or failure of the query may happen immediately, or may
45 happen during a later call to
46 .BR ares_process (3)
47 or
48 .BR ares_destroy (3).
49 .PP
50 The callback argument
51 .I arg
52 is copied from the
53 .B ares_send
54 argument
55 .IR arg .
56 The callback argument
57 .I status
58 indicates whether the query succeeded and, if not, how it failed.  It
59 may have any of the following values:
60 .TP 19
61 .B ARES_SUCCESS
62 The query completed.
63 .TP 19
64 .B ARES_EBADQUERY
65 The query buffer was poorly formed (was not long enough for a DNS
66 header or was too long for TCP transmission).
67 .TP 19
68 .B ARES_ETIMEOUT
69 No name servers responded within the timeout period.
70 .TP 19
71 .B ARES_ECONNREFUSED
72 No name servers could be contacted.
73 .TP 19
74 .B ARES_ENOMEM
75 Memory was exhausted.
76 .TP 19
77 .B ARES_EDESTRUCTION
78 The name service channel
79 .I channel
80 is being destroyed; the query will not be completed.
81 .PP
82 The callback argument
83 .I timeouts
84 reports how many times a query timed out during the execution of the
85 given request.
86 .PP
87 If the query completed, the callback argument
88 .I abuf
89 points to a result buffer of length
90 .IR alen .
91 If the query did not complete,
92 .I abuf
93 will be NULL and
94 .I alen
95 will be 0.
96 .PP
97 Unless the flag
98 .B ARES_FLAG_NOCHECKRESP
99 was set at channel initialization time,
100 .B ares_send
101 will normally ignore responses whose questions do not match the
102 questions in
103 .IR qbuf ,
104 as well as responses with reply codes of
105 .BR SERVFAIL ,
106 .BR NOTIMP ,
107 and
108 .BR REFUSED .
109 Unlike other query functions in the ares library, however,
110 .B ares_send
111 does not inspect the header of the reply packet to determine the error
112 status, so a callback status of
113 .B ARES_SUCCESS
114 does not reflect as much about the response as for other query
115 functions.
116 .SH SEE ALSO
117 .BR ares_process (3)
118 .SH AUTHOR
119 Greg Hudson, MIT Information Systems
120 .br
121 Copyright 1998 by the Massachusetts Institute of Technology.