c++ - CurlPP 不会多次请求
问题描述
我正在使用 CurlPP 通过使用https://ipify.org的 API 获取网络的公共 IP 地址 我的函数工作正常,但是,它只在调用 4-6 次时才有效。我在 while 循环中调用该函数以检查 IP 地址的更改。(有时会工作 4 次,有时会工作 5 或 6 次)。之后,什么也没有发生,没有输出,什么都没有,只是光标在终端中闪烁,没有错误或任何东西!
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;
}
}
解决方案
推荐阅读
- mysql - 用户 'me'@'localhost' 的访问被拒绝(使用密码:否)
- python - Spacy 删除停用词而不影响命名实体
- java - 关于转置方阵的问题
- node.js - 为什么 useFactory 选项会让我在 nestjs 配置中出错?
- python - 如何检查一个元素是否在列表列表中?
- caching - Redis - 基准与现实
- excel - 用户表单(更新、添加、删除和重置)
- python-3.x - 为什么protobuf在python中等于0时会错过一些参数?
- reactjs - 对 React-Data-Grid 中的某些列进行验证
- swift - 在 Swift 中获取子字符串到索引