On Sun, 11 Oct 2020, Noel Duffy via fpc-pascal wrote:
Hi all,
To keep track of the work I've been doing on DNS in netdb, I created bug
#37906 in Mantis.
https://bugs.freepascal.org/view.php?id=37906
I've attached to a note on that bug report a proof-of-concept version of
netdb.pp and a small program that uses it to make text queries over TCP. This
version of netdb has different record types for TCP and UDP (technically, it
has three, one for UDP queries and replies, one for TCP queries, one for TCP
replies). The wire protocol for DNS over TCP has a mandatory two-octet length
field at the start for both queries and replies, and I didn't want to have to
use a full-length 64k buffer for both when a smaller 512 byte buffer
suffices.
Overall I'm not really enthused with this implementation. Having separate
record types for the different payload types means having separate versions
of a number of helper functions as well. Functions like BuildPayload, NextRR,
and SkipAnsQueries.
To avoid that duplication, the code would need to use a dynamic buffer and
fill it just before socket writing. The TCP variant would include its length
field in the buffer. Additionally, after reading the response from the
socket, the buffer contents would have to be copied into a record data
structure. It's a tradeoff between execution efficiency and simplicity.
It always is.
But I am inclined to think that DNS queries benefit more from execution
efficiency, hence the preference for avoiding the copying of buffers as much
as possible.
One could of course argue that with TCP, the speed suffers in each case.
If you have suggestions for a better implementation, I am all ears...
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal