|
I am having a problem with a sub-procedure I am trying to create to get a
host name by providing an IP address. If anybody can spot a problem or lend
any insights, I would appreciate it.
D #GetHostName PR 64A
D InAddress 15A Value
D inet_addr PR 10U 0 ExtProc('inet_addr')
D IPAddr * Value Options(*String)
D GetHostByAddr PR * ExtProc('gethostbyaddr')
D IP_Address *
D AddrLen 10I 0 Value
D AddrType 10I 0 Value
P #GetHostName B Export
*!-----------------------------------------------
* <#GetHostName> Get hostname through DNS
*
* Usage: Eval Host = #GetHostName(IP)
*
*!-----------------------------------------------
D #GetHostName PI 64A
D InAddress 15A Value
* Data Structures
D RcvVar DS
D Protocol 859 859A
D IPAddress 878 892A
D HostEnt DS Based(pHostEnt)
D pHostName *
D pAliases *
D AdrType 10I 0
D Length 10I 0
D pAddrList *
D Host S 64A Based(pHostName)
* Stand Alones
D AddrType S 5I 0 Inz(2)
D pHostEnt S *
D pHostAddr S *
D IP32Addr S 10U 0
D AddrLen S 10I 0
*-------------------
* Sub Procedure
*-------------------
C Eval IP32Addr = inet_addr(%Addr(InAddress))
C Eval pHostAddr = %Addr(IP32Addr)
C Eval AddrLen = %Size(IP32Addr)
C Eval pHostEnt = GetHostByAddr(pHostAddr:
C AddrLen:
C AddrType)
C If pHostEnt = *NULL
C Return ' '
C Else
C Return Host
C EndIf
P #GetHostName E
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.