Search code examples
dns

I'm writing a DNS client but RDLENGTH returns 0


The response is coming in as expected, no errors on RCODE, QDCOUNT is 1 and ANCOUNT is 1 as well.

When I check for RDLENGTH it's always 0. Forcefully reading RDATA I'm able to get what would be that IPv4 address I want except that it's partially correct. I got something like xx.yy.zz.ww where xx and yy is right but zz and ww is not. Would that be due to data compression or something else?


Solution

  • Ok, so I've the issue myself. It stood out that I was fetching answer's TTL as an uint16 where it should be uint32. Fixing it did the trick and I'm now getting the correct ip address.