1--TEST-- 2Streams Based IPv4 TCP Loopback test 3--FILE-- 4<?php # vim:ft=php: 5 /* Setup socket server */ 6 $server = stream_socket_server('tcp://127.0.0.1:31337'); 7 if (!$server) { 8 die('Unable to create AF_INET socket [server]'); 9 } 10 11 /* Connect to it */ 12 $client = stream_socket_client('tcp://127.0.0.1:31337'); 13 if (!$client) { 14 die('Unable to create AF_INET socket [client]'); 15 } 16 17 /* Accept that connection */ 18 $socket = stream_socket_accept($server); 19 if (!$socket) { 20 die('Unable to accept connection'); 21 } 22 23 fwrite($client, "ABCdef123\n"); 24 25 $data = fread($socket, 10); 26 var_dump($data); 27 28 fclose($client); 29 fclose($socket); 30 fclose($server); 31?> 32--EXPECT-- 33string(10) "ABCdef123 34" 35