ares_send.3 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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_SEND 3 "25 July 1998"
  17. .SH NAME
  18. ares_send \- Initiate a DNS query
  19. .SH SYNOPSIS
  20. .nf
  21. #include <ares.h>
  22. typedef void (*ares_callback)(void *\fIarg\fP, int \fIstatus\fP,
  23. int \fItimeouts\fP, unsigned char *\fIabuf\fP,
  24. int \fIalen\fP)
  25. void ares_send(ares_channel \fIchannel\fP, const unsigned char *\fIqbuf\fP,
  26. int \fIqlen\fP, ares_callback \fIcallback\fP, void *\fIarg\fP)
  27. .fi
  28. .SH DESCRIPTION
  29. The
  30. .B ares_send
  31. function initiates a DNS query on the name service channel identified
  32. by
  33. .IR channel .
  34. The parameters
  35. .I qbuf
  36. and
  37. .I qlen
  38. give the DNS query, which should already have been formatted according
  39. to the DNS protocol. When the query is complete or has failed, the
  40. ares library will invoke
  41. .IR callback .
  42. Completion or failure of the query may happen immediately, or may
  43. happen during a later call to
  44. .BR ares_process (3)
  45. or
  46. .BR ares_destroy (3).
  47. .PP
  48. The callback argument
  49. .I arg
  50. is copied from the
  51. .B ares_send
  52. argument
  53. .IR arg .
  54. The callback argument
  55. .I status
  56. indicates whether the query succeeded and, if not, how it failed. It
  57. may have any of the following values:
  58. .TP 19
  59. .B ARES_SUCCESS
  60. The query completed.
  61. .TP 19
  62. .B ARES_EBADQUERY
  63. The query buffer was poorly formed (was not long enough for a DNS
  64. header or was too long for TCP transmission).
  65. .TP 19
  66. .B ARES_ETIMEOUT
  67. No name servers responded within the timeout period.
  68. .TP 19
  69. .B ARES_ECONNREFUSED
  70. No name servers could be contacted.
  71. .TP 19
  72. .B ARES_ENOMEM
  73. Memory was exhausted.
  74. .TP 19
  75. .B ARES_ECANCELLED
  76. The query was cancelled.
  77. .TP 19
  78. .B ARES_EDESTRUCTION
  79. The name service channel
  80. .I channel
  81. is being destroyed; the query will not be completed.
  82. .PP
  83. The callback argument
  84. .I timeouts
  85. reports how many times a query timed out during the execution of the
  86. given request.
  87. .PP
  88. If the query completed, the callback argument
  89. .I abuf
  90. points to a result buffer of length
  91. .IR alen .
  92. If the query did not complete,
  93. .I abuf
  94. will be NULL and
  95. .I alen
  96. will be 0.
  97. .PP
  98. Unless the flag
  99. .B ARES_FLAG_NOCHECKRESP
  100. was set at channel initialization time,
  101. .B ares_send
  102. will normally ignore responses whose questions do not match the
  103. questions in
  104. .IR qbuf ,
  105. as well as responses with reply codes of
  106. .BR SERVFAIL ,
  107. .BR NOTIMP ,
  108. and
  109. .BR REFUSED .
  110. Unlike other query functions in the ares library, however,
  111. .B ares_send
  112. does not inspect the header of the reply packet to determine the error
  113. status, so a callback status of
  114. .B ARES_SUCCESS
  115. does not reflect as much about the response as for other query
  116. functions.
  117. .SH SEE ALSO
  118. .BR ares_process (3)
  119. .SH AUTHOR
  120. Greg Hudson, MIT Information Systems
  121. .br
  122. Copyright 1998 by the Massachusetts Institute of Technology.