[GIT-PULLS] [php-src] PR #22724: CI: fix unstable test \ext\sockets\tests\socket_recvfrom_afpacket_no_port.phpt

[email protected] (LamentXU123)
Newsgroups php.git-pulls
Message-ID <[email protected]>
Pull Request: https://github.com/php/php-src/pull/22724
Author: LamentXU123

Fix flaky CI: https://github.com/php/php-src/actions/runs/29266463698/job/86873055452

When investigating, I've noticed that similar tests does not have this issue. Only `socket_recvfrom_afpacket_no_port.phpt` is flaky. Which makes me discover a shared logic in tests:

https://github.com/php/php-src/blob/master/ext/sockets/tests/socket_sendto_recvfrom_afpacket_malformed.phpt#L28-L41
```php
<?php
function recv_matching(Socket $s, string $header, int $maxlen = 65536, ?string &$addr = null, &$port = null): string|false {
    socket_set_nonblock($s);
    $deadline = microtime(true) + 5.0;
    while (microtime(true) < $deadline) {
        $bytes = @socket_recvfrom($s, $buf, $maxlen, 0, $addr, $port);
        if ($bytes !== false && is_string($buf) && str_starts_with($buf, $header)) {
            return $buf;
        }
        if ($bytes === false) {
            usleep(1000);
        }
    }
    return false;
}
```
This allows the test to wait for a frame matching its own Ethernet header before asserting the returned address, so it no longer depends on incidental packet ordering. ETH_P_ALL sockets on loopback can observe unrelated localhost traffic.

And this single flack test donesn't have that logic. Let's add them.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.