I'm modernizing a legacy application that stores IPv4 addresses in a fixed-size array of unsigned longs. The addresses are stored in host byte order. That is, it is ntohl()
'd when coming from the socket API and htonl()
'd when going to the socket API.
Now in order to support IPv6 as well, I'm wondering what to do with this array.
Whether I should store the string representation, and make it an array of char[INET6_ADDRSTRLEN]
or even a std::vector<std::string>
or std::set<std::string>
to support more addresses.
Or, I could store the in6_addr
structs, which is probably way more efficient to work with than a std::string
, but then I'm wondering how does network and host byte order apply here?