Support Watt-32 under Win32.
[platform/upstream/c-ares.git] / ares_gethostbyname.3
1 .\" $Id$
2 .\"
3 .\" Copyright 1998 by the Massachusetts Institute of Technology.
4 .\"
5 .\" Permission to use, copy, modify, and distribute this
6 .\" software and its documentation for any purpose and without
7 .\" fee is hereby granted, provided that the above copyright
8 .\" notice appear in all copies and that both that copyright
9 .\" notice and this permission notice appear in supporting
10 .\" documentation, and that the name of M.I.T. not be used in
11 .\" advertising or publicity pertaining to distribution of the
12 .\" software without specific, written prior permission.
13 .\" M.I.T. makes no representations about the suitability of
14 .\" this software for any purpose.  It is provided "as is"
15 .\" without express or implied warranty.
16 .\"
17 .TH ARES_GETHOSTBYNAME 3 "25 July 1998"
18 .SH NAME
19 ares_gethostbyname \- Initiate a host query by name
20 .SH SYNOPSIS
21 .nf
22 .B #include <ares.h>
23 .PP
24 .B typedef void (*ares_host_callback)(void *\fIarg\fP, int \fIstatus\fP,
25 .B      int \fItimeouts\fP, struct hostent *\fIhostent\fP)
26 .PP
27 .B void ares_gethostbyname(ares_channel \fIchannel\fP, const char *\fIname\fP,
28 .B      int \fIfamily\fP, ares_host_callback \fIcallback\fP, void *\fIarg\fP)
29 .fi
30 .SH DESCRIPTION
31 The
32 .B ares_gethostbyname
33 function initiates a host query by name on the name service channel
34 identified by
35 .IR channel .
36 The parameter
37 .I name
38 gives the hostname as a NUL-terminated C string, and
39 .I family
40 gives the desired type of address for the resulting host entry.  When the
41 query is complete or has failed, the ares library will invoke \fIcallback\fP.
42 Completion or failure of the query may happen immediately, or may happen
43 during a later call to \fIares_process(3)\fP, \fIares_destroy(3)\fP or
44 \fIares_cancel(3)\fP.
45 .PP
46 The callback argument
47 .I arg
48 is copied from the
49 .B ares_gethostbyname
50 argument
51 .IR arg .
52 The callback argument
53 .I status
54 indicates whether the query succeeded and, if not, how it failed.  It
55 may have any of the following values:
56 .TP 19
57 .B ARES_SUCCESS
58 The host lookup completed successfully.
59 .TP 19
60 .B ARES_ENOTIMP
61 The ares library does not know how to find addresses of type
62 .IR family .
63 .TP 19
64 .B ARES_EBADNAME
65 The hostname
66 .B name
67 is composed entirely of numbers and periods, but is not a valid
68 representation of an Internet address.
69 .TP 19
70 .B ARES_ENOTFOUND
71 The address
72 .I addr
73 was not found.
74 .TP 19
75 .B ARES_ENOMEM
76 Memory was exhausted.
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 On successful completion of the query, the callback argument
89 .I hostent
90 points to a
91 .B struct hostent
92 containing the name of the host returned by the query.  The callback
93 need not and should not attempt to free the memory pointed to by
94 .IR hostent ;
95 the ares library will free it when the callback returns.  If the query
96 did not complete successfully,
97 .I hostent
98 will be
99 .BR NULL .
100 .SH SEE ALSO
101 .BR ares_process (3),
102 .BR ares_gethostbyaddr (3)
103 .SH AUTHOR
104 Greg Hudson, MIT Information Systems
105 .br
106 Copyright 1998 by the Massachusetts Institute of Technology.