He tenido problemas al utilizar asio :: streambuf y espero que alguien me diga si estoy utilizando la clase incorrectamente. Cuando ejecuto este código de ejemplo, segfaults. ¿Por qué?Código que utiliza boost :: asio :: streambuf causa segfault
Para hacer las cosas más confusas, este código funciona en Windows (Visual Studio 2008), pero no funciona en Linux (con gcc 4.4.1).
#include <boost/asio.hpp>
using namespace std;
int main()
{
boost::asio::streambuf Stream;
// Put 4 bytes into the streambuf...
int SetValue = 0xaabbccdd;
Stream.sputn(reinterpret_cast<const char*>(&SetValue), sizeof(SetValue));
// Consume 3 of the bytes...
Stream.consume(3);
cout << Stream.size() << endl; // should output 1
// Get the last byte...
char GetValue;
// --------- The next line segfaults the program ----------
Stream.sgetn(reinterpret_cast<char*>(&GetValue), sizeof(GetValue));
cout << Stream.size() << endl; // should output 0
return 0;
}
posible error ... – niXman
es esto simplemente 'asio :: streambuf', o' std :: streambuf' muestra el mismo comportamiento? –
También obtuve núcleo descargado. por favor '#include 'para obtener el código compilado. –
vissi