How to execute a reverse DNS lookup
Posted on 2003-03-03
First, let me say that I am not a Visual Basic writer. I have not used the langage for years, so the exact details of the syntax escape me.
Anyway, I am looking to execute a reverse DNS lookup(getting a hostname from an IP adress). I have a written a procedure to execute this in Delphi using the gethostbyaddr Windows Socket function, but havent figured out how to port it to VB.
If someone could furnish an exemple of ported code(or a different code that functions), with included the needed declarations to get Winsock started in VB, would be great.
Thanks in advance!
//Procedure in Delphi
wsdata : TWSAData;
he : PHostEnt;
lip : TInAddr;
WSAStartup(MakeWord(1, 1), wsdata);
lip.S_addr := inet_addr(PChar(IP));
he := gethostbyaddr(@lip.S_un_b, 4, AF_INET);
if he<>nil then
Host := string(he.h_name)
Host := '';