Tell you what John,
Here is a very simple solution based upon the M$ business model:

<<set M$ Mode ON>>

cName="www.google.com"
cIP=GetIP_From_Name(cName)

There, how short and simple do you want it? However I will retain all source
code and simply sell you rights to use the compiled function subject to my
T's & C's with a retained ability to stop working whenever I want. Oh, and
by the way the cost is $1,000 and I can't deliver until 2012.

<<set M$ Mode OFF>>

Dave Crozier


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of John Harvey
Sent: 15 July 2008 14:43
To: 'ProFox Email List'
Subject: RE: Determining IP Address from Domain Name programmatically

I know. I guess I was thinking more along the lines of Rick Strahl's
wwipstuff. I think he wraps an api call in his class. It's about 3 lines of
code, but not using sockets. I think it's win32 api.

John

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Dave Crozier
Sent: Tuesday, July 15, 2008 8:39 AM
To: 'ProFox Email List'
Subject: RE: Determining IP Address from Domain Name programmatically

John,
Well Joe did say that he wanted an API solution. There may be a shorter way
but at least I know this way works!

Dave Crozier


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of John Harvey
Sent: 15 July 2008 14:35
To: 'ProFox Email List'
Subject: RE: Determining IP Address from Domain Name programmatically

Dang, that's a ton of code just to get what can be done in a few lines of
code and a ping redirect!

John

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Dave Crozier
Sent: Tuesday, July 15, 2008 2:59 AM
To: 'ProFox Email List'
Subject: RE: Determining IP Address from Domain Name programmatically

Joe,
This does what you want:

********************
* Start of Program
*
Clear

Do DLL_Declare

If InitWinsock()
  Local lcLocalHost, lcLocalIP
  cHost="www.Microsoft.com"
  cHostIP = GetHostIP(cHost)

  ? "Host:", cHost
  ? "Host IP:", cHostIP

  = WSACleanup()
Endif
* End of Main

Function  GetHostIP (lcHostname)
  #Define HOSTENT_SIZE  16
  Local lcHOSTENTptr, lcHOSTENT, lnAddrlistPtr

  * address for the HOSTENT structure
  lcHOSTENTptr = gethostbyname(lcHostname)

  If lcHOSTENTptr <> 0
    lcHOSTENT = GetMemBuf (lcHOSTENTptr, HOSTENT_SIZE)

    * a pointer to a null-terminated list of addresses
    lnAddrlistPtr = buf2dword(Substr(lcHOSTENT, 13,4))
    Return GetIPfromHOSTENT (lnAddrlistPtr)
  Endif
  Return ""
Endfunc


Procedure  GetIPfromHOSTENT (lnAddrlistPtr)
  * retrieving IP address from the HOSTENT structure
  Local lnDataAddress, lcResult
  lnDataAddress = buf2dword(GetMemBuf (lnAddrlistPtr, 4))
  Return Iif(lnDataAddress <> 0, ;
    GetIPAddress(GetMemBuf(lnDataAddress,4)),"")
Endproc

Function  GetIPAddress (lcAddrBuf)
  * converts 4-characters string buffer
  * to the IP address string representation
  Local lcResult, ii
  lcResult = ""
  For ii=1 To 4
    lcResult = lcResult +;
    LTRIM(Str(Asc(Substr(lcAddrBuf, ii,1)))) + ;
      Iif(ii=4, "",".")
  Endfor
  Return  lcResult
Endfunc

Function  InitWinsock()
  * Initializing the Winsock service for the application
  #Define WSADATA_SIZE  398
  #Define WS_VERSION    514  && 0x0202
  Local lcWSADATAln, lnInitResult
  lcWSADATA = Repli(Chr(0), WSADATA_SIZE)
  lnInitResult = WSAStartup (WS_VERSION, @lcWSADATA)
  Return  (lnInitResult = 0)
Endfunc

Function  GetMemBuf (lnAddr, lnBufsize)
  Local lcBuffer
  lcBuffer = Repli(Chr(0), lnBufsize)
  = Heap2Str (@lcBuffer, lnAddr, lnBufsize)
  Return  lcBuffer
Endfunc

Function  buf2dword (lcBuffer)
  Return Asc(Substr(lcBuffer, 1,1)) + ;
    Asc(Substr(lcBuffer, 2,1)) * 256 +;
    Asc(Substr(lcBuffer, 3,1)) * 65536 +;
    Asc(Substr(lcBuffer, 4,1)) * 16777216
Endfunc


Procedure  DLL_Declare
  Declare Integer WSAStartup In ws2_32 Integer wVerRq, String @lpWSAData
  Declare Integer WSACleanup In ws2_32
  Declare Integer gethostbyname In ws2_32 String HostName

  Declare Integer gethostname In ws2_32;
    STRING @Name, Integer namelen

  Declare RtlMoveMemory In kernel32 As Heap2Str;
    STRING @Dest, Integer Src, Integer nLength

Endproc
*
*End of Program
*******

Dave Crozier

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Joe Yoder
Sent: 14 July 2008 21:20
To: [email protected]
Subject: Determining IP Address from Domain Name programmatically

I know I could do an nslookup redirected to a file and tear the file apart
to get the info but it seems there must be a more elegant approach.  An API
call?
 
TIA - Joe


--- StripMime Report -- processed MIME parts ---
multipart/alternative
  text/plain (text body -- kept)
  text/html
---

[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to