added the tcp code in, but its not running yet
[ga4php.git] / unittests / socketrecv.php
diff --git a/unittests/socketrecv.php b/unittests/socketrecv.php
new file mode 100644 (file)
index 0000000..6c96d04
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+// a test of binding
+$res = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
+
+socket_bind($res, "127.0.0.1", 10056);
+
+$t = socket_listen($res);
+
+// do sockets work the way i would like?
+while(true) {
+       $res2 = socket_accept($res);
+       
+       $real_str = "";
+       $continue = true;
+       while($continue) {
+               socket_recv($res2, $str, 10, 0);
+               $real_str .= $str;
+               echo "got a bit: $str\n";
+               
+               if(preg_match("/.*\:EOD/", $real_str)) {
+                       echo "we have a full str: $real_str\n";
+                       $continue = false;
+                       break;
+               }
+       }
+       echo "no longer in continue\n";
+}
+?>
\ No newline at end of file