[ldns-users] Are there send() and recv()-like interfaces in libdns?
adamiaonr at gmail.com
Mon Aug 1 14:48:00 UTC 2016
Thank you for the tip, this is close to what I'm looking for.
I have a couple of follow-up observations/questions:
- 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
- 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?
Thank you once more Wouter!
On Mon, Aug 1, 2016 at 4:24 PM, W.C.A. Wijngaards <wouter at nlnetlabs.nl>
> Hi Damião,
> There are the functions ldns_udp_bgsend() that returns a socket on which
> the send() has been performed. And ldns_udp_read_wire() when you want
> the result. From ldns/net.h. (there are also tcp versions).
> The functions ldns_rdf2native_sockaddr_storage and
> ldns_sockaddr_storage2rdf can help you convert A (and AAAA) rdfs to the
> sockaddr struct that the routines want.
> Best regards, Wouter
> On 31/07/16 23:04, Damião Rodrigues wrote:
> > I've built a simple command line application in C which uses libdns to
> > make periodic DNS queries to the authoritative name servers of multiple
> > domains. Ensuring the periodicity of the queries is important, following
> > a user-defined query_interval (in seconds).
> > As far as I could tell, libdns only allows for request-response calls:
> > the functions which start DNS queries also return the DNS response,
> > blocking until a response is received. Because of this, I've implemented
> > a key part of the application in a naive way within a while() cycle:
> > 1. I do a block of queries
> > 2. Take note of the time taken by the query block (query_time)
> > 3. sleep(query_interval - query_time)
> > 4. Go back to 1
> > I think this is sloppy. A better option would be to have separate
> > send/receive threads. This way, the periodicity of the query blocks
> > wouldn't be affected by the duration of the request-response cycles. But
> > for that I would need libdns functions with separate send()- and
> > recv()-like interfaces, which I couldn't find in the documentation,
> > greps in the source folders, nor examples.
> > Have I missed something? *Are there send()- and recv()-like interfaces
> > in libdns?*
> > *
> > *
> > Thanks in advance!
> > Best regards,
> > Antonio
> > *
> > *
> > _______________________________________________
> > ldns-users mailing list
> > ldns-users at open.nlnetlabs.nl
> > https://open.nlnetlabs.nl/mailman/listinfo/ldns-users
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ldns-users