Thanks Igor, This method " tcp::socket::available()" really solved most of my problem, this was the missing link for me after using WinInet for some time where I had convenience of using high level API I was really missing something while using BOOST::ASIO sync socket. This fills that gap. Thanks, Akhilesh Kumar -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Igor R Sent: Sunday, February 14, 2010 7:49 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] boost::asio determining end of stream,
I am using boost:asio sync socket to upload file to server. At the end of upload, server send response back which can varying length and format. I need to read this response, considering that I haven't found a way to know how much data is available for reading, my call get blocked on some of the response.
I Was wondering if there is a way to know one or more of the following.
Is there condition I can pass to the read_until() call so that it read all the available response in one call?
No. You can read "all the available response" using tcp::socket::read_some()/async_read_some(), but this would be the data available at time of the read operation - next moment some more data might arrive.
Is there a way to know that how much data remaining to be read?
tcp::socket::available() http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/reference/basic_str...
Is there a way that my call time out when there is no data?
You can implement time-out using asynchronous read and asio::deadline_timer, just like in the following example: http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/example/timeouts/st... _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users