Alaska Software Inc. - Get current machine IP Address
Username: Password:
AuthorTopic: Get current machine IP Address
Jose Adriano Baltieri Get current machine IP Address
on Fri, 13 Aug 2010 13:57:32 -0300
Hello !

I'm trying to find out Current Machine IP Address using Asinet.

May I ?

How is it ?

Thanks !
AUGE_OHRRe: Get current machine IP Address
on Fri, 03 Sep 2010 01:33:17 +0200
hi,

> I'm trying to find out Current Machine IP Address using Asinet.

not shure about Asinet, but i "think" Pablo have a Function in his ot4xb Lib

greetings by OHR
Jimmy
Pablo BotellaRe: Get current machine IP Address
on Fri, 03 Sep 2010 10:01:38 +0200
Hi,

>> I'm trying to find out Current Machine IP Address using Asinet.
> not shure about Asinet, but i "think" Pablo have a Function in his ot4xb Lib

The attached package ( this is an updated version) retrieve the same info as the ipconfig and netstat programs, but using WinAPI calls instead of the exes, this is usefull to allow the user to choose one IP and port to start a TCP server application.

Here http://news.xbwin.com/newsgroups.php?art_group=ot4xb.examples&article_id=13 a similar one but reporting wich executable is using every IP/port

However, I suspect that than Jose needs is not this, but retrieve the external address , and this is only possible to see from the outside.

Regards,
Pablo Botella


IpConfig.zip
Andreas Gehrs-Pahl
Re: Get current machine IP Address
on Tue, 07 Sep 2010 00:38:05 -0400
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