KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Obtaining the published or local IP address
PRODUCT: 4D Internet Commands | VERSION: | PLATFORM: Mac & Win
Published On: May 30, 2003
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Versions: 6.8.1 and 2003

Here is a method that returns the IP address that is being used by the Web Server or the local IP address that the Web Server can use to publish.

C_TEXT($0)
C_LONGINT($addr;$a;$b;$c;$d)
$addr:=Get database parameter(IP Address to listen )
$a:=($addr >> 24) & 0x00FF
$b:=($addr >> 16) & 0x00FF
$c:=($addr >> 8) & 0x00FF
$d:=$addr & 0x00FF
If (($a=0) & ($b=0) & ($c=0) & ($d=0))
 C_TEXT($ip_address;$subnet)
 C_LONGINT($Error)
 $Error:=IT_MyTCPAddr ($ip_address;$subnet)
 $0:=$ip_address
Else
 $0:=String($a)+"."+String($b)+"."+String($c)+"."+String($d)
End if

Note: This method can return only one IP address. If the published IP address is set to "All" in the Database Properties (or Preferences for 4D 2003), the method will return the primary IP address of the machine as the function result. The only time that the secondary IP address will be returned is when it is set in the Database Properties (or Preferences for 4D 2003) to be the only published IP address.