[boost::asio]about boost::asio::async_read_until
Hi Dear all I want use async_read_until for read stream from socket until EOF,but I can't compile code below. code: boost::asio::async_read_until(socket_, stream_buffer_,boost::asio::transfer_all(), boost::bind(&http_connection::handle_read_response, this, boost::asio::placeholders::error,boost::asio::placeholders::bytes_transferred)); stream_buffer is instance of boost::asio::streambuf I got the error like: d:\development\boost_1_36_0\boost\asio\impl\read_until.ipp(953) : error C2664: "bool boost::asio::detail::transfer_all_t::operator ()<iterator>(const Error &,size_t)":Can't convert paramerater 2 from "iterator" to "size_t" with [ Error=iterator ] d:\development\tcphttpbridge\httpconnection.cpp(75):参见对正在编译的函数 模 板 实例化"void boost::asio::async_read_until<boost::asio::ip::tcp::socket,std::allocator<_Ty>,boost::asio::detail::transfer_all_t,boost::_bi::bind_t<R,F,L>>(AsyncReadStream &,boost::asio::basic_streambuf<> &,MatchCondition,ReadHandler,void *)"的引用 with [ _Ty=char, R=void, F=boost::_mfi::mf2<void,http_connection,const boost::system::error_code &,size_t>, L=boost::_bi::list3<boost::_bi::value<http_connection *>,boost::arg<1>,boost::arg<2>>, AsyncReadStream=boost::asio::ip::tcp::socket, MatchCondition=boost::asio::detail::transfer_all_t, ReadHandler=boost::_bi::bind_t<void,boost::_mfi::mf2<void,http_connection,const boost::system::error_code &,size_t>,boost::_bi::list3<boost::_bi::value<http_connection *>,boost::arg<1>,boost::arg<2>>> ] -- Best Regards, Ken
Hi, What's the signature of http_connection::handle_read_response ?
I want use async_read_until for read stream from socket until EOF,but I can't compile code below.
code: boost::asio::async_read_until(socket_, stream_buffer_,boost::asio::transfer_all(), boost::bind(&http_connection::handle_read_response, this,
boost::asio::placeholders::error,boost::asio::placeholders::bytes_transferred));
stream_buffer is instance of boost::asio::streambuf
I got the error like:
d:\development\boost_1_36_0\boost\asio\impl\read_until.ipp(953) : error C2664: "bool boost::asio::detail::transfer_all_t::operator ()<iterator>(const Error &,size_t)":Can't convert paramerater 2 from "iterator" to "size_t"
Hi lgor R The handle_read_response is member function of http_connection like this. void http_connection::handle_read_response(const boost::system::error_code& e,size_t bytes_transferred) { ..... } BTW: My compiler is MSVC 8.0. BOOST version 1.36 Thanks Ken 2008/11/24 Igor R <boost.lists@gmail.com>
Hi,
What's the signature of http_connection::handle_read_response ?
I want use async_read_until for read stream from socket until EOF,but I can't compile code below.
code: boost::asio::async_read_until(socket_, stream_buffer_,boost::asio::transfer_all(), boost::bind(&http_connection::handle_read_response, this,
boost::asio::placeholders::error,boost::asio::placeholders::bytes_transferred));
stream_buffer is instance of boost::asio::streambuf
I got the error like:
d:\development\boost_1_36_0\boost\asio\impl\read_until.ipp(953) : error C2664: "bool boost::asio::detail::transfer_all_t::operator ()<iterator>(const Error &,size_t)":Can't convert paramerater 2 from "iterator" to "size_t"
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Best Regards, Ken Zhang Greatelsoft Co., Ltd. mailto:ken@greatelsoft.com http://www.greatelsoft.com M/P:0086-1350-191-6596
Sorry, I didn't pay attention that you try to use transfer_all as a MatchCondition, while it is not MatchCondition. 2008/11/24 Ken zhang <kennir@gmail.com>
Hi lgor R
The handle_read_response is member function of http_connection like this.
void http_connection::handle_read_response(const boost::system::error_code& e,size_t bytes_transferred) { ..... }
BTW: My compiler is MSVC 8.0. BOOST version 1.36
Thanks
Ken
2008/11/24 Igor R <boost.lists@gmail.com>
Hi,
What's the signature of http_connection::handle_read_response ?
I want use async_read_until for read stream from socket until EOF,but I can't compile code below.
code: boost::asio::async_read_until(socket_, stream_buffer_,boost::asio::transfer_all(), boost::bind(&http_connection::handle_read_response, this,
boost::asio::placeholders::error,boost::asio::placeholders::bytes_transferred));
stream_buffer is instance of boost::asio::streambuf
I got the error like:
d:\development\boost_1_36_0\boost\asio\impl\read_until.ipp(953) : error C2664: "bool boost::asio::detail::transfer_all_t::operator ()<iterator>(const Error &,size_t)":Can't convert paramerater 2 from "iterator" to "size_t"
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Best Regards,
Ken Zhang Greatelsoft Co., Ltd. mailto:ken@greatelsoft.com http://www.greatelsoft.com M/P:0086-1350-191-6596
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi lgor R I replaced async_read_until to async_read, that Ok! My be transf_all doesn't adapt to MatchCondition. Thanks Ken 2008/11/25 Igor R <boost.lists@gmail.com>
Sorry, I didn't pay attention that you try to use transfer_all as a MatchCondition, while it is not MatchCondition.
2008/11/24 Ken zhang <kennir@gmail.com>
Hi lgor R
The handle_read_response is member function of http_connection like this.
void http_connection::handle_read_response(const boost::system::error_code& e,size_t bytes_transferred) { ..... }
BTW: My compiler is MSVC 8.0. BOOST version 1.36
Thanks
Ken
2008/11/24 Igor R <boost.lists@gmail.com>
Hi,
What's the signature of http_connection::handle_read_response ?
I want use async_read_until for read stream from socket until EOF,but I can't compile code below.
code: boost::asio::async_read_until(socket_, stream_buffer_,boost::asio::transfer_all(), boost::bind(&http_connection::handle_read_response, this,
boost::asio::placeholders::error,boost::asio::placeholders::bytes_transferred));
stream_buffer is instance of boost::asio::streambuf
I got the error like:
d:\development\boost_1_36_0\boost\asio\impl\read_until.ipp(953) : error C2664: "bool boost::asio::detail::transfer_all_t::operator ()<iterator>(const Error &,size_t)":Can't convert paramerater 2 from "iterator" to "size_t"
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Best Regards,
Ken Zhang Greatelsoft Co., Ltd. mailto:ken@greatelsoft.com http://www.greatelsoft.com M/P:0086-1350-191-6596
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Best Regards, Ken Zhang Greatelsoft Co., Ltd. mailto:ken@greatelsoft.com http://www.greatelsoft.com M/P:0086-1350-191-6596
Sure, if you just want to read the data until the peer closes its socket, then async_read with transfer_all is exactly what you need: when the peer socket is closed, your handler is called with some error (usually asio::error::eof, but not always). The function async_read_until with some MatchCondition is used if you want to read until some *contents* is encountered in the stream. 2008/11/24 Ken zhang <kennir@gmail.com>
Hi lgor R
I replaced async_read_until to async_read, that Ok! My be transf_all doesn't adapt to MatchCondition.
Thanks
participants (2)
-
Igor R
-
Ken zhang