How might I perform DNS lookups using C/C++ on Linux?

c, dns, linux, smtp

Solution

If a blocking (synchronous) query is ok, just use `res_query()`, and link your program with -lresolv.

 len = res_query(host, C_IN, T_MX, &answer, sizeof(answer));

Problem

How do I get similar functionality to the `host` command using a c api (or any other language for that matter)? I need more information than just an IP address given by `gethostbyname()`; specifically, the SMTP-related data.

Original source

Related problems