peerplays-fc/src/network/resolve.cpp

23 lines
594 B
C++
Raw Normal View History

#include <fc/asio.hpp>
#include <fc/network/ip.hpp>
2013-11-09 00:34:54 +00:00
#include <fc/log/logger.hpp>
namespace fc
{
std::vector<fc::ip::endpoint> resolve( const fc::string& host, uint16_t port )
{
auto ep = fc::asio::tcp::resolve( host, std::to_string(uint64_t(port)) );
std::vector<fc::ip::endpoint> eps;
eps.reserve(ep.size());
for( auto itr = ep.begin(); itr != ep.end(); ++itr )
2013-11-09 00:34:54 +00:00
{
if( itr->address().is_v4() )
{
eps.push_back( fc::ip::endpoint(itr->address().to_v4().to_ulong(), itr->port()) );
}
// TODO: add support for v6
}
return eps;
}
}