The res_query() call provides an interface to the server query mechanism.
Syntax
#include <sys\types.h> #include <netinet\in.h> #include <arpa\nameser.h> #include <resolv.h> int res_query(name, class, type, answer, anslen) char *name; int class; int type; u_char *answer; int anslen;
Parameters
name
C_IN
T_A
Description
The res_query() call provides an interface to the server query mechanism. It constructs a query, sends it to the local server, awaits a response, and makes preliminary checks on the reply. The query requests information of the specified type and class for the fully-qualified domain name specified in the name parameter. The reply message is left in the answer buffer whose size is specified by the anslen parameter, which is supplied by the caller.
The caller must parse answer and determine whether it answers the question.
The res_query() call is one of a group of calls that form the resolver, a set of functions that resolve domain names. The _res data structure contains global information used by the resolver calls. The <RESOLV.H> file contains the _res structure definition. (See The _res Data Structure for more on the _res data structure.)
Return Values
When successful, the res_query() call returns the size of the response. When unsuccessful, the res_query() call returns a value of -1 and sets the h_errno value to the appropriate error.
Related Calls
dn_comp() dn_expand()
dn_find()
dn_skipname()
putlong()
putshort()
res_init()
res_mkquery()
res_search()
res_send()