1--TEST--
2Streams Based IPv4 UDP Loopback test
3--FILE--
4<?php
5    /* Setup socket server */
6    for ($port = 31338; $port < 31500; ++$port) {
7      $uri = "udp://127.0.0.1:$port";
8      $server = @stream_socket_server($uri, $errno, $errstr, STREAM_SERVER_BIND);
9      if ($server) break;
10    }
11    if (!$server) {
12        die('Unable to create AF_INET socket [server]: ' . $errstr);
13    }
14
15    /* Connect to it */
16    $client = stream_socket_client($uri);
17    if (!$client) {
18        die('Unable to create AF_INET socket [client]');
19    }
20
21    fwrite($client, "ABCdef123\n");
22
23    $data = fread($server, 10);
24    var_dump($data);
25
26    fclose($client);
27    fclose($server);
28?>
29--EXPECT--
30string(10) "ABCdef123
31"
32