Return to fsockopen_basic.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / network |
1.1 misho 1: --TEST-- 2: Test fsockopen() function : basic functionality 3: --FILE-- 4: <?php 5: /* Prototype : proto resource fsockopen(string hostname, int port [, int errno [, string errstr [, float timeout]]]) 6: * Description: Open Internet or Unix domain socket connection 7: * Source code: ext/standard/fsock.c 8: * Alias to functions: 9: */ 10: 11: echo "*** Testing fsockopen() : basic functionality ***\n"; 12: 13: echo "Open a server socket\n"; 14: $server = stream_socket_server('tcp://127.0.0.1:31337'); 15: 16: 17: // Initialise all required variables 18: $hostname = 'tcp://127.0.0.1'; // loopback address 19: $port = 31337; 20: $errno = null; 21: $errstr = null; 22: $timeout = 1.5; 23: 24: echo "\nCalling fsockopen() with all possible arguments:\n"; 25: $client = fsockopen($hostname, $port, $errno, $errstr, $timeout); 26: var_dump($client); 27: fclose($client); 28: 29: echo "\nCalling fsockopen() with mandatory arguments:\n"; 30: $second_client = fsockopen($hostname, $port); 31: var_dump($second_client); 32: fclose($second_client); 33: 34: echo "\nCalling fsockopen() with address and port in same string:\n"; 35: $address = $hostname . ':' . $port; 36: $third_client = fsockopen($address); 37: var_dump($third_client); 38: fclose($third_client); 39: 40: echo "Done"; 41: ?> 42: --EXPECTF-- 43: *** Testing fsockopen() : basic functionality *** 44: Open a server socket 45: 46: Calling fsockopen() with all possible arguments: 47: resource(%d) of type (stream) 48: 49: Calling fsockopen() with mandatory arguments: 50: resource(%d) of type (stream) 51: 52: Calling fsockopen() with address and port in same string: 53: resource(%d) of type (stream) 54: Done