[Boost-users] boost::asio::error::eof

693 views
Skip to first unread message

Lloyd

unread,
Jul 10, 2010, 7:42:19 AM7/10/10
to boost...@lists.boost.org
Hi,
 
I am asynchromously reading from a file. At the file read handler there is an error checking like this-
 
if(error==boost::asio::error::eof)
{
  //do something
}
else
{
  cout<<error.messge()<<endl;
}
 
When the end of file reaches, the control does not enter into the "if portion", instead it enters the else condition and prints the message "Reached the end of the file". Am I comparing error wrongly? or else where could be the problem? How can I know that the end of file has reached?
 
Thanks a lot,
  Lloyd
 


______________________________________
Scanned and protected by Email scanner

Igor R

unread,
Jul 10, 2010, 4:53:54 PM7/10/10
to boost...@lists.boost.org
> I am asynchromously reading from a file. At the file read handler there is
> an error checking like this-
>
> if(error==boost::asio::error::eof)
> {
>   //do something
> }
> else
> {
>   cout<<error.messge()<<endl;
> }
>
> When the end of file reaches, the control does not enter into the "if
> portion", instead it enters the else condition and prints the message
> "Reached the end of the file". Am I comparing error wrongly? or else where
> could be the problem? How can I know that the end of file has reached?

So you get some other error, not asio::error::eof. Use the debugger
and check what error code you actually get.
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

ecyrbe

unread,
Jul 11, 2010, 12:02:42 AM7/11/10
to boost...@lists.boost.org
On windows you can get the system_error and not the asio misc_error, it's named boost::system::windows_error::handle_eof .
you can file a bug against boost asio to transform this error code to boost::asio::error::eof.
In fact, when you look at the code at :  "boost/asio/detail/impl/win_iocp_handle_service.ipp"
the sync version is ok (it transforms handle_eof to boost::asio::eof) but the async one does not...

2010/7/10 Igor R <boost...@gmail.com>

Lloyd

unread,
Jul 11, 2010, 2:33:04 AM7/11/10
to boost...@lists.boost.org
Thanks a lot, it works now. I shall file a bug.
 
Thank you,
  Lloyd
----- Original Message -----
From: ecyrbe
Sent: Sunday, July 11, 2010 9:32 AM
Subject: Re: [Boost-users] boost::asio::error::eof

On windows you can get the system_error and not the asio misc_error, it's named boost::system::windows_error::handle_eof .
you can file a bug against boost asio to transform this error code to boost::asio::error::eof.
In fact, when you look at the code at :  "boost/asio/detail/impl/win_iocp_handle_service.ipp"
the sync version is ok (it transforms handle_eof to boost::asio::eof) but the async one does not...



______________________________________
Scanned and protected by Email scanner

Reply all
Reply to author
Forward
0 new messages