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--FILE--
11<?php
12
13if (str_contains(PHP_OS, 'Linux')) {
14	$algo = 'cubic';
15} else {
16	$algo = 'newreno';
17}
18$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
19if (!$socket) die ("socket failed");
20$r = socket_get_option($socket, SOL_TCP, TCP_CONGESTION);
21echo "current tcp congestion algo " . $r['name'] . "\n";
22var_dump(socket_set_option($socket, SOL_TCP, TCP_CONGESTION, $algo));
23$r = socket_get_option($socket, SOL_TCP, TCP_CONGESTION);
24echo "new tcp congestion algo " . $r['name'];
25?>
26--EXPECTF--
27current tcp congestion algo %s
28bool(true)
29new tcp congestion algo %s
30