16 #include <boost/asio.hpp> 53 using namespace boost::asio;
54 using namespace boost::asio::ip;
56 cout <<
"Trying to resolve local IP address..." << endl;
58 boost::system::error_code ec;
60 boost::asio::io_service io_service;
62 udp::socket socket(io_service);
64 udp::resolver resolver(io_service);
65 udp::resolver::query query(dns,
"0");
66 udp::resolver::iterator iterator = resolver.resolve(query, ec);
70 cout <<
"WARNING - Could not resolve local ip address: ";
71 cout << ec.message() <<
" (" << ec <<
")" << endl;
75 for (; iterator != udp::resolver::iterator(); ++iterator)
77 udp::endpoint endpoint = *iterator;
78 socket.connect(endpoint, ec);
81 cout <<
"WARNING - Could not resolve local ip address: ";
82 cout << ec.message() <<
" (" << ec <<
")" << endl;
86 const string addr = socket.local_endpoint().address().to_v4().to_string();
160 void Dim::Setup(
const std::string &dns,
const std::string &host)
164 setenv(
"DIM_DNS_NODE",
"...", 1);
172 setenv(
"DIM_DNS_NODE", dns.c_str(), 1);
173 setenv(
"DIM_HOST_NODE", loc.c_str(), 1);
175 cout <<
"Setting DIM_DNS_NODE =" << dns << endl;
176 cout <<
"Setting DIM_HOST_NODE=" << loc << endl;
185 cout <<
"Setting DIM_HOST_NODE=" << rc << endl;
std::string GetLocalIp(const std::string &dns="10.0.100.1")
void Setup(const std::string &dns="", const std::string &host="")
const char * GetLocalIp()