res_search() — Resolver query for domain name servers

Standards

Standards / Extensions C or C++ Dependencies

BSD 4.3

both OS/390 V2R8

Format

#define _XOPEN_SOURCE_EXTENDED 1
#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);

General description

This routine is one of several functions used for making, sending and interpreting query and reply messages with Internet domain name servers (DNS).

The res_search() routine makes a query and awaits a response like res_query() but, in addition, it implements the default and search rules controlled by the RES_DEFNAMES and RES_DNSRCH options. It returns the first successful reply.

Note: The res_search() function has a dependency on the level of the Enhanced ASCII Extensions. See Enhanced ASCII support for details.

Returned value

If successful, res_search() returns the first successful reply.

If unsuccessful, res_search() returns -1 and sets herrno to one of the following values:
Error Code
Description
HOST_NOT_FOUND
The host name provided is not known at any of the domain name servers queried for this request.
NO_DATA
An answer was received but no data was supplied in the answer buffer.
NO_RECOVERY
An error occurred that will continue to fail if tried again.
TRY_AGAIN
A error occurred querying the name selected, which can be retried.

Related information