1--TEST-- 2testing fsockopen() with udp sockets 3--FILE-- 4<?php 5 6$hostname = 'udp://127.0.0.1'; 7$port = '31337'; 8 9echo "Open a server socket\n"; 10$server = stream_socket_server($hostname . ':' . $port, $errno, $errstr, STREAM_SERVER_BIND); 11 12echo "\nCalling fsockopen():\n"; 13$client = fsockopen($hostname, $port); 14var_dump($client); 15 16echo "\nPass some data between the sockets:\n"; 17fwrite($client, "0123456789"); 18var_dump(fread($server, 10)); 19fclose($client); 20 21echo "\nCalling fsockopen() with address and port in same string:\n"; 22$address = $hostname . ':' . $port; 23$second_client = fsockopen($address); 24var_dump($second_client); 25 26echo "\nPass some data between the sockets:\n"; 27fwrite($second_client, "0123456789"); 28var_dump(fread($server, 10)); 29fclose($second_client); 30 31echo "Done"; 32 33?> 34--EXPECTF-- 35Open a server socket 36 37Calling fsockopen(): 38resource(%d) of type (stream) 39 40Pass some data between the sockets: 41string(10) "0123456789" 42 43Calling fsockopen() with address and port in same string: 44resource(%d) of type (stream) 45 46Pass some data between the sockets: 47string(10) "0123456789" 48Done 49