Il 07/30/2011 08:39 PM, Igor R ha scritto:
I use Boost.ASIO for receiving Twitter JSON data. I use this code: boost::asio::write( p_socket, l_request );
boost::asio::streambuf l_response;
boost::asio::read_until(p_socket, l_response, "\r\n\r\n");
Read the manual: http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/reference/read_unti...
I would also suggest that you look to the http server examples in the documentation. The problem of reading an http response, as your client should do, is no different from reading an http request as the server in the examples does (also parsing it is little different, thus reading the examples would benefit you for this). As an aside, let me remark that your approach was flawed also from the http point of view. Think what would happen if the server, for any reason whatsoever, sent you a message without a body... The empty line is intended as a _separator_, not as a _termiantor_ i.e. if there is no body there is no CRLF alone on its line, because there is nothing to separate! Thus in that case your call will lock forever waiting for a sequence which would never come (well, it would not lock truly forever as the server would close the connection ad you'll end up with an unexpected connection error, but you still would have problems) -- Leo Cacciari Aliae nationes servitutem pati possunt populi romani est propria libertas