I've got a problem associated with socket and PHP process termination among execution of script.Please browse the problem (sorry for that lengthy question).

Telecom equipment1<---SOCKET1--->Web Server<--------->Client Browser
Telecom equipment2<---SOCKET2--->

Objective: -Run $num_iteration testcases on all tools.

Implemented Process: -Send Run request(AJAX call) by browser with numerous testcases and $num_iteration(say 1000 occasions repeat same quantity of testcases).PHP opens socket for every equipment and runs testcases on all.

Problem: -PHP process begins running and performing testcases after AJAX request. -Among i can not steer clear of the execution (Despite closing the browser, PHP code works on the server).

Note: I'm running Apache on home windows machine.

What workaround i'm doing at this time: get rid of the apache process but that is a worst idea.

Some solution which i think although not sure how you can implement:

-Store process id and when user wish to terminate the execution, he/she will send the procedure id towards the server and server will get rid of the process. (could it be advisable? how do i implement for home windows machine?).

-Check should_i_run flag in the database before you run each testcase. If user really wants to terminate the procedure, he/she will alter the should_i_run flag in DB with a request. This appears to become a fair idea but performance smart again it will likely be little effect on the execution.

  <before each testcase execution>
  <check should_i_run from DB>--yes-->fputs($this->socketResource,$command);

This is actually the small area of the code that i'm running:

for($i =1; $i <= $num_iteration; $i++){
        foreach($operation as $key => $value){
       //other code