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");
9 die('Unable to create AF_UNIX socket [server]');
13 $client = stream_socket_client("unix:///tmp/$uniqid.sock");
15 die('Unable to create AF_UNIX socket [client]');
18 /* Accept that connection */
19 $socket = stream_socket_accept($server);
21 die('Unable to accept connection');
24 fwrite($client, "ABCdef123\n");
26 $data = fread($socket, 10);
32 unlink("/tmp/$uniqid.sock");