X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FProtocols%2FINet%2FINetAddressing.hh;h=e1095fdd381bc320923a6c68f6516dea44f444c3;hb=1ad3873b372da6187b1fbc645bf276287d2efb54;hp=e3a95d337488171c156bc6a5ee1ced265f159d1b;hpb=fa696fb7164ff243f6b7c1c5bda35ed75af153dc;p=senf.git diff --git a/Socket/Protocols/INet/INetAddressing.hh b/Socket/Protocols/INet/INetAddressing.hh index e3a95d3..e1095fd 100644 --- a/Socket/Protocols/INet/INetAddressing.hh +++ b/Socket/Protocols/INet/INetAddressing.hh @@ -32,10 +32,11 @@ #include #include #include -#include "Socket/SocketPolicy.hh" -#include "Socket/ClientSocketHandle.hh" -#include "Socket/CommunicationPolicy.hh" -#include "Socket/Protocols/GenericAddressingPolicy.hh" +#include "../../../Socket/SocketPolicy.hh" +#include "../../../Socket/ClientSocketHandle.hh" +#include "../../../Socket/CommunicationPolicy.hh" +#include "../../../Socket/Protocols/GenericAddressingPolicy.hh" +#include "../../../Utils/safe_bool.hh" #include "INet4Address.hh" #include "INet6Address.hh" @@ -56,20 +57,20 @@ namespace senf { */ class INet4SocketAddress : public boost::equality_comparable, - public senf::ComparableSafeBool + public senf::comparable_safe_bool { public: INet4SocketAddress(); - explicit INet4SocketAddress(std::string const & address); ///< Set address and port + explicit INet4SocketAddress(std::string const & addr); ///< Set address and port /**< This constructor expects a string of the form 'host:port'. The constructor will use this value to initialize the host and port members. Since it uses the INet4Address::from_string constructor, this call may block while waiting for the resolver. - \throws SyntaxException if the 'host:port' syntax is - not obeyed. - \throws INet4Address::SyntaxException if the host part - cannot be converted to an IP address. */ + \throws SyntaxException if the address syntax is + invalid + \throws INet4Address::UnknownHostnameException if the + address cannot be resolved. */ INet4SocketAddress(INet4Address const & addr, unsigned port); ///< Set address and port explicitly @@ -82,7 +83,7 @@ namespace senf { INet4Address address() const; ///< Return address unsigned port() const; ///< Return port number - bool boolean_test() const; ///< \c true, if address is empty (i.e. 0.0.0.0:0) + bool boolean_test() const; ///< \c true, if address is not empty (i.e. 0.0.0.0:0) void clear(); ///< Clear address/port to 0.0.0.0:0 @@ -100,7 +101,7 @@ namespace senf { struct SyntaxException : public std::exception { virtual char const * what() const throw() - { return "Invalid IpV4 socket address syntax"; } }; + { return "Invalid IPv4 socket address syntax"; } }; private: struct ::sockaddr_in addr_; @@ -154,14 +155,21 @@ namespace senf { ///@{ INet6SocketAddress(); ///< Create empty instance - explicit INet6SocketAddress(std::string const & addr); + explicit INet6SocketAddress(std::string const & addr, + INet6Address::Resolve_t resolve = INet6Address::ResolveINet6); ///< Initialize/convert from string representation + /**< \throws SyntaxException if the address syntax is + invalid + \throws INet6Address::UnknownHostnameException if the + address cannot be resolved. + \param[in] addr Address to parse + \param[in] resolve If this is + INet6Address::ResolveINet4, support IPv4 + addresses. See INet6Address. */ INet6SocketAddress(INet6Address const & addr, unsigned port); ///< Initialize from address and port INet6SocketAddress(INet6Address const & addr, unsigned port, std::string const & iface); ///< Initialize explicitly from given parameters - INet6SocketAddress(std::string const & addr, std::string const & iface); - ///< Initialize from URL representation and explit interface ///@} /////////////////////////////////////////////////////////////////////////// @@ -192,12 +200,11 @@ namespace senf { struct SyntaxException : public std::exception { virtual char const * what() const throw() - { return "Invalid IpV6 socket address syntax"; } }; + { return "Invalid IPv6 socket address syntax"; } }; protected: private: - void assignAddr(std::string const & addr); void assignIface(std::string const & iface); struct sockaddr_in6 sockaddr_;