1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/sockets/tests/socket_cmsg_udp_segment.phpt
David Carlier 4671f8510c ext/sockets: UDP_SEGMENT support.
UDP segmentation offload is an optimisation attempt by sending multiple
large enough datagrams over UDP which reduces syscalls as by default,
they have to be broke down in small UDP packets, it is better if the
hardware supports it, other handed down to the software implementation.

close GH-18213
2025-05-22 20:32:29 +01:00

27 lines
665 B
PHP

--TEST--
UDP_SEGMENT setsockopt(), can't really test is as the kernel support might not be enabled.
--EXTENSIONS--
sockets
--SKIPIF--
<?php
if (!defined('UDP_SEGMENT')) { die('skip UDP_SEGMENT is not defined'); }
?>
--FILE--
<?php
$src = socket_create(AF_UNIX, SOCK_DGRAM, 0);
try {
socket_setopt($src, SOL_UDP, UDP_SEGMENT, -1);
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}
try {
socket_setopt($src, SOL_UDP, UDP_SEGMENT, 65536);
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
socket_setopt(): Argument #4 ($value) must be of between 0 and 65535
socket_setopt(): Argument #4 ($value) must be of between 0 and 65535