I am using CurlPP to get the public IP address of a network by using the API of https://ipify.org My function works fine, however, it only does when called up to 4-6 times. I am calling the function in a while loop to check for changes of the IP address. (It sometimes works for 4 times, sometimes for 5 or 6 times). After that, nothing happens, no output, nothing, just the cursor blinking in the terminal, no error or anything!
std::string getIPAddress()
{
try
{
curlpp::Cleanup myCleanup;
{
std::ostringstream ip_address_stream;
ip_address_stream << curlpp::options::Url("http://api.ipify.org");
ip_address = ip_address_stream.str();
return ip_address;
}
}
catch(curlpp::RuntimeError &e)
{
std::cout << e.what() << std::endl;
}
catch(curlpp::LogicError &e)
{
std::cout << e.what() << std::endl;
}
}