Hello, I try to read the newsgroup list with aiso, but I've got some problems with terminate the reading. I send the "list" command to my nntp server and get a status 200, after that I read the data with boost::asio::streambuf l_response; std::istream l_response_stream( &l_response ); boost::system::error_code error; while (boost::asio::read(m_socket, l_response, boost::asio::transfer_at_least(1), error)) std::cout << &l_response; and I see on cout the list (excerpt): xs4all.ipv6 0000000481 0000000001 y de.comp.lang.vbclassic 0000000257 0000000001 y de.comp.office-pakete.ms-office.word 0000000013 0000000001 y it.comp.dotnet 0000000074 0000000001 y free.timothy.sutter 0000000003 0000000001 y free.soc.religion.christian 0000000006 0000000001 y free.fan.taylor-momsen 0000000000 0000000001 y . After the dot, my program doesn't terminate, because the while loop doesn't break. I understand the loop in that way: I read some bytes into my stream from the socket and write them to the std::cout, if there more bytes the loop will continue otherwise (like EOF) the look should be break. I use the example at http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/example/http/client... because I'm new on asio, so I hope someone can explain me, the problem. Thanks for help Phil .
and I see on cout the list (excerpt): xs4all.ipv6 0000000481 0000000001 y de.comp.lang.vbclassic 0000000257 0000000001 y de.comp.office-pakete.ms-office.word 0000000013 0000000001 y it.comp.dotnet 0000000074 0000000001 y free.timothy.sutter 0000000003 0000000001 y free.soc.religion.christian 0000000006 0000000001 y free.fan.taylor-momsen 0000000000 0000000001 y . After the dot, my program doesn't terminate, because the while loop doesn't break. I understand the loop in that way: I read some bytes into my stream from the socket and write them to the std::cout, if there more bytes the loop will continue otherwise (like EOF) the look should be break.
You'll get some error (EOF or similar) if the peer closes the socket after sending you the data. But if it doesn't close the socket, then no error occurs, and read() operation will block forever.
Am 24.10.2010 um 13:08 schrieb Igor R:
and I see on cout the list (excerpt): xs4all.ipv6 0000000481 0000000001 y de.comp.lang.vbclassic 0000000257 0000000001 y de.comp.office-pakete.ms-office.word 0000000013 0000000001 y it.comp.dotnet 0000000074 0000000001 y free.timothy.sutter 0000000003 0000000001 y free.soc.religion.christian 0000000006 0000000001 y free.fan.taylor-momsen 0000000000 0000000001 y . After the dot, my program doesn't terminate, because the while loop doesn't break. I understand the loop in that way: I read some bytes into my stream from the socket and write them to the std::cout, if there more bytes the loop will continue otherwise (like EOF) the look should be break.
You'll get some error (EOF or similar) if the peer closes the socket after sending you the data. But if it doesn't close the socket, then no error occurs, and read() operation will block forever.
I don't send data, I receive the data, but how can I check, that I reach the end of the transmission? It seems the socket will block, so how can I determine the "end" of the sending data? Should I analyse the stream data? I know the last char ist a dot. Sorry, I'm a little bit confused. Phil
You'll get some error (EOF or similar) if the peer closes the socket after sending you the data. But if it doesn't close the socket, then no error occurs, and read() operation will block forever.
I don't send data, I receive the data, but how can I check, that I reach the end of the transmission? It seems the socket will block, so how can I determine the "end" of the sending data? Should I analyse the stream data? I know the last char ist a dot. Sorry, I'm a little bit confused.
If the server that sends to you the data doesn't close the socket after the transmission, you have to analyse the data and decide when you want to stop reading.
On 2010-10-24 13:46:17 +0200, Igor R said:
You'll get some error (EOF or similar) if the peer closes the socket after sending you the data. But if it doesn't close the socket, then no error occurs, and read() operation will block forever.
I don't send data, I receive the data, but how can I check, that I reach the end of the transmission? It seems the socket will block, so how can I determine the "end" of the sending data? Should I analyse the stream data? I know the last char ist a dot. Sorry, I'm a little bit confused.
If the server that sends to you the data doesn't close the socket after the transmission, you have to analyse the data and decide when you want to stop reading.
Yes you're right. I solve my problem with boost::asio::read_until and that works now
On 2010-10-24 13:37, Kraus Philipp wrote:
It seems the socket will block, so how can I determine the "end" of the sending data? Should I analyse the stream data? I know the last char ist a dot.
Have you looked at the NNTP protocol in more detail? Probably the dot, indeed. Regards, Rutger
participants (4)
-
Igor R
-
Kraus Philipp
-
Philipp Kraus
-
Rutger ter Borg