import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-network / unixloop.php
blob0b851f1225bca872cef450e1f8db284dc2251048
1 <?php
2 $uniqid = uniqid();
3 if (file_exists("/tmp/$uniqid.sock"))
4 die('Temporary socket already exists.');
6 /* Setup socket server */
7 $server = stream_socket_server("unix:///tmp/$uniqid.sock");
8 if (!$server) {
9 die('Unable to create AF_UNIX socket [server]');
12 /* Connect to it */
13 $client = stream_socket_client("unix:///tmp/$uniqid.sock");
14 if (!$client) {
15 die('Unable to create AF_UNIX socket [client]');
18 /* Accept that connection */
19 $socket = stream_socket_accept($server);
20 if (!$socket) {
21 die('Unable to accept connection');
24 fwrite($client, "ABCdef123\n");
26 $data = fread($socket, 10);
27 var_dump($data);
29 fclose($client);
30 fclose($socket);
31 fclose($server);
32 unlink("/tmp/$uniqid.sock");