KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to get the server IP address from a client machine
PRODUCT: 4D | VERSION: 11.6 | PLATFORM: Mac & Win
Published On: April 2, 2010
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

An easy way to get the server's IP address from the client machine is to use the IT_MyTCPAddr command from the 4D Internet Commands plugin. To implement this:

  1. Install the 4D Internet Commands.bundle in the database Plugins folder.

  2. Create a method with the Execute on server property checked on. The method below named Util_IpAddress will work for this:

    `--- Method Util_IpAddress
    `This method has Execute on server property checked on
    `
    C_TEXT($ipAddress;$subnet)
    C_TEXT($0)

    IT_MyTCPAddr ($ipAddress;$subnet)
    $0:=$ipAddress

    `---End Util_IpAddress

  3. Create another method that calls Util_IpAddress from the client. The method below named getServer_IpAddress does this:

    `---Method getServer_IpAddress
    `

    C_TEXT($serverIP)

    $serverIP:= Util_IpAddress

    `---End getServer_IpAddress

  4. Execute getServer_IpAddress to retrieve the IP.