support for php5.6.30
[php-ancillary.git] / test001.php
index fd2e1f4..4a829b5 100755 (executable)
@@ -15,17 +15,33 @@ umask($old_umask);
 
 $new_socket = stream_socket_accept($list);
 
-$fp = ancillary_getstream($new_socket);
+$stream_info = "";
+
+$fp = ancillary_getstream($new_socket, $stream_info);
 printf("FP: %d\n", $fp);
 
+stream_set_blocking ($fp, FALSE);
 
 if ($fp == FALSE)
     printf("ERROR\n");
 else
     printf("GOOD\n");
 
-fwrite($fp, "DI QUI CI PASSO2");
+$from = fread($fp, 4096);
+printf("FROM: [%s]\n", $from);
+
+$body = "<html><title>Ancillary Test 001</title><body>HERE I AM</body></html>\n";
+
+fwrite($fp, "HTTP/1.0 200 OK\r\n");
+fwrite($fp, "Content-type: text/html\r\n");
+fwrite($fp, "X-Savannah: rapatal\r\n");
+// fwrite($fp, sprintf("Content-length: %d\r\n", strlen($body)));
+fwrite($fp, "\r\n");
+
+fwrite($fp, $body);
+
 fflush($fp);
 fclose($fp);
 
-?>
\ No newline at end of file
+print_r($stream_info);
+?>