Eric Montréal wrote:
> Wilfried Mestdagh wrote:
>> Hello Eric,
>> Check out DnsQuery component, I think that's what you need.
> I looked at tDnsQuery, but this part of DNS is still some kind of
> mysterious art to me ...
> The component  gives me the IP for a domain, but, I have no idea how to
> use it to get
> the DNS server's IP (or name) for a domain instead of the domain's IP
> itself.

Domains do not own an IP, but hosts do :)
However you are right, as far as I understand the component there's in fact
no method implemented to get the name server of a domain.

However I think it's easy to add, try something like:

function TDnsQuery.NSLookup(Domain : String) : Integer;
    BuildRequestHeader(PDnsRequestHeader(@FQueryBuf), FIDCount, DnsOpCodeQuery, 
TRUE, 1, 0, 0, 0);
    FQueryLen := BuildQuestionSection(@FQueryBuf[SizeOf(TDnsRequestHeader)], 
Domain, DnsQueryNS, DnsClassIN);
    FQueryLen := FQueryLen + SizeOf(TDnsRequestHeader);
    Result    := FIDCount;

In procedure TDnsQuery.WSocketDataAvailable(Sender: TObject; Error: WORD);

add ==>     DnsQueryNS,
                    if FPTRRecordCount <= High(FHostnameArray) then begin
                        FAnswerTagArray[I] := FPTRRecordCount;
                        DecodePTRData(@FResponseBuf, RDataPtr,


Check DnsQuery.Hostname[n] in DnsQuery.OnRequestDone, is it working for you?

To unsubscribe or change your settings for TWSocket mailing list
please goto
Visit our website at

Reply via email to