1--TEST--
2Test if socket_set_option() works, option:SO_SEOLINGER
3--DESCRIPTION--
4-wrong params
5-set/get params comparison
6-l_linger not given
7--SKIPIF--
8<?php
9if (!extension_loaded('sockets')) {
10        die('SKIP sockets extension not available.');
11}
12?>
13--FILE--
14<?php
15$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
16
17if (!$socket) {
18        die('Unable to create AF_INET socket [socket]');
19}
20// wrong params
21$retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_LINGER, array());
22
23// set/get comparison
24$options = array("l_onoff" => 1, "l_linger" => 1);
25$retval_2 = socket_set_option( $socket, SOL_SOCKET, SO_LINGER, $options);
26$retval_3 = socket_get_option( $socket, SOL_SOCKET, SO_LINGER);
27
28//l_linger not given
29$options_2 = array("l_onoff" => 1);
30var_dump(socket_set_option( $socket, SOL_SOCKET, SO_LINGER, $options_2));
31
32var_dump($retval_2);
33var_dump($retval_3 === $options);
34
35socket_close($socket);
36?>
37
38--EXPECTF--
39Warning: socket_set_option(): no key "l_onoff" passed in optval in %s on line %d
40
41Warning: socket_set_option(): no key "l_linger" passed in optval in %s on line %d
42bool(false)
43bool(true)
44bool(true)
45--CREDITS--
46Moritz Neuhaeuser, info@xcompile.net
47PHP Testfest Berlin 2009-05-10
48