added the tcp code in, but its not running yet
[ga4php.git] / unittests / socketrecv.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", 10056);
6
7 $t = socket_listen($res);
8
9 // do sockets work the way i would like?
10 while(true) {
11         $res2 = socket_accept($res);
12         
13         $real_str = "";
14         $continue = true;
15         while($continue) {
16                 socket_recv($res2, $str, 10, 0);
17                 $real_str .= $str;
18                 echo "got a bit: $str\n";
19                 
20                 if(preg_match("/.*\:EOD/", $real_str)) {
21                         echo "we have a full str: $real_str\n";
22                         $continue = false;
23                         break;
24                 }
25         }
26         echo "no longer in continue\n";
27 }
28 ?>