Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

res_search()

Query a local server, using search options

Synopsis:

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

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

Arguments:

dname
The fully qualified domain name that you want to query.
class
The class of information that you want; one of:

You typically use C_IN.

type
The type of information that you want. You typically use T_PTR, but you can use any of the T_* constants defined in <arpa/nameser.h>.
answer
A pointer to a buffer where the function can store the answer to the query.
anslen
The length of the buffer.

Library:

libsocket

Use the -l socket option to qcc to link against this library.

Description:

The res_search() routine makes an Internet domain name search. Like res_query(), res_search() makes a query and waits for a response. But it also implements the default and search rules controlled by the RES_DEFNAMES and RES_DNSRCH options. It returns the first successful reply.

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().

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:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread No

See also:

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

hostname, /etc/resolv.conf in the Utilities Reference

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