diff options
author | Christian Pointner <equinox@anytun.org> | 2009-03-22 17:50:10 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2009-03-22 17:50:10 +0000 |
commit | fd419ce4f2bcadae313f4f368361c733c1249ae9 (patch) | |
tree | ba244a9428e8b9cd5e40ceaa3857ab15a7a1a93e /src/resolver.h | |
parent | updated config (new option auth-tag-length) (diff) |
added error callback to resolver for better handling
of resolvCallback exceptions
Diffstat (limited to 'src/resolver.h')
-rw-r--r-- | src/resolver.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/resolver.h b/src/resolver.h index 8a64738..b5553bc 100644 --- a/src/resolver.h +++ b/src/resolver.h @@ -39,17 +39,22 @@ #include "datatypes.h" #include "threadUtils.hpp" +typedef boost::function<void (boost::asio::ip::udp::endpoint)> UdpResolveCallback; +typedef boost::function<void (boost::asio::ip::tcp::endpoint)> TcpResolveCallback; +typedef boost::function<void (std::runtime_error const&)> ErrorCallback; + template<class Proto> class ResolveHandler { public: - ResolveHandler(const std::string& addr, const std::string& port, boost::function<void (boost::asio::ip::basic_endpoint<Proto>)> const& onResolve, ResolvAddrType r = ANY); + ResolveHandler(const std::string& addr, const std::string& port, boost::function<void (boost::asio::ip::basic_endpoint<Proto>)> const& onResolve, ErrorCallback const& onError, ResolvAddrType r = ANY); void operator()(const boost::system::error_code& e, const boost::asio::ip::basic_resolver_iterator<Proto>); private: std::string addr_; std::string port_; - boost::function<void (boost::asio::ip::basic_endpoint<Proto>)> callback_; + boost::function<void (boost::asio::ip::basic_endpoint<Proto>)> onResolve_; + ErrorCallback onError_; ResolvAddrType resolv_addr_type_; }; @@ -64,8 +69,8 @@ public: void init(); void run(); - void resolveUdp(const std::string& addr, const std::string& port, boost::function<void (boost::asio::ip::udp::endpoint)> const& onResolve, ResolvAddrType r = ANY); - void resolveTcp(const std::string& addr, const std::string& port, boost::function<void (boost::asio::ip::tcp::endpoint)> const& onResolve, ResolvAddrType r = ANY); + void resolveUdp(const std::string& addr, const std::string& port, UdpResolveCallback const& onResolve, ErrorCallback const& onError, ResolvAddrType r = ANY); + void resolveTcp(const std::string& addr, const std::string& port, TcpResolveCallback const& onResolve, ErrorCallback const& onError, ResolvAddrType r = ANY); private: Resolver(); |