boost 1.47 使用 non_blocking() 时出现编译错误

发布于 2024-11-23 23:17:08 字数 387 浏览 2 评论 0原文

有人能看出我在这里做错了什么吗?根据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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野鹿林 2024-11-30 23:17:09

成员函数 boost::asio::ip::udp::socket::non_blocking() 似乎是 1.47 中的新函数。要么它实际上并不存在于 1.47 中,要么您实际上使用的是较旧的标头。我建议找到包含的 标头,看看它是否确实具有该成员函数作为 basic_datagram_socket 类的一部分。如果没有,你总是可以像史蒂夫·汤森德在他的回答中所说的那样用旧的方式来做。

我刚刚下载了Boost 1.47,发现basic_datagram_socket继承了basic_socketnon_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 the basic_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 inherits non_blocking() from basic_socket. It looks to me like you don't actually have Boost 1.47.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文