Annotation of embedaddon/php/ext/standard/tests/network/fsockopen_basic.phpt, revision 1.1.1.2

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: 
1.1.1.2 ! misho      15: for ($i=0; $i<100; $i++) {
        !            16:   $port = rand(10000, 65000);
        !            17:   /* Setup socket server */
        !            18:   $server = @stream_socket_server("tcp://127.0.0.1:$port");
        !            19:   if ($server) {
        !            20:     break;
        !            21:   }
        !            22: }
1.1       misho      23: 
                     24: // Initialise all required variables
                     25: $hostname = 'tcp://127.0.0.1'; // loopback address
                     26: $errno = null;
                     27: $errstr = null;
                     28: $timeout = 1.5;
                     29: 
                     30: echo "\nCalling fsockopen() with all possible arguments:\n";
                     31: $client = fsockopen($hostname, $port, $errno, $errstr, $timeout);
                     32: var_dump($client);
                     33: fclose($client);
                     34: 
                     35: echo "\nCalling fsockopen() with mandatory arguments:\n";
                     36: $second_client = fsockopen($hostname, $port);
                     37: var_dump($second_client);
                     38: fclose($second_client);
                     39: 
                     40: echo "\nCalling fsockopen() with address and port in same string:\n";
                     41: $address = $hostname . ':' . $port;
                     42: $third_client = fsockopen($address);
                     43: var_dump($third_client);
                     44: fclose($third_client);
                     45: 
                     46: echo "Done";
                     47: ?>
                     48: --EXPECTF--
                     49: *** Testing fsockopen() : basic functionality ***
                     50: Open a server socket
                     51: 
                     52: Calling fsockopen() with all possible arguments:
                     53: resource(%d) of type (stream)
                     54: 
                     55: Calling fsockopen() with mandatory arguments:
                     56: resource(%d) of type (stream)
                     57: 
                     58: Calling fsockopen() with address and port in same string:
                     59: resource(%d) of type (stream)
                     60: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>