1ARES_PROCESS(3) Library Functions Manual ARES_PROCESS(3)
2
3
4
6 ares_process - Process events for name resolution
7
9 #include <ares.h>
10
11 void ares_process(ares_channel channel, fd_set *read_fds,
12 fd_set *write_fds)
13
14 void ares_process_fd(ares_channel channel, ares_socket_t read_fd,
15 ares_socket_t write_fd)
16
18 The ares_process(3) function handles input/output events and timeouts
19 associated with queries pending on the name service channel identified
20 by channel. The file descriptor sets pointed to by read_fds and
21 write_fds should have file descriptors set in them according to whether
22 the file descriptors specified by ares_fds(3) are ready for reading and
23 writing. (The easiest way to determine this information is to invoke
24 select with a timeout no greater than the timeout given by ares_time‐
25 out(3) ).
26
27 The ares_process function will invoke callbacks for pending queries if
28 they complete successfully or fail.
29
30 ares_process_fd(3) works the same way but acts and operates only on the
31 specific file descriptors (sockets) you pass in to the function. Use
32 ARES_SOCKET_BAD for "no action". This function is of course provided to
33 allow users of c-ares to void select() in their applications and within
34 c-ares.
35
36 EXAMPLE
37 The following code fragment waits for all pending queries on a channel
38 to complete:
39
40 int nfds, count;
41 fd_set readers, writers;
42 struct timeval tv, *tvp;
43
44 while (1)
45 {
46 FD_ZERO(&readers);
47 FD_ZERO(&writers);
48 nfds = ares_fds(channel, &readers, &writers);
49 if (nfds == 0)
50 break;
51 tvp = ares_timeout(channel, NULL, &tv);
52 count = select(nfds, &readers, &writers, NULL, tvp);
53 ares_process(channel, &readers, &writers);
54 }
55
57 ares_fds(3), ares_timeout(3)
58
60 Greg Hudson, MIT Information Systems
61 Copyright 1998 by the Massachusetts Institute of Technology.
62
63
64
65 25 July 1998 ARES_PROCESS(3)