1--TEST-- 2testing fsockopen without a protocol string 3--FILE-- 4<?php 5 6echo "Open a server socket\n"; 7for ($i=0; $i<100; $i++) { 8 $port = rand(10000, 65000); 9 /* Setup socket server */ 10 $server = @stream_socket_server("tcp://127.0.0.1:$port"); 11 if ($server) { 12 break; 13 } 14} 15 16echo "\nCalling fsockopen() without a protocol in the hostname string:\n"; 17$hostname = '127.0.0.1'; 18$client = fsockopen($hostname, $port); 19var_dump($client); 20fclose($client); 21 22echo "\nCalling fsockopen() with address and port in same string, without a protocol:\n"; 23$address = $hostname . ':' . $port; 24$second_client = fsockopen($address); 25var_dump($second_client); 26fclose($second_client); 27 28echo "Done"; 29?> 30--EXPECTF-- 31Open a server socket 32 33Calling fsockopen() without a protocol in the hostname string: 34resource(%d) of type (stream) 35 36Calling fsockopen() with address and port in same string, without a protocol: 37resource(%d) of type (stream) 38Done 39