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