Search code examples
socketsposixipv6ipv4

Socket for IPV4 mapped to IPV6


What socket family should be used for an IP that looks as follows and it is IP4 mapped to IPV6 as far as I know:

::ffff:171.167.66.44

AF_INET or AF_INET_6

Any useful documentation would be really appreciated. Thanks a lot in advance


Solution

  • This ...

    ::ffff:171.167.66.44

    ... is an IPv4-mapped IPv6 address. It conveys an IPv4 address in IPv6 format, and the address family is thus AF_INET6. That is how you must configure a socket that you will connect to such an address.

    This is useful primarily for a dual-stack machine. It must understand the IPv6-formatted address, and it must communicate with the specified endpoint via IPv4.

    Here is a discussion over on ServerFault: https://serverfault.com/a/1102261.

    Here is what IBM has to say about it in the zOS docs: https://www.ibm.com/docs/en/zos/2.2.0?topic=addresses-ipv4-mapped-ipv6.