Solved

HELP: DNS

Posted on 2000-05-09
3
160 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 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now