res_query()

query the local Internet domain name server

Synopsis:

#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>

int res_query( char *dname, 
               int class, 
               int type,
               u_char *answer, 
               int anslen );

Description:

The res_query() function provides an interface to the server query mechanism. It constructs a query, sends it to the local server, waits for a response, and makes preliminary checks on the reply. The query requests information of the specified type and class for the specified fully qualified domain name dname. The reply message is left in the answer buffer with length anslen supplied by the caller.

The resolver routines are used for making, sending, and interpreting query and reply messages with Internet domain name servers. Global configuration and state information used by the resolver routines is kept in the structure _res. For more information on the options, see res_init().

The res_query() function uses the following lower-level routines:

Returns:

The length of a reply message, in bytes, or -1 if an error occurs (h_errno is set).

Errors:

See herror().

Files:

/etc/resolv.conf
Resolver configuration file.

Environment variables:

LOCALDOMAIN
When set, LOCALDOMAIN contains a domain name that overrides the current domain name.

Classification:

UNIX

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

dn_comp(), dn_expand(), gethostbyname(), herror(), res_init(), res_mkquery(), res_query(), res_search(), res_send()

/etc/resolv.conf, hostname, named in the TCP/IP User's Guide

RFC 1032, RFC 1033, RFC 1034, RFC 1035, RFC 974