1--TEST--
2Test TCP_CONGESTION constant with allowed algos for unprivileged accounts.
3--EXTENSIONS--
4sockets
5--SKIPIF--
6<?php
7if (!defined('TCP_CONGESTION')) {
8    die('skip TCP_CONGESTION test');
9}
10?>
11--FILE--
12<?php
13
14if (str_contains(PHP_OS, 'Linux')) {
15	$algo = 'cubic';
16} else {
17	$algo = 'newreno';
18}
19$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
20if (!$socket) die ("socket failed");
21$r = socket_get_option($socket, SOL_TCP, TCP_CONGESTION);
22echo "current tcp congestion algo " . $r['name'] . "\n";
23var_dump(socket_set_option($socket, SOL_TCP, TCP_CONGESTION, $algo));
24$r = socket_get_option($socket, SOL_TCP, TCP_CONGESTION);
25echo "new tcp congestion algo " . $r['name'];
26?>
27--EXPECTF--
28current tcp congestion algo %s
29bool(true)
30new tcp congestion algo %s
31