Jose,
>I'm trying to find out Current Machine IP Address using Asinet.
As Pablo already mentioned, it depends on what you want, the internal
or the external IP Address of the computer. Here are routines for both,
using ASINet (some lines may wrap):
Function GetLocalIPAddress()
LOCAL aLocal := SocketGetHostByName('localhost')
LOCAL cName := aLocal[HOSTINFO_CNAME]
LOCAL aHost := SocketGetHostByName(cName)
LOCAL cIP := SocketInetNtoA(aHost[HOSTINFO_ADDR, 1])
return (iif(empty(cIP), '127.0.0.1', cIP))
Function GetPublicIPAddress()
LOCAL cIP :=
LoadFromURL('http://www.WhatIsMyIP.com/automation/n09230945.asp')
return (iif(empty(cIP) .or. len(cIP := CleanUp_CRLFs(cIP)) > 20, 'Unknown',
cIP))
Function CleanUp_CRLFs(cText)
cText := alltrim(cText)
while at(' ' + CRLF, cText) # 0
cText := StrTran(cText, ' ' + CRLF, CRLF)
enddo
while at(CRLF + CRLF, cText) # 0
cText := StrTran(cText, CRLF + CRLF, CRLF)
enddo
if left(cText, 2) == CRLF
cText := substr(cText, 3)
endif
return (alltrim(cText))
Hope that helps,
Andreas
Andreas Gehrs-Pahl
EJustice OnSite Product Manager
EJustice Solutions, LLC
phone: (989) 723-9927
web: http://www.EJusticeSolutions.com/EJS_OnSite/
email: Andreas_Gehrs-Pahl@EJusticeSolutions.com
Andreas@DDPSoftware.com
GPahl@CharterMI.net