PHP fsockopen : How to connect to an external IPv6 address?

Hello,

In a PHP script running on my OVHCloud "Hébergement Perso", I use fsockopen towards an external server. When I use the IPv4 address of that server, my script works fine. That server (an RPi behind SFR box) will lose soon its IPv4 address and I need now to use its IPv6 address in my script.

I tried several syntax with the IPv6 address:
$fp = fsockopen("2a02:…4]", 1042, $errNo, $errStr, 10);
$fp = fsockopen("2a02:…4", 1042, $errNo, $errStr, 10);
$fp = fsockopen("tcp://[2a02:…4]", 1042, $errNo, $errStr, 10);
etc
But they all fail, PHP (PHP7.3, PHP8.0, …) says :
php_network_getaddresses: getaddrinfo for 2a02:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxx4 failed: Address family for hostname not supported (0)

My issue is similar to [this past one
but there is no solution posted there.

I'm sure the IPv6 address is correct, as I can successfully connect to it with netcat from anywhere.

Thanks for your help,
Jerome