User Tools

Site Tools


Sidebar



en:objects:connection:ip:set_local_ip

set_local_ip

set_local_ip($number,$ip,$subnetMask="",$gateway="",$default DNS="",$subDNS=""); - set the local IP address. Available from version 7.0.20

the input function accepts parameters:

  • $number – adapter number
  • $ip – new IP address
  • $subnetMask – new subnet mask
  • $gateway – new gateway
  • $defaultDNS – DNS by default, available from version 7.0.42
  • $subdns – additional DNS, available from version 7.0.42

    After testing, the function returns the result of its work to the script :
  • true – successfully set
  • "NA" – failed to set

    PHP example:

    <?php $xhe_host = "127.0.0.1:7011";
     
    //connect the object to control the emulator, if not already connected
    if(!isset($path))
       $path = "../../../Templates/xweb_human_emulator.php";
    require($path);
     
    //Start
    echo "<hr> <font color = blue> connection->".basename(__FILE__)."</font> <hr>";
     
    //1
    echo "1.Get the internal IP of the machine:";
    echo $beg_ip = $connection->get_local_ip()." n";
     
    //2
    echo "2.Change the settings of the network card:";
    echo $connection->set_local_ip(1, "192.168.1.234", "255.255.255.0", "192.168.1.10", "8.8.8.8", "192.168.1.10")." n";
     
    //3
    echo "3.Get the internal IP of the machine:";
    echo $connection->get_local_ip()." n";
     
    //4
    echo "4.Put ip back:";
    echo $connection->set_local_ip(1, $beg_ip)." n";
     
    //end
    echo "<hr> <br>";
     
    //Quit
    $app->quit();
    ?>

    Python example:

    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
     
    xhe_host = "127.0.0.1:7015"
    from xweb_human_emulator import *
     
    # Start
    echo("<hr> <font color = blue> connection.xxxxxxxxx </font> <hr>")
     
    # 1
    echo("1.Get the internal IP of the machine:");
    beg_ip = connection.get_local_ip()
    echo(beg_ip + "
    ")
     
    # 2
    echo("2.Change ip:")
    echo(connection.set_local_ip(2, "192.168.1.70"), "
    ")
     
    # 3
    echo("3.Get the internal IP of the machine:");
    echo(connection.get_local_ip() + "
    ");
     
    # 4
    echo("4.Let's return ip back:");
    echo(connection.set_local_ip(2, beg_ip), "
    ");
     
    # end
    echo("<hr> <br>")
     
    # Quit
    app.quit()

    C# example:

    #region using
     
    using System;
    using System.Diagnostics;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using System.Text;
    using System.Threading;
     
    using XHE;
    using XHE.XHE_DOM;
    using XHE.XHE_System;
    using XHE.XHE_Window;
    using XHE.XHE_Web;
     
    #endregion
     
     class Program: XHEScript
     {
    static void Main(string [] args)
    {
    //init XHE
    server = "127.0.0.1:7015";
    InitXHE();
     
    //Start
    echo("<hr> <font color = blue> connection.set_local_ip </font> <hr>");
     
               //1
                echo("1.Get the internal IP of the machine:");
                string beg_ip = connection.get_local_ip();
                echo(beg_ip + " n");
     
               //2
                echo("2.Change ip:");
                echo(connection.set_local_ip(2, "192.168.1.70") + " n");
     
               //3
                echo("3.Get the internal IP of the machine:");
                echo(connection.get_local_ip() + " n");
     
               //4
                echo("4.Let's return ip back:");
                echo(connection.set_local_ip(2, beg_ip) + " n");
     
    //end
    echo("<hr> <br>");
     
    app.quit();
    }
    }

    Java Script example:

    //connect the object to control the emulator, if not already connected
    xhe_host = "127.0.0.1:7015";
    echo = require("../../../Templates JS/xweb_human_emulator.js");
     
    //Start
    echo("<hr> <font color = blue> connection.get_real_ip </font> <hr>");
     
    //1
    echo("1.Get the internal IP of the machine:");
    var beg_ip = connection.get_local_ip();
    echo(beg_ip + " n");
     
    //2
    echo("2.Change ip:");
    echo(connection.set_local_ip(2, "192.168.1.70") + " n");
     
    //3
    echo("3.Get the internal IP of the machine:");
    echo(connection.get_local_ip() + " n");
     
    //4
    echo("4.Let's return ip back:");
    echo(connection.set_local_ip(2, beg_ip) + " n");
     
    //end
    echo("<hr> <br>");
     
    //Quit
    app.quit();
  • en/objects/connection/ip/set_local_ip.txt · Last modified: 2026/08/05 22:35 (external edit)