1--TEST--
2Streams Based Unix Domain Datagram Loopback test
3--SKIPIF--
4<?php # vim:ft=php:
5	if (array_search("udg",stream_get_transports()) === false)
6		die('SKIP No support for UNIX domain sockets.');
7?>
8--FILE--
9<?php
10	$uniqid = uniqid();
11	if (file_exists("/tmp/$uniqid.sock"))
12		die('Temporary socket /tmp/$uniqid.sock already exists.');
13
14	/* Setup socket server */
15	$server = stream_socket_server("udg:///tmp/$uniqid.sock", $errno, $errstr, STREAM_SERVER_BIND);
16	if (!$server) {
17		die('Unable to create AF_UNIX socket [server]');
18	}
19
20	/* Connect to it */
21	$client = stream_socket_client("udg:///tmp/$uniqid.sock");
22	if (!$client) {
23		die('Unable to create AF_UNIX socket [client]');
24	}
25
26	fwrite($client, "ABCdef123\n");
27
28	$data = fread($server, 10);
29	var_dump($data);
30
31	fclose($client);
32	fclose($server);
33	unlink("/tmp/$uniqid.sock");
34?>
35--EXPECT--
36string(10) "ABCdef123
37"
38