× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Lane,

Take a look at Scott Klement's socket tutorial at 
http://klement.dstorm.net/rpg/socktut/index.html.

Matt

-----Original Message-----
From: McBride, Lane (Artco) [mailto:lmcbride@artco.zgate.com]
Sent: Thursday, July 11, 2002 1:01 PM
To: 'rpg400-l@midrange.com'
Subject: Get Host By IP


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
_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l
or email: RPG400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.