Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::asio determining end of stream,
From: Kumar, Akhilesh (Akhilesh.Kumar_at_[hidden])
Date: 2010-02-18 12:12:30


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_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Igor R
Sent: Sunday, February 14, 2010 7:49 AM
To: boost-users_at_[hidden]
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_stream_socket/available.html

> 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/stream_receive_timeout.cpp
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net