1--TEST-- 2Test if socket_set_option() works, option:SO_SNDTIMEO 3--DESCRIPTION-- 4-wrong params 5-set/get params comparison 6--SKIPIF-- 7<?php 8if (!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); 15if (!$socket) { 16 die('Unable to create AF_INET socket [socket]'); 17} 18socket_set_block($socket); 19 20//wrong params 21try { 22 $retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_SNDTIMEO, []); 23} catch (\ValueError $e) { 24 echo $e->getMessage() . \PHP_EOL; 25} 26 27//set/get comparison 28$options = array("sec" => 1, "usec" => 0); 29$retval_2 = socket_set_option( $socket, SOL_SOCKET, SO_SNDTIMEO, $options); 30$retval_3 = socket_get_option( $socket, SOL_SOCKET, SO_SNDTIMEO); 31 32var_dump($retval_2); 33var_dump($retval_3 === $options); 34socket_close($socket); 35?> 36--EXPECT-- 37socket_set_option(): Argument #4 ($value) must have key "sec" 38bool(true) 39bool(true) 40