[ldns-users] Are there send() and recv()-like interfaces in libdns?

W.C.A. Wijngaards wouter at nlnetlabs.nl
Mon Aug 1 14:24:47 UTC 2016


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 --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.nlnetlabs.nl/pipermail/ldns-users/attachments/20160801/89d8f57e/attachment.bin>


More information about the ldns-users mailing list