Mercurial > code
diff C++/SocketAddress.h @ 245:3c12f0e8bbb9
Converter: add cstring missing
Sockets:
* Starts a PIMPL idiom to safely cast Socket with the future SocketSsl and be
able to return a class of type "Socket" whilst the interface returns
effectively a SocketSsl.
* Rename some function to be more cute to use like getDomain -> domain().
* SocketListener now owns completely sockets and must be moved to it, the
dedicated function select() always return a socket owned by SocketListener.
* Operation close is not needed anymore but the function stays in case it's
needed.
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 28 Sep 2014 21:15:26 +0200 |
parents | ce3e1c3d6fed |
children | 9cfa6fbc9c03 |
line wrap: on
line diff
--- a/C++/SocketAddress.h Sat Sep 13 19:42:15 2014 +0200 +++ b/C++/SocketAddress.h Sun Sep 28 21:15:26 2014 +0200 @@ -19,8 +19,6 @@ #ifndef _SOCKET_ADDRESS_H_ #define _SOCKET_ADDRESS_H_ -#include "Socket.h" - /** * @class SocketAddress * @brief base class for socket addresses @@ -28,9 +26,8 @@ * This class is mostly used to bind, connect or getting information * on socket clients. * - * @see BindAddressIP - * @see ConnectAddressIP - * @see AddressUnix + * @see Internet + * @see Unix */ class SocketAddress { protected: @@ -38,9 +35,6 @@ socklen_t m_addrlen; public: - // Friends. - friend class Socket; - /** * Default constructor. */ @@ -57,7 +51,7 @@ /** * Default destructor. */ - virtual ~SocketAddress(); + virtual ~SocketAddress() = default; /** * Get the address length @@ -74,61 +68,37 @@ const sockaddr_storage &address() const; }; -/** - * @class BindAddressIP - * @brief internet protocol bind class - * - * Create a bind address for internet protocol, - * IPv4 or IPv6. - */ -class BindAddressIP : public SocketAddress { -private: - std::string m_host; - int m_family; - unsigned m_port; - -public: - /** - * Create a bind end point. - * - * @param addr the interface to bind - * @param port the port - * @param family AF_INET or AF_INET6 - * @throw SocketError on error - */ - BindAddressIP(const std::string &addr, unsigned port, int family); -}; +namespace address { /** - * @class ConnectAddressIP + * @class Internet * @brief internet protocol connect class * * Create a connect address for internet protocol, * using getaddrinfo(3). */ -class ConnectAddressIP : public SocketAddress { +class Internet final : public SocketAddress { public: /** - * Create a connect end point. + * Create an IPv4 or IPV6 end point. * * @param host the hostname * @param port the port * @param family AF_INET, AF_INET6, ... - * @param type of socket SOCK_STREAM, SOCK_DGRAM, ... * @throw SocketError on error */ - ConnectAddressIP(const std::string &host, unsigned port, int family, int type = SOCK_STREAM); + Internet(const std::string &host, unsigned port, int family); }; #if !defined(_WIN32) /** - * @class AddressUnix + * @class Unix * @brief unix family sockets * * Create an address to a specific path. Only available on Unix. */ -class AddressUnix : public SocketAddress { +class Unix final : public SocketAddress { public: /** * Construct an address to a path. @@ -136,9 +106,11 @@ * @param path the path * @param rm remove the file before (default: false) */ - AddressUnix(const std::string &path, bool rm = false); + Unix(const std::string &path, bool rm = false); }; +} // !address + #endif // ! !_WIN32 #endif // !_SOCKET_ADDRESS_H_