making a query for mx records

Edgar Pettijohn edgar at pettijohn-web.com
Sat Dec 11 17:11:51 CET 2021


I'm planning on using c-ares for making mx record searches and possibly 
txt record searches. This is what I've tried, error checking and obvious 
stuff removed for clarity:

int main() {

unsigned char *buf;

int buflen;

struct ares_mx_reply *out;

ares_library_init(ARES_LIB_INIT_ALL);

ares_init(&channel);

/* 1 = INTERNET, 15 = MX */

ares_create_query(host, 1, 15, 0x1234, 1, &buf, &buflen, 0);

wait_ares(channel);

ares_parse_mx_reply(buf, buflen, &out);

...

}

this  is where it errors out due to an empty response. I'm guessing I'm 
using the library wrong, but not sure.


Thanks,


Edgar



More information about the c-ares mailing list