Query the local Internet domain name server
#include <sys/types.h> #include <netinet/in.h> #include <arpa/nameser.h> #include <resolv.h> int res_querydomain( const char * name, const char * domain, int class, int type, u_char * answer, int anslen );
- The host name that you want to query.
- The domain name that you want to query.
- The class of information that you want; one of:
- C_IN — ARPA Internet.
- C_CHAOS — Chaos net (MIT).
- C_HS — Hesiod name server (MIT).
- C_ANY — any class.
You typically use C_IN.
- 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>.
- A pointer to a buffer where the function can store the answer to the query.
- The length of the buffer.
Use the -l socket option to qcc to link against this library.
The res_querydomain() 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 host specified by concatenating name and domain. The trailing dot is removed from name if domain is 0.
The reply message is left in the answer buffer with length anslen supplied by the caller.
- An error occurred.
- Resolver configuration file.
- When set, LOCALDOMAIN contains a domain name that overrides the current domain name.