OK think I've figured this out based on .. actually reading the above properly :D
I think in the code snippet above, $hostname = "pvelocalhost".
As mentioned by @wbumiller, it picks the family that it sees first and by default this is in /etc/hosts as an IPv4 address.
By making this an...