s1 = php_stream_sock_open_from_socket(pair[0], 0);
s2 = php_stream_sock_open_from_socket(pair[1], 0);
+ /* set the __exposed flag.
+ * php_stream_to_zval() does, add_next_index_resource() does not */
+ php_stream_auto_cleanup(s1);
+ php_stream_auto_cleanup(s2);
+
add_next_index_resource(return_value, php_stream_get_resource_id(s1));
add_next_index_resource(return_value, php_stream_get_resource_id(s2));
}
--- /dev/null
+--TEST--
+stream_socket_pair()
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip: non windows test");
+?>
+--FILE--
+<?php
+$sockets = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, 0);
+var_dump($sockets);
+fwrite($sockets[0], b"foo");
+var_dump(fread($sockets[1], strlen(b"foo")));
+fclose($sockets[0]);
+?>
+--EXPECTF--
+array(2) {
+ [0]=>
+ resource(%d) of type (stream)
+ [1]=>
+ resource(%d) of type (stream)
+}
+string(3) "foo"