i'm using boost::asio::ip::tcp::iostream
read binary data tcp stream. that:
stream.read(reinterpret_cast<char*>(&packetsize), 4); // first 4 bytes length stream.read(buffer, packetsize);
should check stream.gcount()
, when next stream.gcount() == 0
means no data more available reading (tcp session finished)?
the stream members looking buried in base class http://en.cppreference.com/w/cpp/io/basic_ios
use good() , !eof() see if got data. can set flags on stream object ( exception() ) instruct stream throw exceptions in case, error occurred. makes handling times easier.
Comments
Post a Comment