Solved

HELP: DNS

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

Technology Partners: 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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 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