boost 1.47 使用 non_blocking() 时出现编译错误
有人能看出我在这里做错了什么吗?根据1.47 basic_datagram_socket中的文档,basic_datagram_socket继承自basic_socket,因此应该继承non_blocking()或non_blocking(bool)。 谢谢
错误 1 错误 C2039: 'non_blocking' : 不是 'boost::asio::basic_datagram_socket' 的成员 c:\DEV\projects\topoTest\topoTest\multiReceiver.cpp 129
这是调用。 socket_.non_blocking(true);
套接字在类中定义如下:
boost::asio::ip::udp::socket socket_;
Can anyone discern what I'm doing wrong here? According to the documentation in 1.47 basic_datagram_socket inherits from basic_socket so the non_blocking() or non_blocking(bool) should be inherited.
Thanks
Error 1 error C2039: 'non_blocking' : is not a member of 'boost::asio::basic_datagram_socket' c:\DEV\projects\topoTest\topoTest\multiReceiver.cpp 129
This is the call.
socket_.non_blocking(true);
and the socket is defined as follows within a class:
boost::asio::ip::udp::socket socket_;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
成员函数
boost::asio::ip::udp::socket::non_blocking()
似乎是 1.47 中的新函数。要么它实际上并不存在于 1.47 中,要么您实际上使用的是较旧的标头。我建议找到包含的
标头,看看它是否确实具有该成员函数作为basic_datagram_socket
类的一部分。如果没有,你总是可以像史蒂夫·汤森德在他的回答中所说的那样用旧的方式来做。我刚刚下载了Boost 1.47,发现
basic_datagram_socket
继承了basic_socket
的non_blocking()
。在我看来,你实际上并没有 Boost 1.47。The member function
boost::asio::ip::udp::socket::non_blocking()
appears to be new in 1.47. Either it doesn't actually exist in 1.47 or you're actually using an older header. I'd suggest finding the<boost/asio/basic_datagram_socket.hpp>
header that's being included to see if it actually has that member function as part of thebasic_datagram_socket
class. If not, you can always do it the old way like Steve Townsend said in his answer.I just downloaded Boost 1.47 and found that
basic_datagram_socket
inheritsnon_blocking()
frombasic_socket
. It looks to me like you don't actually have Boost 1.47.