BitShares-Core  5.0.0
BitShares blockchain implementation and command-line interface software
resolve.cpp
Go to the documentation of this file.
1 #include <fc/asio.hpp>
2 #include <fc/network/ip.hpp>
3 #include <fc/log/logger.hpp>
4 
5 namespace fc
6 {
7  std::vector<fc::ip::endpoint> resolve( const std::string& host, uint16_t port )
8  {
9  auto ep = fc::asio::tcp::resolve( host, std::to_string(uint64_t(port)) );
10  std::vector<fc::ip::endpoint> eps;
11  eps.reserve(ep.size());
12  for( auto itr = ep.begin(); itr != ep.end(); ++itr )
13  {
14  if( itr->address().is_v4() )
15  {
16  eps.push_back( fc::ip::endpoint(itr->address().to_v4().to_ulong(), itr->port()) );
17  }
18  // TODO: add support for v6
19  }
20  return eps;
21  }
22 }
std::string to_string(double)
Definition: string.cpp:73
Definition: api.hpp:15
std::vector< endpoint > resolve(const std::string &hostname, const std::string &port)
Definition: asio.cpp:188
std::vector< fc::ip::endpoint > resolve(const std::string &host, uint16_t port)
Definition: resolve.cpp:7