blob: 7fb837188836a8fdec0be303bcb18aace27d036e [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001.\"
2.\" Copyright 1998 by the Massachusetts Institute of Technology.
3.\"
4.\" Permission to use, copy, modify, and distribute this
5.\" software and its documentation for any purpose and without
6.\" fee is hereby granted, provided that the above copyright
7.\" notice appear in all copies and that both that copyright
8.\" notice and this permission notice appear in supporting
9.\" documentation, and that the name of M.I.T. not be used in
10.\" advertising or publicity pertaining to distribution of the
11.\" software without specific, written prior permission.
12.\" M.I.T. makes no representations about the suitability of
13.\" this software for any purpose. It is provided "as is"
14.\" without express or implied warranty.
15.\"
16.TH ARES_PROCESS 3 "25 July 1998"
17.SH NAME
18ares_process \- Process events for name resolution
19.SH SYNOPSIS
20.nf
21.B #include <ares.h>
22.PP
23.B void ares_process(ares_channel \fIchannel\fP, fd_set *\fIread_fds\fP,
24.B fd_set *\fIwrite_fds\fP)
25.fi
26.PP
27.B void ares_process_fd(ares_channel \fIchannel\fP,
28.B ares_socket_t \fIread_fd\fP,
29.B ares_socket_t \fIwrite_fd\fP)
30.fi
31.SH DESCRIPTION
32The \fBares_process(3)\fP function handles input/output events and timeouts
33associated with queries pending on the name service channel identified by
34.IR channel .
35The file descriptor sets pointed to by \fIread_fds\fP and \fIwrite_fds\fP
36should have file descriptors set in them according to whether the file
37descriptors specified by \fIares_fds(3)\fP are ready for reading and writing.
38(The easiest way to determine this information is to invoke
39.B select
40with a timeout no greater than the timeout given by \fIares_timeout(3)\fP ).
41.PP
42The
43.B ares_process
44function will invoke callbacks for pending queries if they complete
45successfully or fail.
46
47\fBares_process_fd(3)\fP works the same way but acts and operates only on the
48specific file descriptors (sockets) you pass in to the function. Use
49ARES_SOCKET_BAD for "no action". This function is of course provided to allow
50users of c-ares to void select() in their applications and within c-ares.
51.SS EXAMPLE
52The following code fragment waits for all pending queries on a channel
53to complete:
54.PP
55.RS
56.nf
57int nfds, count;
58fd_set readers, writers;
59struct timeval tv, *tvp;
60
61while (1)
62 {
63 FD_ZERO(&readers);
64 FD_ZERO(&writers);
65 nfds = ares_fds(channel, &readers, &writers);
66 if (nfds == 0)
67 break;
68 tvp = ares_timeout(channel, NULL, &tv);
69 count = select(nfds, &readers, &writers, NULL, tvp);
70 ares_process(channel, &readers, &writers);
71 }
72.fi
73.RE
74.SH SEE ALSO
75.BR ares_fds (3),
76.BR ares_timeout (3)
77.SH AUTHOR
78Greg Hudson, MIT Information Systems
79.br
80Copyright 1998 by the Massachusetts Institute of Technology.