(Please close this thread if duplicate, I tried hard, but couldn't find any matching question)
It seems some OS/platforms listen for both IPv6 and IPv4 (tcp) connections when bound to IPv6 widcard address, while some listen for only IPv6, as mentioned in:
with the following lines:
If your platform does not support disabling this option but you still want to listen for both AF_INET and AF_INET6 connections you will have to create two listening sockets, one bound to each protocol
And in the section "How IPv6 Works on a Java Platform"
And as per correct answer in this SO question
Now I want to write some Perl code which can determine if the underlying OS/platform listens for both IPv6 and IPv4 (if bound to IPv6), if yes, I'll bind to IPv6 only, if no I'll create 2 sockets (1 for IPv4 and another for IPv6).
I wonder what could be the best way for this?
As mentioned in IO::Socket::IP I could use
if( IO::Socket::IP->CAN_DISABLE_V6ONLY ) {
...
}
else {
...
}
But, I am not sure if it will tell me exactly
if the underlying OS/platform listens for both IPv6 and IPv4 (if bound to IPv6)
Or it will just tells that the
IPV6_V6ONLY socket option cannot be disabled