Blame ares_process.3

Packit 514978
.\"
Packit 514978
.\" Copyright 1998 by the Massachusetts Institute of Technology.
Packit 514978
.\"
Packit 514978
.\" Permission to use, copy, modify, and distribute this
Packit 514978
.\" software and its documentation for any purpose and without
Packit 514978
.\" fee is hereby granted, provided that the above copyright
Packit 514978
.\" notice appear in all copies and that both that copyright
Packit 514978
.\" notice and this permission notice appear in supporting
Packit 514978
.\" documentation, and that the name of M.I.T. not be used in
Packit 514978
.\" advertising or publicity pertaining to distribution of the
Packit 514978
.\" software without specific, written prior permission.
Packit 514978
.\" M.I.T. makes no representations about the suitability of
Packit 514978
.\" this software for any purpose.  It is provided "as is"
Packit 514978
.\" without express or implied warranty.
Packit 514978
.\"
Packit 514978
.TH ARES_PROCESS 3 "25 July 1998"
Packit 514978
.SH NAME
Packit 514978
ares_process \- Process events for name resolution
Packit 514978
.SH SYNOPSIS
Packit 514978
.nf
Packit 514978
#include <ares.h>
Packit 514978
Packit 514978
void ares_process(ares_channel \fIchannel\fP,
Packit 514978
                  fd_set *\fIread_fds\fP,
Packit 514978
                  fd_set *\fIwrite_fds\fP)
Packit 514978
Packit 514978
void ares_process_fd(ares_channel \fIchannel\fP,
Packit 514978
                     ares_socket_t \fIread_fd\fP,
Packit 514978
                     ares_socket_t \fIwrite_fd\fP)
Packit 514978
.fi
Packit 514978
.SH DESCRIPTION
Packit 514978
The \fBares_process(3)\fP function handles input/output events and timeouts
Packit 514978
associated with queries pending on the name service channel identified by
Packit 514978
.IR channel .
Packit 514978
The file descriptor sets pointed to by \fIread_fds\fP and \fIwrite_fds\fP
Packit 514978
should have file descriptors set in them according to whether the file
Packit 514978
descriptors specified by \fIares_fds(3)\fP are ready for reading and writing.
Packit 514978
(The easiest way to determine this information is to invoke \fBselect(3)\fP
Packit 514978
with a timeout no greater than the timeout given by \fIares_timeout(3)\fP).
Packit 514978
Packit 514978
The \fBares_process(3)\fP function will invoke callbacks for pending queries
Packit 514978
if they complete successfully or fail.
Packit 514978
Packit 514978
\fBares_process_fd(3)\fP works the same way but acts and operates only on the
Packit 514978
specific file descriptors (sockets) you pass in to the function. Use
Packit 514978
ARES_SOCKET_BAD for "no action". This function is provided to allow users of
Packit 514978
c-ares to void \fIselect(3)\fP in their applications and within c-ares.
Packit 514978
.SH EXAMPLE
Packit 514978
The following code fragment waits for all pending queries on a channel
Packit 514978
to complete:
Packit 514978
Packit 514978
.nf
Packit 514978
int nfds, count;
Packit 514978
fd_set readers, writers;
Packit 514978
struct timeval tv, *tvp;
Packit 514978
Packit 514978
while (1) {
Packit 514978
  FD_ZERO(&readers);
Packit 514978
  FD_ZERO(&writers);
Packit 514978
  nfds = ares_fds(channel, &readers, &writers);
Packit 514978
  if (nfds == 0)
Packit 514978
    break;
Packit 514978
  tvp = ares_timeout(channel, NULL, &tv;;
Packit 514978
  count = select(nfds, &readers, &writers, NULL, tvp);
Packit 514978
  ares_process(channel, &readers, &writers);
Packit 514978
}
Packit 514978
.fi
Packit 514978
.SH SEE ALSO
Packit 514978
.BR ares_fds (3),
Packit 514978
.BR ares_timeout (3)
Packit 514978
.SH AUTHOR
Packit 514978
Greg Hudson, MIT Information Systems
Packit 514978
.br
Packit 514978
Copyright 1998 by the Massachusetts Institute of Technology.