ares 1.1.1 with collected applied patches
[platform/upstream/c-ares.git] / ares_process.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_PROCESS 3 "25 July 1998"
18 .SH NAME
19 ares_process \- Process events for name resolution
20 .SH SYNOPSIS
21 .nf
22 .B #include <ares.h>
23 .PP
24 .B void ares_process(ares_channel \fIchannel\fP, fd_set *\fIread_fds\fP,
25 .B      fd_set *\fIwrite_fds\fP)
26 .fi
27 .SH DESCRIPTION
28 The
29 .B ares_process
30 function handles input/output events and timeouts associated with
31 queries pending on the name service channel identified by
32 .IR channel .
33 The file descriptor sets pointed to by
34 .I read_fds
35 and
36 .I write_fds
37 should have file descriptors set in them according to whether the file
38 descriptors specified by
39 .BR ares_fds (3)
40 are ready for reading and writing.  (The easiest way to determine this
41 information is to invoke
42 .B select
43 with a timeout no greater than the timeout given by
44 .BR ares_timeout (3)).
45 .PP
46 The
47 .B ares_process
48 function will invoke callbacks for pending queries if they complete
49 successfully or fail.
50 .SS EXAMPLE
51 The following code fragment waits for all pending queries on a channel
52 to complete:
53 .PP
54 .RS
55 .nf
56 int nfds, count;
57 fd_set readers, writers;
58 struct timeval tv, *tvp;
59
60 while (1)
61   {
62     FD_ZERO(&readers);
63     FD_ZERO(&writers);
64     nfds = ares_fds(channel, &readers, &writers);
65     if (nfds == 0)
66       break;
67     tvp = ares_timeout(channel, NULL, &tv);
68     count = select(nfds, &readers, &writers, NULL, tvp);
69     ares_process(channel, &readers, &writers);
70   }
71 .fi
72 .RE
73 .SH SEE ALSO
74 .BR ares_fds (3),
75 .BR ares_timeout (3)
76 .SH AUTHOR
77 Greg Hudson, MIT Information Systems
78 .br
79 Copyright 1998 by the Massachusetts Institute of Technology.