i dont believe, i switched to tcp and it seems to WORK
[ga4php.git] / authserver / authd / authd.php
index f5e35e9..6156a5e 100644 (file)
@@ -11,6 +11,7 @@ require_once("../lib/lib.php");
 // first we want to fork into the background like all good daemons should
 //$pid = pcntl_fork();
 
+
 // uncomment this bit and comment the fork above to stop it going into the background
 $pid = 0;
 
@@ -29,17 +30,21 @@ if($pid == -1) {
        // 3) main server continues.
        // a forked process thingy should be fully self contained and capable of dealing
        // with "problems", i.e. the parent doesnt want to have to clean up children
+       
+       /* TCP TEST
        global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
-       global $TCP_PORT_NUMBER;
+       
        
        $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT, 0666 | 'IPC_CREAT');
        $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER, 0666 | 'IPC_CREAT');
+       */
        
        // Here goes the tcp equivalent
-       /*
+       global $TCP_PORT_NUMBER;
        $res = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
-       socket_bind($res, "127.0.0.1", 10056);
+       socket_bind($res, "127.0.0.1", $TCP_PORT_NUMBER);
        socket_listen($res);
+       echo "am now listneing\n";
 
        while(true) {
                $data_socket = socket_accept($res);
@@ -57,7 +62,7 @@ if($pid == -1) {
                        while($continue) {
                                $size = socket_recv($data_socket, $recvd_a, 1024, 0);
                                $recvd .= $recvd_a;
-                               if(preg_match("/.*\:EOD$/", $recvd) {
+                               if(preg_match("/.*\:EOD$/", $recvd)) {
                                        // we have a full string... break out
                                        $continue = false;
                                        break;
@@ -71,6 +76,10 @@ if($pid == -1) {
                        $msg_type = $component["type"];
                        $msg = $component["data"];
 
+                       echo "I now have a message of $msg_type\n";
+                       echo "with data:\n";
+                       print_r($msg);
+                       echo "eof\n";
                        // the switch should now set a $data_returned value that gets bundled up and sent back to the client
                        // HERES WHERE THE SWITCH GOES
                        // ******
@@ -474,8 +483,8 @@ if($pid == -1) {
                }
                // otherwise return to the accept loop
        }
-       
-       */
+}
+       /*
 
        $myga = new gaasGA();
        global $myga;
@@ -869,7 +878,10 @@ if($pid == -1) {
                                break;
                                
                }               
+               
        }       
+       
 }
+*/
 
 ?>