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 20:06:41 MSK 2011


2011/2/5 Michael Tokarev <mjt at tls.msk.ru>:
> The above little program prints some non-NULL pointer here,
> like `q=0x93c7520'.

Yes sorry, as I've explained in my last mail it was a stupid bug of
mine, missing ( ).


>> Perhaps should I use the data pointer provided in the dns_submit_a4()
>> call as last parameter to match the callback? But that would mean
>> before the query I must create a "random" identifier, set it as 'data'
>> parameter in dns_submit_a4(), and check 'data' when a callback is
>> executed.
>>
>> Do I miss something?
>
> I don't understand what you're doing, really.
>
> Yes, that "data" thing is your identifier, or anything you want to
> be assotiated with the query.  I don't see why it should be "random" --
> you aren't running "random" queries, each query is assotiated with
> something, so use that 'something' as your identifier.
>
> Usually you'll have address of some structure as 'data' pointer.
> For example, when you write a mailserver, and want to retrieve
> name of the connecting client (rDNS), you'll have a "connection"
> structure which will be passed as data to the callback.
>
> In short: I don't understand what you're asking.

I was asking exactly this, now it's clear :)

In some other libraries the async call returns an identifier that's
generated internally by the async call. Then the application can use
the returned identifier to match the callback. I was looking
obsessively for this exact mechanism in udns. Now I understand that
the identifier is, instead, provided by the application when
performing the async query.

Thanks a lot.

-- 
Iñaki Baz Castillo
<ibc at aliax.net>


More information about the udns mailing list