What's the meaning of ipv6 :: address?

Viewed 89

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?

2 Answers

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.

:: is a convenient way of writing the unspecified IPv6 address, which is an all-zeroes guard-value that is used to indicate the absence of a valid address.

Here's the relevant quote from IBM's online documentation:

The unspecified address is 0:0:0:0:0:0:0:0. You can abbreviate the address with two colons (::). The unspecified address indicates the absence of an address, and it can never be assigned to a host. It can be used by an IPv6 host that does not yet have an address assigned to it. For example, when the host sends a packet to discover if an address is used by another node, the host uses the unspecified address as its source address.

Related