Support Watt-32 under Win32.
[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 .PP
28 .B void ares_process_fd(ares_channel \fIchannel\fP,
29 .B      ares_socket_t \fIread_fd\fP,
30 .B      ares_socket_t \fIwrite_fd\fP)
31 .fi
32 .SH DESCRIPTION
33 The \fBares_process(3)\fP function handles input/output events and timeouts
34 associated with queries pending on the name service channel identified by
35 .IR channel .
36 The file descriptor sets pointed to by \fIread_fds\fP and \fIwrite_fds\fP
37 should have file descriptors set in them according to whether the file
38 descriptors specified by \fIares_fds(3)\fP are ready for reading and writing.
39 (The easiest way to determine this information is to invoke
40 .B select
41 with a timeout no greater than the timeout given by \fIares_timeout(3)\fP ).
42 .PP
43 The
44 .B ares_process
45 function will invoke callbacks for pending queries if they complete
46 successfully or fail.
47
48 \fBares_process_fd(3)\fP works the same way but acts and operates only on the
49 specific file descriptors (sockets) you pass in to the function. Use
50 ARES_SOCKET_BAD for "no action". This function is of course provided to allow
51 users of c-ares to void select() in their applications and within c-ares.
52 .SS EXAMPLE
53 The following code fragment waits for all pending queries on a channel
54 to complete:
55 .PP
56 .RS
57 .nf
58 int nfds, count;
59 fd_set readers, writers;
60 struct timeval tv, *tvp;
61
62 while (1)
63   {
64     FD_ZERO(&readers);
65     FD_ZERO(&writers);
66     nfds = ares_fds(channel, &readers, &writers);
67     if (nfds == 0)
68       break;
69     tvp = ares_timeout(channel, NULL, &tv);
70     count = select(nfds, &readers, &writers, NULL, tvp);
71     ares_process(channel, &readers, &writers);
72   }
73 .fi
74 .RE
75 .SH SEE ALSO
76 .BR ares_fds (3),
77 .BR ares_timeout (3)
78 .SH AUTHOR
79 Greg Hudson, MIT Information Systems
80 .br
81 Copyright 1998 by the Massachusetts Institute of Technology.