2
// basic_resolver_query.hpp
3
// ~~~~~~~~~~~~~~~~~~~~~~~~
5
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11
#ifndef ASIO_IP_BASIC_RESOLVER_QUERY_HPP
12
#define ASIO_IP_BASIC_RESOLVER_QUERY_HPP
14
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
16
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18
#include "asio/detail/push_options.hpp"
20
#include "asio/detail/push_options.hpp"
21
#include <boost/config.hpp>
23
#include "asio/detail/pop_options.hpp"
25
#include "asio/detail/socket_ops.hpp"
26
#include "asio/ip/resolver_query_base.hpp"
31
/// An query to be passed to a resolver.
33
* The asio::ip::basic_resolver_query class template describes a query
34
* that can be passed to a resolver.
37
* @e Distinct @e objects: Safe.@n
38
* @e Shared @e objects: Unsafe.
40
template <typename InternetProtocol>
41
class basic_resolver_query
42
: public resolver_query_base
45
/// The protocol type associated with the endpoint query.
46
typedef InternetProtocol protocol_type;
48
/// Construct with specified service name for any protocol.
49
basic_resolver_query(const std::string& service_name,
50
int flags = passive | address_configured)
53
service_name_(service_name)
55
typename InternetProtocol::endpoint endpoint;
56
hints_.ai_flags = flags;
57
hints_.ai_family = PF_UNSPEC;
58
hints_.ai_socktype = endpoint.protocol().type();
59
hints_.ai_protocol = endpoint.protocol().protocol();
60
hints_.ai_addrlen = 0;
61
hints_.ai_canonname = 0;
66
/// Construct with specified service name for a given protocol.
67
basic_resolver_query(const protocol_type& protocol,
68
const std::string& service_name,
69
int flags = passive | address_configured)
72
service_name_(service_name)
74
hints_.ai_flags = flags;
75
hints_.ai_family = protocol.family();
76
hints_.ai_socktype = protocol.type();
77
hints_.ai_protocol = protocol.protocol();
78
hints_.ai_addrlen = 0;
79
hints_.ai_canonname = 0;
84
/// Construct with specified host name and service name for any protocol.
85
basic_resolver_query(const std::string& host_name,
86
const std::string& service_name, int flags = address_configured)
88
host_name_(host_name),
89
service_name_(service_name)
91
typename InternetProtocol::endpoint endpoint;
92
hints_.ai_flags = flags;
93
hints_.ai_family = PF_UNSPEC;
94
hints_.ai_socktype = endpoint.protocol().type();
95
hints_.ai_protocol = endpoint.protocol().protocol();
96
hints_.ai_addrlen = 0;
97
hints_.ai_canonname = 0;
102
/// Construct with specified host name and service name for a given protocol.
103
basic_resolver_query(const protocol_type& protocol,
104
const std::string& host_name, const std::string& service_name,
105
int flags = address_configured)
107
host_name_(host_name),
108
service_name_(service_name)
110
hints_.ai_flags = flags;
111
hints_.ai_family = protocol.family();
112
hints_.ai_socktype = protocol.type();
113
hints_.ai_protocol = protocol.protocol();
114
hints_.ai_addrlen = 0;
115
hints_.ai_canonname = 0;
120
/// Get the hints associated with the query.
121
const asio::detail::addrinfo_type& hints() const
126
/// Get the host name associated with the query.
127
std::string host_name() const
132
/// Get the service name associated with the query.
133
std::string service_name() const
135
return service_name_;
139
asio::detail::addrinfo_type hints_;
140
std::string host_name_;
141
std::string service_name_;
147
#include "asio/detail/pop_options.hpp"
149
#endif // ASIO_IP_BASIC_RESOLVER_QUERY_HPP