Loop temporized Client1.html and Server1.php

Hello.
I started testing ExeOutput for PHP and I have some doubts that I detail below.
My project is more complex but as an example I show two scripts called Client1.html and Server1.php

The screen of Client1.html has two fields and a button as shown:

And this is the code:

Client1 form { width:400px; height:auto; margin:20px; resize: none; background-color:gray; padding:20px; } input {text-align:right; }
</head>

 <body onLoad="init();">
    <form name="f">
    Client Time: <input type="text" name="ctime" size="30"/>
    <br/><br/>
    Server Time: <textarea id="stime" name="stim" rows="2" cols="30" style="overflow:auto;resize:none"></textarea>
    <br/><br/>
    <input type="button" value="Start" onClick="serveron();">
    </p>
    </form>
</body>

And Server1.php code is this:

<?php set_time_limit (0); error_reporting(E_ALL); $comand = $_POST['comand']; $crlf = chr(13).chr(10); //CRLF $t3 = 0; $t2 = 0; $t1 = time(); $ho = date ("h:i:s",time ()); if (!isset($comand)){ $t2 = $t1 + 10; //if not comand, set time to 10 Sec } else { $t3 = intval(trim($comand)); // $t2 = $t1 + $t3; // } //--- Starting $_post temporized loop while ($t2 > $t1){ $t1 = time(); $ho = date ("h:i:s",time ()); $dt = $t2 - $t1; $b = fopen("sermsg.txt", "w"); //report Server1 status fwrite($b, "S1-Time: ".$ho.$crlf."TimeOut: ".$dt.$crlf); fclose($b); usleep(1000000); //sleep 1 Sec. } $b = fopen("sermsg.txt", "w"); //Server1 out msg fwrite($b, "S1 Out: ".$ho.$crlf."TimeOut: ".$dt.$crlf); fclose($b); ?>

Client Time field on Client1.html shows the local time clock using the functions:

    setInterval(showwatch,1000);

and:

function showwatch()
 {
    var t = new Date();
    var m = "";
    var s = "";
    if (t.getMinutes() < 10) {
        m = "0"; }
    if (t.getSeconds() < 10) {
        s = "0"; }
    document.f.ctime.value = "["+tflag+"] "+t.getHours()+":"+m+t.getMinutes()+":"+s+t.getSeconds();

and Time Server field displays the server time clock Server1.PHP using jQuery function:

            $('#stime').load('sermsg.txt');

In sermsg.txt text file, the Server1.php records a string informing his local time and timeout (remaining execution time in seconds) with the code:

fwrite($b, "S1-Time: ".$ho.$crlf."TimeOut: ".$dt.$crlf);	 

The starting instant and execution time on Server 1.php are passed when the Start button is pressed, through the code:

            comand = "60" // 1 min. execution time
            urlser = "http://localhost/server1.php";  //
            sendComand(comand, urlser); // AJAX Object called

and invoking the Ajax object, is passed the time seconds parameter to Server1.php, charging it as a variable loop execution.
During the time the Server1.php are running the loop, shown in the Time Server field, his local time clock and decreasing his counter Time Out
When the loop ends, S1 Out and TimeOut: 0 are shown in Time Server field.

This example with these two scripts works perfectly on localhost environment (folder C: \ wamp \ www).

The localhost folder is showen:

But about EXEOUTPUT for PHP, It does not work if both scripts are compiled together with ExeOutput creating a single Client1.exe with Server1.php embedded, and I understand that is because both scripts run simultaneously while Server1 is in execution time.

As a possible solution, would try to compile both scripts separated, ¿or may be another suggestion?

So ¿what would be the changes in the code of both scripts Client1 and Server1 that allow them to run as Client1.exe as Server1.exe in the same way that scripts work on localhost environment?

Thanks in advance

Excuse me, the complete Client1.html code was not posted complete.
Here is the complete code (I have problems with the post editor):

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Client1</title>
<style>
form {
    width:400px;
    height:auto;
    margin:20px;
    resize: none;
    background-color:gray;
    padding:20px;
    }
input {text-align:right; }
</style>

< script type=“text/javascript” src=“jquery-1.7.1.min.js”>

< script type=“text/javascript”>

    var tflag = 0; //
    var urlser = "";
    var comand = "";


function init() {
    setInterval(showwatch,1000);
    }

function serveron(){
    tflag = 100;  //
    }

function showwatch()
 {
    var t = new Date();
    var m = "";
    var s = "";
    if (t.getMinutes() < 10) {
        m = "0"; }
    if (t.getSeconds() < 10) {
        s = "0"; }
    document.f.ctime.value = t.getHours()+":"+m+t.getMinutes()+":"+s+t.getSeconds();

    switch(tflag) {
        case 0:  //
			break;
        case 10:  //
            $('#stime').load('sermsg.txt');
			break;
        case 100: //
            tflag = 10; //
            comand = "60" // 1 min.
            urlser = "http://localhost/server1.php";  //
            sendComand(comand, urlser); //
            break;
        default:
            break;
        }
 }


function objetoAjax(){
    var xmlhttp = false;
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {

        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            xmlhttp = false; }
    }

    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
      xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp;
}

function sendComand(comand, urlser)

{

    ajax = objetoAjax();

    ajax.open("POST", urlser, true);

    ajax.onreadystatechange = function() {

        if (ajax.readyState == 4){

            rmsg = (ajax.responseText); 
        }
    }

    ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

    ajax.send("&comand="+comand);  //send mens.

}

 <body onLoad="init();">
    <form name="f">
    Client Time: <input type="text" name="ctime" size="30"/>
    <br/><br/>
    Server Time: <textarea id="stime" name="stim" rows="2" cols="30" style="overflow:auto;resize:none"></textarea>
    <br/><br/>
    <input type="button" value="Start" onClick="serveron();">
    </p>
    </form>
</body>

It looks like your project is using AJAX. There is a known problem with AJAX in Chromium. Are you using the Chromium or Trident engine in ExeOutput?

As picture show

I tried with both engines getting some differences.

In case Trident (Client1_Tri.exe), after Start button

Time Server field shows the last message of the script Server1, when its loop ends.

In case Chromium (Client1_Cro.exe), after Start button

in the Time Server field displays nothing.

Furthermore, in no case the executable runs as do the scripts in the localhost environment, as already I described.

So I would like to know how to get two separate executable Client1.exe and Server1.exe functioning like scripts.

What changes should be made in the script prior to compilation, for example in the lines:

     urlser = "http: //localhost/server1.php";

and

      $ comand = $ _POST ['comand'];

and some other change required.

Thanks in advance.

It’s difficult to help without having the full project and files. But some thoughts:

You open a file:

b = fopen("sermsg.txt", "w");  //Server1 out msg
fwrite($b, "S1 Out: ".$ho.$crlf."TimeOut: ".$dt.$crlf);	 
fclose($b);

But where is created that file? Since writing files on destination computer is limited, you should use the special folder provided by ExeOutput to write files. See the doc or starting guide.

Also, http://localhost doesn’t exist in compiled publications. We don’t use a local connection, so localhost has nothing to do with ExeOutput. The built-in namespace is http://heserver/

I understand that http://localhost does not exist in compiled publications.
But with changing http://localhost by http://heserver, the project also does not work compiled
but its works with scripts without compiling.

Thanks for your tips