first working version (one shot version)
[php-ancillary.git] / test001.php
diff --git a/test001.php b/test001.php
new file mode 100755 (executable)
index 0000000..fd2e1f4
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/php
+<?php
+
+$FILE_SOCKET = "/tmp/test001.sock";
+$UNIX_SOCKET = "unix://$FILE_SOCKET";
+if (file_exists($FILE_SOCKET)) {
+    unlink($FILE_SOCKET);
+}
+
+$old_umask = umask(0);
+if (($list = stream_socket_server($UNIX_SOCKET, $err, $errs)) === FALSE) {
+    exit(11);
+}
+umask($old_umask);
+
+$new_socket = stream_socket_accept($list);
+
+$fp = ancillary_getstream($new_socket);
+printf("FP: %d\n", $fp);
+
+
+if ($fp == FALSE)
+    printf("ERROR\n");
+else
+    printf("GOOD\n");
+
+fwrite($fp, "DI QUI CI PASSO2");
+fflush($fp);
+fclose($fp);
+
+?>
\ No newline at end of file