Solved

HELP: DNS

Posted on 2000-05-09
3
171 Views
Last Modified: 2010-04-04
Hi all!

I'm using D5 with the Windshoes WinshoeMappedPort. It works like a dream :-)

Q: For each connection made through the WinshoeMappedPort a thread is running. In each of these threads I want to make a DNS lookup (converting a name to ip).

So basicly I need some code that I can put inside the code of each thread (I don't with to use synchronized code, due to performance reasons).

If several DNS servers is available, I guess it would be smart to have multiple thread querying each of them. Please comment this issue.

Please note the DNS address can be either on a LAN or modem connection.

Source code would be very appreciated, something like
DNSQuery(ComputerName : String) : TStrings;
begin
  ?
end;

I know FPiette has an example using ICS, so don't give me that solution! If I can avoid it, I would try to stick to WinShoes.

Best regards,

Peter
0
Comment
Question by:jpvj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
God_Ares earned 100 total points
ID: 2791916
uses WinSock;

function GetHostName(name : string) : string;
var
wsdata : TWSAData;
  he : PHostEnt;
  ip : TInAddr;            
begin
  WSAStartup(MakeWord(1, 1), wsdata);
  ip.S_addr := inet_addr(PChar(name));
  he := gethostbyaddr(@ip.S_un_b, 4, AF_INET);        
  if he<>nil then
    Result := string(he.h_name)
  else
    Result := IntToStr(WSAGetLastError);
  WSACleanup();
end;

function GetIPAddress(name : string) : string;
var wsdata : TWSAData;
    he : PHostEnt;
    ss : pchar;
    ip : TInAddr;
begin
  WSAStartup(MakeWord(1, 1), wsdata);
  he := gethostbyname(pchar(name));
  if he<>nil then
  begin
    ip.S_addr := integer(pointer(he^. h_addr_list^)^);
    ss := inet_ntoa(ip);
    Result := string(ss);
  end;
  WSACleanup();
end;
0
 

Author Comment

by:jpvj
ID: 2793741
Thanks a lot!

Peter
0
 
LVL 7

Expert Comment

by:God_Ares
ID: 2795697
yeah shure no probl.. thanx for tha points...

yet again closer to my t-shirt :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question