绑定代码:
boost::shared_ptr<string> send_buffer(new string(encode(*_msg)));
boost::function<void(void)>send_call_back = boost::bind(
&Connection::async_send_msg_call_back,
this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred,
send_buffer
);
回调函数原型:
void Connection::async_send_msg_call_back(
boost::system::error_code& ec,
std::size_t bytes_transferred,
boost::shared_ptr<string> send_buffer)
{
}
[/code]
以上这个是模仿asio下的async_read_some写的,它的源码注释中有(basic_stream_socket.hpp)
@code void handler(
* const boost::system::error_code& error, // Result of operation.
* std::size_t bytes_transferred // Number of bytes written.
* ); @endcode
编译出错....
一大堆模板报错...你们不想看的...
1>------ 已启动生成: 项目: Slave, 配置: Debug Win32 ------
1> Connection.cpp
1> Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example:
1> - add -D_WIN32_WINNT=0x0501 to the compiler command line; or
1> - add _WIN32_WINNT=0x0501 to your project's Preprocessor Definitions.
1> Assuming _WIN32_WINNT=0x0501 (i.e. Windows XP target).
1>d:\boost_1_50_0\boost\bind\bind.hpp(457): error C2784: “result_traits<R,F>::type boost::_bi::list0::operator [](const boost::_bi::bind_t<R,F,L> &) const”: 未能从“重载函数类型”为“重载函数类型”推导 模板 参数
1> d:\boost_1_50_0\boost\bind\bind.hpp(178) : 参见“boost::_bi::list0::operator []”的声明
1> d:\boost_1_50_0\boost\bind\bind_template.hpp(20): 参见对正在编译的函数 模板 实例化“void boost::_bi::list4<A1,A2,A3,A4>::operator ()<F,boost::_bi::list0>(boost::_bi::type<T>,F &,A &,int)”的引用
1> with
1> [
1> A1=boost::_bi::value<Connection *>,
1> A2=boost::arg<1>,
1> A3=boost::arg<2>,
1> A4=boost::_bi::value<boost::shared_ptr<std::string>>,
1> F=boost::_mfi::mf3<void,Connection,boost::system::error_code &,size_t,boost::shared_ptr<std::string>>,
1> T=void,
1> A=boost::_bi::list0
1> ]
1> d:\boost_1_50_0\boost\bind\bind_template.hpp(18): 编译类 模板 成员函数“void boost::_bi::bind_t<R,F,L>::operator ()(void)”时
1> with
1> [
1> R=void,
1> F=boost::_mfi::mf3<void,Connection,boost::system::error_code &,size_t,boost::shared_ptr<std::string>>,
1> L=boost::_bi::list4<boost::_bi::value<Connection *>,boost::arg<1>,boost::arg<2>,boost::_bi::value<boost::shared_ptr<std::string>>>
1> ]
1> d:\scn\slave\slave\connection.cpp(29): 参见对正在编译的类 模板 实例化“boost::_bi::bind_t<R,F,L>”的引用
1> with
1> [
1> R=void,
1> F=boost::_mfi::mf3<void,Connection,boost::system::error_code &,size_t,boost::shared_ptr<std::string>>,
1> L=boost::_bi::list4<boost::_bi::value<Connection *>,boost::arg<1>,boost::arg<2>,boost::_bi::value<boost::shared_ptr<std::string>>>
1> ]
1>d:\boost_1_50_0\boost\bind\bind.hpp(457): error C2784: “result_traits<R,F>::type boost::_bi::list0::operator [](boost::_bi::bind_t<R,F,L> &) const”: 未能从“重载函数类型”为“重载函数类型”推导 模板 参数
1> d:\boost_1_50_0\boost\bind\bind.hpp(176) : 参见“boost::_bi::list0::operator []”的声明
1>d:\boost_1_50_0\boost\bind\bind.hpp(457): error C2784: “T &boost::_bi::list0::operator [](const boost::reference_wrapper<T> &) const”: 未能从“重载函数类型”为“重载函数类型”推导 模板 参数
1> d:\boost_1_50_0\boost\bind\bind.hpp(174) : 参见“boost::_bi::list0::operator []”的声明
1>d:\boost_1_50_0\boost\bind\bind.hpp(457): error C2784: “const T &boost::_bi::list0::operator [](const boost::_bi::value<T> &) const”: 未能从“重载函数类型”为“重载函数类型”推导 模板 参数
1> d:\boost_1_50_0\boost\bind\bind.hpp(172) : 参见“boost::_bi::list0::operator []”的声明
1>d:\boost_1_50_0\boost\bind\bind.hpp(457): error C2784: “T &boost::_bi::list0::operator [](boost::_bi::value<T> &) const”: 未能从“重载函数类型”为“重载函数类型”推导 模板 参数
1> d:\boost_1_50_0\boost\bind\bind.hpp(170) : 参见“boost::_bi::list0::operator []”的声明
1>d:\boost_1_50_0\boost\bind\bind.hpp(457): error C2676: 二进制“[”:“boost::_bi::list0”不定义该运算符或到预定义运算符可接收的类型的转换
1>d:\boost_1_50_0\boost\bind\bind.hpp(457): error C2784: “result_traits<R,F>::type boost::_bi::list0::operator [](const boost::_bi::bind_t<R,F,L> &) const”: 未能从“重载函数类型”为“重载函数类型”推导 模板 参数
1> d:\boost_1_50_0\boost\bind\bind.hpp(178) : 参见“boost::_bi::list0::operator []”的声明
1>d:\boost_1_50_0\boost\bind\bind.hpp(457): error C2784: “result_traits<R,F>::type boost::_bi::list0::operator [](boost::_bi::bind_t<R,F,L> &) const”: 未能从“重载函数类型”为“重载函数类型”推导 模板 参数
1> d:\boost_1_50_0\boost\bind\bind.hpp(176) : 参见“boost::_bi::list0::operator []”的声明
1>d:\boost_1_50_0\boost\bind\bind.hpp(457): error C2784: “T &boost::_bi::list0::operator [](const boost::reference_wrapper<T> &) const”: 未能从“重载函数类型”为“重载函数类型”推导 模板 参数
1> d:\boost_1_50_0\boost\bind\bind.hpp(174) : 参见“boost::_bi::list0::operator []”的声明
1>d:\boost_1_50_0\boost\bind\bind.hpp(457): error C2784: “const T &boost::_bi::list0::operator [](const boost::_bi::value<T> &) const”: 未能从“重载函数类型”为“重载函数类型”推导 模板 参数
1> d:\boost_1_50_0\boost\bind\bind.hpp(172) : 参见“boost::_bi::list0::operator []”的声明
1>d:\boost_1_50_0\boost\bind\bind.hpp(457): error C2784: “T &boost::_bi::list0::operator [](boost::_bi::value<T> &) const”: 未能从“重载函数类型”为“重载函数类型”推导 模板 参数
1> d:\boost_1_50_0\boost\bind\bind.hpp(170) : 参见“boost::_bi::list0::operator []”的声明
1>d:\boost_1_50_0\boost\bind\bind.hpp(457): error C2676: 二进制“[”:“boost::_bi::list0”不定义该运算符或到预定义运算符可接收的类型的转换
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========