|
Sigh... I've already answered this message wrong twice, because my brain fell out and rolled away. Anyway... this has nothing to do with WinXP or Win2k. Neither gethostbyname() or gethostbyaddr() actually contacts the computer that you're looking up, so it doesn't matter what their operating systems are. All it does it ask the DNS server. The DNS server will have a file called a "zone file" which contains a list of computers and their addresses. To do reverse lookup, it reverses the IP address and makes a hostname that it can check for. If the IP address is "1.2.3.4", then it will look for "4.3.2.1.IN-ADDR.ARPA" in your zone file. Make sure you have your PCs defined in that matter, and you should be all set. On Wed, 18 Jun 2003, Jonathan Giles wrote: > > I have an RPG program I copied from Midrange (thank you Scott Klement ) > using the gethostbyaddr API and it worked well on my W2k machines. I > have upgraded my machines to XP and the program no longer returns the > host name. I have the latest patches applied (06/18/2003). > > Jon Giles > > hdebug dftactgrp( *no ) bnddir( 'QC2LE' ) > Dinet_addr PR 10U 0 ExtProc('inet_addr') > D IPAddr * Value options(*string) > > DGetHostByAddr PR * ExtProc('gethostbyaddr') > D HostEnt 10U 0 > D AddrLen 10I 0 Value > D AddrType 10I 0 Value > > DHostEntP S * > > Dhostent DS Based(HostEntP) > D h_name * > D h_aliases * > D h_addrtype 5I 0 > D h_length 5I 0 > D h_addr_list * > > DIP32Addr S 10U 0 > DAF_INET C Const(2) > C *Entry PList > C Parm P#IPAddress 15 > C Parm P#IPName 64 > > * Convert IP to binary format: > C Eval IP32Addr = inet_addr(P#IPAddress) > > * do reverse DNS lookup: > > C Eval HostEntP = gethostbyaddr(IP32Addr : > C %size(IP32Addr) : > C AF_INET) > > * set results > > C if HostEntP = *Null > C Eval P#IPName = 'Host not found!' > C Else > C Eval P#IPName = %str(h_name) > C endif > C SetOn Lr > C Return
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.