How to match the async result? (dns_submit_a4 returns 0 instead of a pointer)
Iñaki Baz Castillo
ibc at aliax.net
Sat Feb 5 19:59:57 MSK 2011
2011/2/5 Iñaki Baz Castillo <ibc at aliax.net>:
>> ---------------
>> size_t query_ptr;
>>
>> if (query_ptr = dns_submit_a4(dns_context, "google.com", 0,
>> dns_res_A_cb, NULL) == 0) {
>> fprintf(stderr, "FATAL: unable to submit query: %s\n",
>> dns_strerror(dns_status(0)));
>> return 1;
>> }
>> printf("query_ptr = <%lu>\n", (unsigned long)query_ptr);
>> --------------
>>
>> Running it I get: "query_ptr = <0>". Shouldn't it be a pointer?
>
> Well, dns_submit_a4() returns NULL rather than 0 sorry. But why does
> it return NULL?
Sorry, a really stupid C bug in my code:
WRONG:
if (query_ptr = dns_submit_a4(dns_context, "google.com", 0,
dns_res_A_cb, NULL) == 0)
OK:
if ((query_ptr = dns_submit_a4(dns_context, "google.com", 0,
dns_res_A_cb, NULL)) == 0)
So ok, dns_submit_a4 returns a pointer to 'struct dns_query'. Now the
question: how can I use this pointer to match the future response
given in a callback routine?
--
Iñaki Baz Castillo
<ibc at aliax.net>
More information about the udns
mailing list