Search code examples
c++ipv6

What's the meaning of ipv6 :: address?


In my code, I found that my initial client and server configurations has the ipv6 address: :: (equivalent to 0:0:0:0:0:0:0:0?).

struct SslConfigurations 
{
    std::string         clientIp{"::"};
    std::string         serverIp{"::"};
    UInt16              clientPort{0U};
    UInt16              serverPort{0U};
    ssl::SocketType     type{};
    ssl::SSLReturnCodes errorCode{};
};

What's the meaning of this address? Can I use this address if I don't change it?


Solution

  • It is just a shortcut for the groups of four-zeroes (0000) appearing in the middle, that can be omitted. It's more visible on the example:

    The address 2001:0db8:0000:0000:0000:8a2e:0370:7334 becomes 2001:db8::8a2e:370:7334.

    The :: means 0000:0000:0000:0000:0000:0000:0000:0000.

    The :: address has the same meaning as 0 or 0.0.0.0 in the IPv4 world: It represents all networks.