@comment The start of a comment is indicated by the following comment. This @comment syntax is used by the script funcstxh.sh: @comment function @comment function res_query @node res_query, resolver @findex res_query @c This file was originally a Linux man page - see the copyright below. It @c was modified for use in libsocket by Richard Dawe . @c Copyright 1993 David Metcalfe (david@prism.demon.co.uk) @c @c Permission is granted to make and distribute verbatim copies of this @c manual provided the copyright notice and this permission notice are @c preserved on all copies. @c @c Permission is granted to copy and distribute modified versions of this @c manual under the conditions for verbatim copying, provided that the @c entire resulting derived work is distributed under the terms of a @c permission notice identical to this one @c @c Since the Linux kernel and libraries are constantly changing, this @c manual page may be incorrect or out-of-date. The author(s) assume no @c responsibility for errors or omissions, or for damages resulting from @c the use of the information contained herein. The author(s) may not @c have taken the same level of care in the production of this manual, @c which is licensed free of charge, as they might when working @c professionally. @c @c Formatted or processed versions of this manual, if unaccompanied by @c the source, must acknowledge the copyright and authors of this work. @c @c References consulted: @c Linux libc source code @c Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) @c 386BSD man pages @c Modified Sun Jul 25 11:01:53 1993 by Rik Faith (faith@cs.unc.edu) @example #include #include #include extern struct state _res; int res_query (const char *dname, int class, int type, unsigned char *answer, int anslen); @end example @subheading Description The @code{res_query()} function queries the name server for the fully-qualified domain name @var{name} of specified @var{type} and @var{class}. The reply is left in the buffer @var{answer} of length @var{anslen} supplied by the caller. The resolver routines use global configuration and state information contained in the structure @samp{_res}, which is defined in @samp{}. The only field that is normally manipulated by the user is @samp{_res.options}. This field can contain the bitwise OR of the following options: @vtable @samp @item RES_INIT True if @code{res_init()} has been called. @item RES_DEBUG Print debugging messages. @item RES_AAONLY Accept authoritative answers only. @code{res_send()} continues until it fins an authoritative answer or returns an error. [Not currently implemented]. @item RES_USEVC Use TCP connections for queries rather than UDP datagrams. @item RES_PRIMARY Query primary domain name server only. @item RES_IGNTC Ignore truncation errors. Don't retry with TCP. [Not currently implemented]. @item RES_RECURSE Set the recursion desired bit in queries. Recursion is carried out by the domain name server, not by @code{res_send()}. [Enabled by default]. @item RES_DEFNAMES If set, @code{res_search()} will append the default domain name to single component names, ie. those that do not contain a dot. [Enabled by default]. @item RES_STAYOPEN Used with RES_USEVC to keep the TCP connection open between queries. @item RES_DNSRCH If set, @code{res_search()} will search for host names in the current domain and in parent domains. This option is used by @code{gethostbyname()} (@pxref{gethostbyname}). [Enabled by default]. @end vtable @subheading Return Value @code{res_query()} returns the length of the response, or -1 if an error occurs. @subheading Portability This function is not portable. It is taken from Linux's libc 5 and so may be portable to Linux. @subheading Example @example @end example