i dont believe, i switched to tcp and it seems to WORK
authorpaulr <me@pjr.cc>
Thu, 23 Dec 2010 16:20:08 +0000 (03:20 +1100)
committerpaulr <me@pjr.cc>
Thu, 23 Dec 2010 16:20:08 +0000 (03:20 +1100)
authserver/authd/authd.php
authserver/lib/authClient.php
authserver/lib/lib.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;
                                
                }               
+               
        }       
+       
 }
+*/
 
 ?>
index e43d2cc..4f398ac 100644 (file)
@@ -12,7 +12,7 @@ class GAAuthClient {
        // 2) timeouts and locking
        
        // io think this function should now "work" more or less as is
-       function sendReceiveTcp($message_type, $message) {
+       function sendReceive($message_type, $message) {
                // yeah... this is totally gunna work
                global $TCP_PORT_NUMBER;
                
@@ -29,7 +29,7 @@ class GAAuthClient {
                $datacomp = base64_encode(serialize($msg));
                $tosend = "AC:$datacomp:EOD";
                
-               socket_send($socket, $tosend, strlen($tosend));
+               socket_send($socket, $tosend, strlen($tosend), 0);
                
                // get up to one meg of data - this is bad... i can feel this function
                // hurting alot
@@ -41,7 +41,7 @@ class GAAuthClient {
                while($continue) {
                        $size = socket_recv($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,7 +71,7 @@ class GAAuthClient {
                return $component["data"];
        }
        
-       function sendReceive($message_type, $message) {
+       function sendReceiveIPC($message_type, $message) {
                global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
                
                
index bbdc186..3a55a6c 100644 (file)
@@ -4,7 +4,7 @@ if(!isset($MSG_QUEUE_KEY_ID_SERVER)) $MSG_QUEUE_KEY_ID_SERVER = "189751072"; //
 if(!isset($MSG_QUEUE_KEY_ID_CLIENT)) $MSG_QUEUE_KEY_ID_CLIENT = "189751073"; // ftok is not ok!
 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
 
-if(!isset($TCP_PORT_NUMBER)) $TCP_PORT_NUMBER = 21416;
+if(!isset($TCP_PORT_NUMBER)) $TCP_PORT_NUMBER = 21446;
 global $TCP_PORT_NUMBER;
 
 define("MSG_AUTH_USER_TOKEN", 1);