Annotation of embedaddon/php/ext/sockets/tests/socket_set_option_rcvtimeo.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test if socket_set_option() works, option:SO_RCVTIMEO
! 3: --DESCRIPTION--
! 4: -wrong params
! 5: -set/get params comparison
! 6: --SKIPIF--
! 7: <?php
! 8: if (!extension_loaded('sockets')) {
! 9: die('SKIP sockets extension not available.');
! 10: }
! 11: ?>
! 12: --FILE--
! 13: <?php
! 14: $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
! 15: if (!$socket) {
! 16: die('Unable to create AF_INET socket [socket]');
! 17: }
! 18: socket_set_block($socket);
! 19:
! 20: //wrong params
! 21: $retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_RCVTIMEO, array());
! 22:
! 23: //set/get comparison
! 24: $options = array("sec" => 1, "usec" => 0);
! 25: $retval_2 = socket_set_option( $socket, SOL_SOCKET, SO_RCVTIMEO, $options);
! 26: $retval_3 = socket_get_option( $socket, SOL_SOCKET, SO_RCVTIMEO);
! 27:
! 28: var_dump($retval_2);
! 29: var_dump($retval_3 === $options);
! 30: socket_close($socket);
! 31: ?>
! 32:
! 33: --EXPECTF--
! 34: Warning: socket_set_option(): no key "sec" passed in optval in %s on line %d
! 35: bool(true)
! 36: bool(true)
! 37: --CREDITS--
! 38: Moritz Neuhaeuser, info@xcompile.net
! 39: PHP Testfest Berlin 2009-05-10
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>