Boost logo

Boost Users :

Subject: [Boost-users] boost::asio determining end of stream,
From: Kumar, Akhilesh (Akhilesh.Kumar_at_[hidden])
Date: 2010-02-11 16:41:01


Hi,

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?
Is there a way to know that how much data remaining to be read?
Is there a way that my call time out when there is no data?

With three different server and response these call behave in following Manner

Server1 : First call read all the data, 2nd call fail with error code EOF.
                
Server2 :First call read all the data, 2nd call read some data, some time there are still more data to be read.

Server2 :First call read all the data, 2nd call block.
        

        size_t size1 = boost::asio::read_until(*m_pSocket, response_, "\r\n", error);

        //process response,

        //Read again,
        size1 = boost::asio::read_until(*m_pSocket, response_, "\r\n\r\n", error);
        numByte = response_.in_avail();

        //process response.

Thanks,
Akhilesh Kumar


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