× 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.


  • Subject: IP address for the Host name
  • From: ram babu <rbkalidindi@xxxxxxxxx>
  • Date: Mon, 16 Apr 2001 06:51:36 -0700 (PDT)

Hi,

I'm new to this forum.I'm having trouble with gethostbyname API.Basically i'm trying to get IP address for the Host name through DNS lookup.Specified DNS server address through CFGTCP option '12'.Also i'm not using host table entries.I'm able to get Host name for the IP address by gethostbyaddr API.I wonder why this code was not working for me.I'm using following code to get IP address for the Host name.I appreciate your help.Please advise me.

Regards,
Rambabu Kalidindi.

HDEBUG(*YES)
DGetHostByName PR * ExtProc('gethostbyname')
D HostName * Value
D*
D Host@ S *
D HostEntData@ S * Inz
D*
DHostEnt DS Align Based(Host@)
D HName@ *
D HAliases@ *
D HAddrType 10I 0
D HLength 10I 0
D HAddrList@ *
D*
DHostEntData DS Align Based(HostEntData@)
D HName 256A
D HAliasesArr@ * Dim(64)
D HAliasesArr 256A Dim(64)
D HAddrArr@ * Dim(101)

D HAddrArr 10U 0 Dim(100)
D OpenFlag 10I 0
D F0@ *
D FileP0 260A
D Reserved0 150A
D F1@ *
D FileP1 260A
D Reserved1 150A
D F2@ *
D FileP2 260A
D Reserved2 150A
D*
DServerIP@ S *
DServerIP S 256A Based(ServerIP@)
DServerName S 256A
DServer@ S *
D*
D*Get h_errno
D*
DGetH_ErrNo PR * ExtProc('__h_errno')
D h_ErrnoPtr S *
D h_errno S 10I 0 Based(h_ErrnoPtr)
D*
DIPaddr S 10U 0
D*
c
c *entry plist
c parm HostName 256
c*
C eval ServerName = %trim(HostName)+X'00'
C eval Server@ =%addr(ServerName)
C eval Host@ = GetHostByName(Server@)
C eval h_ErrnoPtr = GetH_ErrNo
C*
c if h_errno = 0
c Eval HostEntData@ = HName@
c Eval IPaddr = HAddrArr(1)
c Endif
c*
c dump
c Seton lr
c



Do You Yahoo!?
Yahoo! Mail Personal Address - Get email at your own domain with Yahoo! Mail.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.