DNS lookup example 
Author Message
 DNS lookup example

Hi,

Does anyone have example code that does a DNS lookup given
an IP address ?

Thx

Matt T.
Washington State Resident, spam'l cost ya $500 a pop !!
I don't want the crap, but if you want to fund my retirement...



Thu, 25 Jan 2001 03:00:00 GMT  
 DNS lookup example

Quote:

>Does anyone have example code that does a DNS lookup given
>an IP address ?

Function getByAddr(remoteIPaddr As String) As String

  Dim phe&
  Dim heDestHost As HostEnt
  Dim hostname$
  Dim retString$
  Dim remoteIP&

  hostname = String(256, 0)
  remoteIP = inet_addr(remoteIPaddr)
  phe = gethostbyaddr(remoteIP, 4, PF_INET)
  If phe <> 0 Then
    MemCopy heDestHost, ByVal phe, hostent_size
    MemCopy ByVal hostname, ByVal heDestHost.h_name, 256
    retString = Left(hostname, InStr(hostname, Chr(0)) - 1)
  Else
    retString = WSA_NoName
  End If

  getByAddr = retString

End Function

Include appropriate wsock32.dll declares for inet_addr and
gethostbyaddr as well as the kernel32 declare for MemCopy.
There's a lot of constants in there too.  Check wsksock.bas
for all of those.

Michael
http://www.thecube.com/



Thu, 25 Jan 2001 03:00:00 GMT  
 DNS lookup example

Quote:
>Does anyone have example code that does a DNS lookup given
>an IP address ?

you can use my DNS.ocx
actually it's not real DNS but GetHostByAddress
but who cares as long as it works

you can download it from http://www.ostrosoft.addr.com



Fri, 26 Jan 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Trying to do DNS lookup and reverse DNS lookup

2. Performing a DNS Lookup

3. Reverse DNS lookup?

4. IP-DNS Lookup for ASP.Net?

5. DNS Lookup

6. DNS Lookups (Visual Basic 5 & SOCKS4)

7. DNS lookup in VB6

8. WinSock HELP - need reverse DNS lookup ...

9. DNS Lookup with Winsock Control

10. forcing a DNS lookup with Inet

11. DNS lookup for MX records

12. DNS Lookup

 

 
Powered by phpBB® Forum Software