From cced56c77764436592a7ccda33d30c57e6ee5510 Mon Sep 17 00:00:00 2001 From: paulr Date: Fri, 24 Dec 2010 01:53:07 +1100 Subject: [PATCH] added a socket test --- authserver/authd/authd.php | 10 ++++++++++ authserver/lib/authClient.php | 3 +++ unittests/sockettest.php | 26 ++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 0 deletions(-) create mode 100644 unittests/sockettest.php diff --git a/authserver/authd/authd.php b/authserver/authd/authd.php index edd750e..912e12b 100644 --- a/authserver/authd/authd.php +++ b/authserver/authd/authd.php @@ -10,6 +10,8 @@ require_once("../lib/lib.php"); //exit(0); // 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; if($pid == -1) { @@ -19,6 +21,14 @@ if($pid == -1) { echo "i am a parent, i leave\n"; exit(0); } else { + // here is where i need to swithc to TCP network protocol stuff + // i must bind 127.0.0.1 though. + // what i want to happen is this: + // 1) server receives connection + // 2) server forks off process to process connection + // 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 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT; $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT, 0666 | 'IPC_CREAT'); diff --git a/authserver/lib/authClient.php b/authserver/lib/authClient.php index f52221a..539ddc1 100644 --- a/authserver/lib/authClient.php +++ b/authserver/lib/authClient.php @@ -7,6 +7,9 @@ class GAAuthClient { // this functiuon will now act as our generic send/recieve client funciton // im doing this because im going to move from ipc messaging to a tcp connection // shortly and i want to encapsulate the send/receive behaviour + // things we need to add here are: + // 1) a way of saying "more data coming" cause getusers wont fit into one message + // 2) timeouts and locking function sendReceive($message_type, $message) { global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT; diff --git a/unittests/sockettest.php b/unittests/sockettest.php new file mode 100644 index 0000000..f363ce1 --- /dev/null +++ b/unittests/sockettest.php @@ -0,0 +1,26 @@ + -- 1.7.0.4