<div dir="ltr"><div><div>Hi Wouter,<br><br></div>Thank you for the tip, this is close to what I'm looking for.<br><br></div>I have a couple of follow-up observations/questions:<br><ul><li>Let's say I would go ahead with the separate read/write thread pattern. Since ldns_udp_bgsend() would update the socket file descriptor to be subsequently used by ldns_udp_read_wire(), for every individual call, I would have to keep a shared list of file descriptors, shared between the threads. This list would be written to by the ldns_udp_bgsend(), read by the ldns_udp_read_wire().</li><li>In your experience with libdns, did you ever had to implement something like this (separate read/write threads)? If yes, Is the method described above the one that you've followed to accomplish it? If not, what method did you use?</li></ul><p>Thank you once more Wouter!</p><p>Best regards,</p><p>Damião<br></p></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 1, 2016 at 4:24 PM, W.C.A. Wijngaards <span dir="ltr"><<a href="mailto:wouter@nlnetlabs.nl" target="_blank">wouter@nlnetlabs.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Damião,<br>
<br>
There are the functions ldns_udp_bgsend() that returns a socket on which<br>
the send() has been performed.  And ldns_udp_read_wire() when you want<br>
the result.  From ldns/net.h.  (there are also tcp versions).<br>
<br>
The functions ldns_rdf2native_sockaddr_storage and<br>
ldns_sockaddr_storage2rdf can help you convert A (and AAAA) rdfs to the<br>
sockaddr struct that the routines want.<br>
<br>
Best regards, Wouter<br>
<span class=""><br>
On 31/07/16 23:04, Damião Rodrigues wrote:<br>
> I've built a simple command line application in C which uses libdns to<br>
> make periodic DNS queries to the authoritative name servers of multiple<br>
> domains. Ensuring the periodicity of the queries is important, following<br>
> a user-defined query_interval (in seconds).<br>
><br>
> As far as I could tell, libdns only allows for request-response calls:<br>
> the functions which start DNS queries also return the DNS response,<br>
> blocking until a response is received. Because of this, I've implemented<br>
> a key part of the application in a naive way within a while() cycle:<br>
><br>
</span>>  1. I do a block of queries<br>
>  2. Take note of the time taken by the query block (query_time)<br>
>  3. sleep(query_interval - query_time)<br>
>  4. Go back to 1<br>
<span class="">><br>
> I think this is sloppy. A better option would be to have separate<br>
> send/receive threads. This way, the periodicity of the query blocks<br>
> wouldn't be affected by the duration of the request-response cycles. But<br>
> for that I would need libdns functions with separate send()- and<br>
> recv()-like interfaces, which I couldn't find in the documentation,<br>
> greps in the source folders, nor examples.<br>
><br>
</span>> Have I missed something? *Are there send()- and recv()-like interfaces<br>
> in libdns?*<br>
> *<br>
> *<br>
<span class="">> Thanks in advance!<br>
><br>
> Best regards,<br>
> Antonio<br>
</span>> *<br>
> *<br>
><br>
><br>
> _______________________________________________<br>
> ldns-users mailing list<br>
> <a href="mailto:ldns-users@open.nlnetlabs.nl">ldns-users@open.nlnetlabs.nl</a><br>
> <a href="https://open.nlnetlabs.nl/mailman/listinfo/ldns-users" rel="noreferrer" target="_blank">https://open.nlnetlabs.nl/mailman/listinfo/ldns-users</a><br>
><br>
<br>
<br>
</blockquote></div><br></div>