TrinityCore
Loading...
Searching...
No Matches
Resolver.h
Go to the documentation of this file.
1
/*
2
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3
*
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation; either version 2 of the License, or (at your
7
* option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License along
15
* with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef Resolver_h__
19
#define Resolver_h__
20
21
#include "
IoContext.h
"
22
#include "
Optional.h
"
23
#include <boost/asio/ip/tcp.hpp>
24
#include <string>
25
26
namespace
Trinity
27
{
28
namespace
Asio
29
{
33
class
Resolver
34
{
35
public
:
36
explicit
Resolver
(
IoContext
& ioContext) :
_impl
(ioContext) { }
37
38
Optional<boost::asio::ip::tcp::endpoint>
Resolve
(boost::asio::ip::tcp
const
& protocol, std::string
const
& host, std::string
const
& service)
39
{
40
boost::system::error_code ec;
41
boost::asio::ip::resolver_base::flags flagsResolver = boost::asio::ip::resolver_base::all_matching;
42
boost::asio::ip::tcp::resolver::results_type results =
_impl
.resolve(protocol, host, service, flagsResolver, ec);
43
if
(results.begin() == results.end() || ec)
44
return
{};
45
46
return
results.begin()->endpoint();
47
}
48
49
private
:
50
boost::asio::ip::tcp::resolver
_impl
;
51
};
52
}
53
}
54
55
#endif
// Resolver_h__
IoContext.h
Optional.h
Optional
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition
Optional.h:25
Trinity::Asio::IoContext
Definition
IoContext.h:29
Trinity::Asio::Resolver
Definition
Resolver.h:34
Trinity::Asio::Resolver::_impl
boost::asio::ip::tcp::resolver _impl
Definition
Resolver.h:50
Trinity::Asio::Resolver::Resolve
Optional< boost::asio::ip::tcp::endpoint > Resolve(boost::asio::ip::tcp const &protocol, std::string const &host, std::string const &service)
Definition
Resolver.h:38
Trinity::Asio::Resolver::Resolver
Resolver(IoContext &ioContext)
Definition
Resolver.h:36
Trinity
Definition
AsioHacksFwd.h:53
common
Asio
Resolver.h
Generated on Sun May 10 2026 02:30:12 for TrinityCore by
1.9.8