在iOS上提升ASIO错误"Host not found"
Boost ASIO error "Host not found" on iOS
我有一个应用程序,每秒通过本地网络发送一次多播消息。这段代码在Windows和macOS上运行良好,在iOS上运行良好,除非网络没有连接到互联网。
boost::asio::ip::tcp::resolver resolver(m_IOservice);
boost::system::error_code ec;
boost::asio::ip::tcp::resolver::query query(boost::asio::ip::host_name(),"");
boost::asio::ip::tcp::resolver::iterator it = resolver.resolve(query, ec);
boost::asio::ip::address interface_ip_address;
while(it!=boost::asio::ip::tcp::resolver::iterator())
{
interface_ip_address = (it++)->endpoint().address();
if(interface_ip_address.is_v4())
{
// Message sending code here
}
}
问题发生在resolver.resolve(),我得到一个异常"主机未找到(权威)"作为错误。
我不确定我真的理解为什么这个错误会发生,当然也不知道如何修复它。有人能给我解释一下吗?
host_name返回什么?它可能返回一个不能解析的名称。
如果您只想要localhost,请使用boost::asio::ip::addressv4()
甚至boost::asio::ip::address::from_string("127.0.0.1")
。
或者在您的/etc/hosts
文件中添加一个条目:
127.0.0.1 thehostnametoresolvetolocalhost
相关文章:
- OpenMP卸载说'fatal error: could not find accel/nvptx-none/mkoffload'
- 使用JsonCpp将数据返回到带有pybind11的python会在python调用中产生Symbol not foun
- OpenCV Android C++ imwrite not found
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 使用单词"not"作为C ++类的名称会导致VS2019错误
- 错误"Could not find Boost"(缺少:上下文标头)
- 如何修复"error: ‘_1’ was not declared in this scope"?
- 套接字连接"Operation not permitted"错误,甚至使用升压/平发器根.cpp
- Is !NaN not a NaN?
- 为什么我会" void value not ignored as it ought to be"?
- 解决"ld: library not found for -ltensorflow_framework.2.3.0"
- 加载与引用 .NET DLL 位于同一文件夹中的引用的 .NET DLL 时"Not found"异常
- Directx 11 - CompileFromFile() is not compiling
- 方法错误"not all control paths return a value"和方法不返回值
- Centos7 g++ "to_string is not in a member of std"
- 将系数存储在头文件的数组中("does not name a type"错误)
- QGraphicsItems not showing up QGraphicsScene
- 使用提升 asio 时出现"resolve: Host not found (authoritative)"异常
- 提升 ASIO:"host not found (authorative)"
- 在iOS上提升ASIO错误"Host not found"