res_query()--Send Domain Query
Syntax
#include <sys/types.h> #include <netinet/in.h> #include <arpa/nameser.h> #include <resolv.h> int res_query(char *domain_name, int class, int type, char *answer_buffer, int answer_buffer_length)
Service Program Name: QSOSRV2
Default Public Authority: *USE
Threadsafe: Yes
The res_query() function is used to interface to the server query mechanism.
Parameters
- domain_name
- (Input) The pointer to the domain name.
- class
- (Input) The class of data being looked for. See res_mkquery() or <arpa/nameser.h> for possible
values.
- type
- (Input) The type of request being made. See res_mkquery() or <arpa/nameser.h> for possible
values.
- answer_buffer
- (Output) The pointer to an address where the response is stored.
- answer_buffer_length
- (Input) The size of the answer area.
Authorities
No authorization is required.
Return Value
res_query() returns an integer. Possible values are:
- -1 (unsuccessful)
- n (successful), where n is the actual size of the answer returned.
Error Conditions
When the res_query() function fails, errno can be set to one of the following:
- [EFAULT]
The system detected a pointer that was invalid while attempting to access an input pointer.
- [EINVAL]
The _res appears to be initialized but the reserved field is not set to zeros.
When the res_query() function fails, h_errno (defined in <netdb.h>) can be set to one of the following:
- [HOST_NOT_FOUND]
The domain name specified by the domain_name parameter was not found. The return code in the response packet was NXDOMAIN.
- [TRY_AGAIN]
Either the name server is not running or the name server returned SERVFAIL in the response packet.
- [NO_RECOVERY]
An unrecoverable error has occurred. Either the domain name could not be compressed because it was invalid or the name server returned FORMERR, NOTIMP, or REFUSED.
- [NO_DATA]
The domain name exists but there is no data of the requested type.
Usage Notes
- res_query() makes a query packet by calling
res_mkquery(), sends the query by calling res_send(), and
makes preliminary checks on the reply. The reply message is left in
answer_buffer.
- res_query() calls res_init() if the _res
structure has not been initialized.
- res_query() expects EBCDIC data as input. The output from
res_query() is also EBCDIC.
- In a thread-enabled environment, the _res structure is shared among all threads within a process.
Related Information
- hstrerror()--Retrieve Resolver Error
Message
- res_nquery()--Send Domain Query
- res_hostalias()--Retrieve the host alias
- res_init()--Initialize _res Structure
- res_mkquery()--Place Domain Query in Buffer
- res_close()--Close Socket and Reset _res
Structure
- res_search()--Search for Domain Name
- res_send()--Send Buffered Domain Query
- res_xlate()--Translate DNS Packets
API introduced: V3R1