[fpc-pascal] netdb, DNS and TCP

Noel Duffy noelduffy at xtra.co.nz
Mon Oct 12 09:39:23 CEST 2020


On 11/10/20 9:42 pm, Michael Van Canneyt via fpc-pascal wrote:
> 
> On Sun, 11 Oct 2020, Noel Duffy via fpc-pascal wrote:

>> 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.

Therein lies the rub. Once your code reads or writes to the network, all bets are off with regard to speed.

> 
> If you have suggestions for a better implementation, I am all ears...

Well, better depends on what you're optimizing for, of course. In many places the DRY principle is considered a Holy Commandment graven on stone tablets and breaking it tantamount to heresy.

If the community thinks breaking DRY is acceptable to preserve speed in this case then I'm willing to accept that and run with it.



More information about the fpc-pascal mailing list