lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 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_GETHOSTBYNAME 3 "25 July 1998" |
| 17 | .SH NAME |
| 18 | ares_gethostbyname \- Initiate a host query by name |
| 19 | .SH SYNOPSIS |
| 20 | .nf |
| 21 | .B #include <ares.h> |
| 22 | .PP |
| 23 | .B typedef void (*ares_host_callback)(void *\fIarg\fP, int \fIstatus\fP, |
| 24 | .B int \fItimeouts\fP, struct hostent *\fIhostent\fP) |
| 25 | .PP |
| 26 | .B void ares_gethostbyname(ares_channel \fIchannel\fP, const char *\fIname\fP, |
| 27 | .B int \fIfamily\fP, ares_host_callback \fIcallback\fP, void *\fIarg\fP) |
| 28 | .fi |
| 29 | .SH DESCRIPTION |
| 30 | The |
| 31 | .B ares_gethostbyname |
| 32 | function initiates a host query by name on the name service channel |
| 33 | identified by |
| 34 | .IR channel . |
| 35 | The parameter |
| 36 | .I name |
| 37 | gives the hostname as a NUL-terminated C string, and |
| 38 | .I family |
| 39 | gives the desired type of address for the resulting host entry. When the |
| 40 | query is complete or has failed, the ares library will invoke \fIcallback\fP. |
| 41 | Completion or failure of the query may happen immediately, or may happen |
| 42 | during a later call to \fIares_process(3)\fP, \fIares_destroy(3)\fP or |
| 43 | \fIares_cancel(3)\fP. |
| 44 | .PP |
| 45 | The callback argument |
| 46 | .I arg |
| 47 | is copied from the |
| 48 | .B ares_gethostbyname |
| 49 | argument |
| 50 | .IR arg . |
| 51 | The callback argument |
| 52 | .I status |
| 53 | indicates whether the query succeeded and, if not, how it failed. It |
| 54 | may have any of the following values: |
| 55 | .TP 19 |
| 56 | .B ARES_SUCCESS |
| 57 | The host lookup completed successfully. |
| 58 | .TP 19 |
| 59 | .B ARES_ENOTIMP |
| 60 | The ares library does not know how to find addresses of type |
| 61 | .IR family . |
| 62 | .TP 19 |
| 63 | .B ARES_EBADNAME |
| 64 | The hostname |
| 65 | .B name |
| 66 | is composed entirely of numbers and periods, but is not a valid |
| 67 | representation of an Internet address. |
| 68 | .TP 19 |
| 69 | .B ARES_ENOTFOUND |
| 70 | The address |
| 71 | .I addr |
| 72 | was not found. |
| 73 | .TP 19 |
| 74 | .B ARES_ENOMEM |
| 75 | Memory was exhausted. |
| 76 | .TP 19 |
| 77 | .B ARES_ECANCELLED |
| 78 | The query was cancelled. |
| 79 | .TP 19 |
| 80 | .B ARES_EDESTRUCTION |
| 81 | The name service channel |
| 82 | .I channel |
| 83 | is being destroyed; the query will not be completed. |
| 84 | .PP |
| 85 | The callback argument |
| 86 | .I timeouts |
| 87 | reports how many times a query timed out during the execution of the |
| 88 | given request. |
| 89 | .PP |
| 90 | On successful completion of the query, the callback argument |
| 91 | .I hostent |
| 92 | points to a |
| 93 | .B struct hostent |
| 94 | containing the name of the host returned by the query. The callback |
| 95 | need not and should not attempt to free the memory pointed to by |
| 96 | .IR hostent ; |
| 97 | the ares library will free it when the callback returns. If the query |
| 98 | did not complete successfully, |
| 99 | .I hostent |
| 100 | will be |
| 101 | .BR NULL . |
| 102 | .SH SEE ALSO |
| 103 | .BR ares_process (3), |
| 104 | .BR ares_gethostbyaddr (3) |
| 105 | .SH AUTHOR |
| 106 | Greg Hudson, MIT Information Systems |
| 107 | .br |
| 108 | Copyright 1998 by the Massachusetts Institute of Technology. |