ares_process.3 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. .\"
  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
  18. ares_process \- Process events for name resolution
  19. .SH SYNOPSIS
  20. .nf
  21. #include <ares.h>
  22. void ares_process(ares_channel \fIchannel\fP,
  23. fd_set *\fIread_fds\fP,
  24. fd_set *\fIwrite_fds\fP)
  25. void ares_process_fd(ares_channel \fIchannel\fP,
  26. ares_socket_t \fIread_fd\fP,
  27. ares_socket_t \fIwrite_fd\fP)
  28. .fi
  29. .SH DESCRIPTION
  30. The \fBares_process(3)\fP function handles input/output events and timeouts
  31. associated with queries pending on the name service channel identified by
  32. .IR channel .
  33. The file descriptor sets pointed to by \fIread_fds\fP and \fIwrite_fds\fP
  34. should have file descriptors set in them according to whether the file
  35. descriptors specified by \fIares_fds(3)\fP are ready for reading and writing.
  36. (The easiest way to determine this information is to invoke \fBselect(3)\fP
  37. with a timeout no greater than the timeout given by \fIares_timeout(3)\fP).
  38. The \fBares_process(3)\fP function will invoke callbacks for pending queries
  39. if they complete successfully or fail.
  40. \fBares_process_fd(3)\fP works the same way but acts and operates only on the
  41. specific file descriptors (sockets) you pass in to the function. Use
  42. ARES_SOCKET_BAD for "no action". This function is provided to allow users of
  43. c-ares to avoid \fIselect(3)\fP in their applications and within c-ares.
  44. To only process possible timeout conditions without a socket event occurring,
  45. one may pass NULL as the values for both \fIread_fds\fP and \fIwrite_fds\fP for
  46. \fBares_process(3)\fP, or ARES_SOCKET_BAD for both \fIread_fd\fP and
  47. \fIwrite_fd\fP for \fBares_process_fd(3)\fP.
  48. .SH EXAMPLE
  49. The following code fragment waits for all pending queries on a channel
  50. to complete:
  51. .nf
  52. int nfds, count;
  53. fd_set readers, writers;
  54. struct timeval tv, *tvp;
  55. while (1) {
  56. FD_ZERO(&readers);
  57. FD_ZERO(&writers);
  58. nfds = ares_fds(channel, &readers, &writers);
  59. if (nfds == 0)
  60. break;
  61. tvp = ares_timeout(channel, NULL, &tv);
  62. count = select(nfds, &readers, &writers, NULL, tvp);
  63. ares_process(channel, &readers, &writers);
  64. }
  65. .fi
  66. .SH SEE ALSO
  67. .BR ares_fds (3),
  68. .BR ares_timeout (3)
  69. .SH AUTHOR
  70. Greg Hudson, MIT Information Systems
  71. .br
  72. Copyright 1998 by the Massachusetts Institute of Technology.