Mercurial > code
changeset 442:44887104242a
Socket: Ip can now be use for generic purposes
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 23 Oct 2015 08:31:46 +0200 |
parents | 21f1a6ed0570 |
children | 9c85d9158990 |
files | C++/modules/Socket/Sockets.cpp C++/modules/Socket/Sockets.h |
diffstat | 2 files changed, 20 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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 <typename Address> using SocketTls = Socket<Address, Tls>; -#endif +#endif // !SOCKET_NO_SSL /* }}} */