Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HELP: DNS

Posted on 2000-05-09
3
Medium Priority
?
178 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
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
God_Ares earned 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

926 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