# HG changeset patch # User David Demelier # Date 1445581906 -7200 # Node ID 44887104242a4d87ba62ff5890564039de6ff00f # Parent 21f1a6ed05702d070f8509636492a4e82fa6f021 Socket: Ip can now be use for generic purposes diff -r 21f1a6ed0570 -r 44887104242a C++/modules/Socket/Sockets.cpp --- a/C++/modules/Socket/Sockets.cpp Fri Oct 23 08:19:09 2015 +0200 +++ b/C++/modules/Socket/Sockets.cpp Fri Oct 23 08:31:46 2015 +0200 @@ -641,8 +641,8 @@ } } +} // !ssl + #endif // SOCKET_NO_SSL -} // !ssl - } // !net diff -r 21f1a6ed0570 -r 44887104242a C++/modules/Socket/Sockets.h --- a/C++/modules/Socket/Sockets.h Fri Oct 23 08:19:09 2015 +0200 +++ b/C++/modules/Socket/Sockets.h Fri Oct 23 08:31:46 2015 +0200 @@ -918,7 +918,7 @@ /** * @class Ip - * @brief Base class for IPv6 and IPv4, don't use it directly + * @brief Base class for IPv6 and IPv4, you can use it if you don't know in advance if you'll use IPv6 or IPv4. */ class Ip { private: @@ -933,13 +933,23 @@ socklen_t m_length{0}; int m_domain{AF_INET}; - Ip(int domain) noexcept; + Ip(const std::string &host, int port, int domain); +public: + /** + * Default initialize the Ip domain. + * + * @param domain the domain (AF_INET or AF_INET6) + */ + Ip(int domain = AF_INET) noexcept; - Ip(const std::string &host, int port, int domain); - + /** + * Construct an address from a storage. + * + * @param ss the storage + * @param length the length + */ Ip(const struct sockaddr_storage *ss, socklen_t length); -public: /** * Return the underlying address, either sockaddr_in6 or sockaddr_in. * @@ -967,7 +977,7 @@ /** * @class Ipv6 - * @brief Use IPv6 address + * @brief Use IPv6 address (helper). */ class Ipv6 : public Ip { public: @@ -1000,22 +1010,11 @@ : Ip{host, port, AF_INET6} { } - - /** - * Construct an address from a storage. - * - * @param ss the storage - * @param length the length - */ - inline Ipv6(const struct sockaddr_storage *ss, socklen_t length) - : Ip{ss, length} - { - } }; /** * @class Ipv4 - * @brief Use IPv4 address + * @brief Use IPv4 address (helper). */ class Ipv4 : public Ip { public: @@ -1048,17 +1047,6 @@ : Ip{host, port, AF_INET} { } - - /** - * Construct an address from a storage. - * - * @param ss the storage - * @param length the length - */ - inline Ipv4(const struct sockaddr_storage *ss, socklen_t length) - : Ip{ss, length} - { - } }; #if !defined(_WIN32) @@ -1727,7 +1715,7 @@ template using SocketTls = Socket; -#endif +#endif // !SOCKET_NO_SSL /* }}} */