繁体   English   中英

如何将Boost.asio用于多播发件人?

[英]how to use Boost.asio for the multicast sender?

我正在尝试使用boost.asio来实现多播发送器。 我有一个线程实现,只需要boost.asio来管理套接字。

我看了boost网站上的示例,但我不理解,也没有编译。 在哪里可以找到我需要的东西?

编译错误为:(我尝试过以下示例: http : //www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/example/multicast/sender.cpp

错误3错误C2653:'asio':不是类或名称空间名称c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 2

错误4错误C2653:'asio':不是类或名称空间名称c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 24

错误5错误C2143:语法错误:'&'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp之前缺少')'24

错误6错误C2143:语法错误:缺少';' 在'&'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp之前24

错误7错误C2460:'sender :: io_service':使用'sender',正在定义c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 24

错误8错误C4430:缺少类型说明符-假定为int。 注意:C ++不支持default-int c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 24

错误9错误C2653:'asio':不是类或名称空间名称c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 24

错误10错误C2143:语法错误:缺少';' 在'&'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp之前24

错误11错误C4430:缺少类型说明符-假定为int。 注意:C ++不支持default-int c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 24

错误13错误C2059:语法错误:')'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 24

错误14错误C2065:'multicast_address':未声明的标识符c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 26

错误15错误C3861:'endpoint_':找不到标识符c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 26

错误16错误C2531:'sender :: multicast_address':引用位域非法c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 26

错误17错误C4430:缺少类型说明符-假定为int。 注意:C ++不支持default-int c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 26

错误18错误C2327:'sender :: io_service':不是类型名称,静态或枚举器c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 27

错误19错误C2061:语法错误:标识符'io_service'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 27

错误20错误C2059:语法错误:')'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 27

错误21错误C2061:语法错误:标识符'timer_'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 28

错误22错误C2143:语法错误:'{'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp前缺少')'30

错误23错误C4430:缺少类型说明符-假定为int。 注意:C ++不支持default-int c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 30

错误24错误C2143:语法错误:缺少';' 在'{'c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp之前39

错误25错误C2334:“ {”之前的意外标记; 跳过明显的函数正文c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 39

错误26致命错误C1004:发现意外的文件结尾c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 100

假设您已正确安装boost,那么您选择编译的示例应该完整构建。 我不知道您的开发环境是如何设置的。 在我的系统上,我在/opt/local安装了boost,因此标头位于/opt/local/include ,要链接的库位于/opt/local/lib 我的编译和链接行看起来像

stackoverflow samm$ g++ sender.cpp  -I /opt/local/include/ -L/opt/local/lib -lboost_system -Wl,-rpath,/opt/local/lib

您看到的第一个错误

错误3错误C2653:'asio':不是类或名称空间名称c:\\ Documents and Settings \\ GG \\ Desktop \\ sender.cpp 2

好像您忘记在某个地方#include <boost/asio.hpp> 但是我离Windows开发专家还很远,所以也许会有更多知识渊博的人回答。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM