basic_resolver_query.hpp
Go to the documentation of this file.
00001 //
00002 // basic_resolver_query.hpp
00003 // ~~~~~~~~~~~~~~~~~~~~~~~~
00004 //
00005 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
00006 //
00007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
00008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00009 //
00010 
00011 #ifndef ASIO_IP_BASIC_RESOLVER_QUERY_HPP
00012 #define ASIO_IP_BASIC_RESOLVER_QUERY_HPP
00013 
00014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
00015 # pragma once
00016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
00017 
00018 #include "asio/detail/push_options.hpp"
00019 
00020 #include "asio/detail/push_options.hpp"
00021 #include <boost/config.hpp>
00022 #include <string>
00023 #include "asio/detail/pop_options.hpp"
00024 
00025 #include "asio/detail/socket_ops.hpp"
00026 #include "asio/ip/resolver_query_base.hpp"
00027 
00028 namespace asio {
00029 namespace ip {
00030 
00032 
00040 template <typename InternetProtocol>
00041 class basic_resolver_query
00042   : public resolver_query_base
00043 {
00044 public:
00046   typedef InternetProtocol protocol_type;
00047 
00049   basic_resolver_query(const std::string& service_name,
00050       int flags = passive | address_configured)
00051     : hints_(),
00052       host_name_(),
00053       service_name_(service_name)
00054   {
00055     typename InternetProtocol::endpoint endpoint;
00056     hints_.ai_flags = flags;
00057     hints_.ai_family = PF_UNSPEC;
00058     hints_.ai_socktype = endpoint.protocol().type();
00059     hints_.ai_protocol = endpoint.protocol().protocol();
00060     hints_.ai_addrlen = 0;
00061     hints_.ai_canonname = 0;
00062     hints_.ai_addr = 0;
00063     hints_.ai_next = 0;
00064   }
00065 
00067   basic_resolver_query(const protocol_type& protocol,
00068       const std::string& service_name,
00069       int flags = passive | address_configured)
00070     : hints_(),
00071       host_name_(),
00072       service_name_(service_name)
00073   {
00074     hints_.ai_flags = flags;
00075     hints_.ai_family = protocol.family();
00076     hints_.ai_socktype = protocol.type();
00077     hints_.ai_protocol = protocol.protocol();
00078     hints_.ai_addrlen = 0;
00079     hints_.ai_canonname = 0;
00080     hints_.ai_addr = 0;
00081     hints_.ai_next = 0;
00082   }
00083 
00085   basic_resolver_query(const std::string& host_name,
00086       const std::string& service_name, int flags = address_configured)
00087     : hints_(),
00088       host_name_(host_name),
00089       service_name_(service_name)
00090   {
00091     typename InternetProtocol::endpoint endpoint;
00092     hints_.ai_flags = flags;
00093     hints_.ai_family = PF_UNSPEC;
00094     hints_.ai_socktype = endpoint.protocol().type();
00095     hints_.ai_protocol = endpoint.protocol().protocol();
00096     hints_.ai_addrlen = 0;
00097     hints_.ai_canonname = 0;
00098     hints_.ai_addr = 0;
00099     hints_.ai_next = 0;
00100   }
00101 
00103   basic_resolver_query(const protocol_type& protocol,
00104       const std::string& host_name, const std::string& service_name,
00105       int flags = address_configured)
00106     : hints_(),
00107       host_name_(host_name),
00108       service_name_(service_name)
00109   {
00110     hints_.ai_flags = flags;
00111     hints_.ai_family = protocol.family();
00112     hints_.ai_socktype = protocol.type();
00113     hints_.ai_protocol = protocol.protocol();
00114     hints_.ai_addrlen = 0;
00115     hints_.ai_canonname = 0;
00116     hints_.ai_addr = 0;
00117     hints_.ai_next = 0;
00118   }
00119 
00121   const asio::detail::addrinfo_type& hints() const
00122   {
00123     return hints_;
00124   }
00125 
00127   std::string host_name() const
00128   {
00129     return host_name_;
00130   }
00131 
00133   std::string service_name() const
00134   {
00135     return service_name_;
00136   }
00137 
00138 private:
00139   asio::detail::addrinfo_type hints_;
00140   std::string host_name_;
00141   std::string service_name_;
00142 };
00143 
00144 } // namespace ip
00145 } // namespace asio
00146 
00147 #include "asio/detail/pop_options.hpp"
00148 
00149 #endif // ASIO_IP_BASIC_RESOLVER_QUERY_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


Castor
Author(s): Carpe Noctem
autogenerated on Fri Nov 8 2013 11:05:39