removed eronius comment
[ga4php.git] / unittests / sockettest.php
1 <?php
2 // a test of binding
3 $res = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
4
5 socket_bind($res, "127.0.0.1", 10051);
6 while(true) {
7         $t = socket_listen($res);
8         $res2 = socket_accept($res);
9         echo "I went past listen\n";
10         $i = pcntl_fork();
11         if($i == -1) echo "Failed to fork\n";
12         else if (!$i) {
13                 // i am a child
14                 echo "Child processing\n";
15                 while(true) {
16                         socket_send($res2, "stuff\n", 6, 0);
17                         $str = "";
18                         echo "Child wait data\n";
19                         $k = socket_recv($res2, $str, 16, MSG_WAITALL);
20                         echo "Child got data\n";
21                         socket_send($res2, $str, $k, 0);
22                 }
23         }
24 }
25
26 ?>