3 // get out master library for gaasd daemon
4 require_once("../lib/lib.php");
6 // first we want to fork into the background like all good daemons should
10 // uncomment this bit and comment the fork above to stop it going into the background
14 // we failed to fork, oh woe is me
16 // i am the parent, i shall leave
17 //echo "i am a parent, i leave\n";
20 // here is where i need to swithc to TCP network protocol stuff
21 // i must bind 127.0.0.1 though.
22 // what i want to happen is this:
23 // 1) server receives connection
24 // 2) server forks off process to process connection
25 // 3) main server continues.
26 // a forked process thingy should be fully self contained and capable of dealing
27 // with "problems", i.e. the parent doesnt want to have to clean up children
29 // Here goes the tcp equivalent
30 global $TCP_PORT_NUMBER;
31 $res = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
32 socket_bind($res, "127.0.0.1", $TCP_PORT_NUMBER);
36 $data_socket = socket_accept($res);
38 $forked = pcntl_fork();
40 // TODO: DEAL WITH THIS PROPERLY
42 echo "Failed to fork\n";
44 // I am the child, i process the request
45 // all the shit down below goes in here