boost::asio write_some - error

  • Thread starter Przemek Biernat
  • Start date
P

Przemek Biernat

I have some problem with send data by boost::asio. My code:

void Connection::SendCommand(std::shared_ptr<ICommand> command)
{
int dataSize = command->GetSize();

vector<char> dataBuffer = vector<char>(dataSize);

stringstream ss;
binary_oarchive oa(ss);
command->Serialize(oa);

if(_side == Server)
command->Execute();

binary_iarchive ia(ss);

ia.load_binary(&dataBuffer[0], dataSize);

int* header = new int[3];

header[0] = (int)(command->Type());
header[1] = (int)FromClientToServer;
header[2] = dataSize;

size_t s = _socket->write_some(buffer(header, 3*sizeof(int)));
size_t s1 = _socket->write_some(buffer(dataBuffer, dataSize*sizeof(char)));

delete[] header;
}

I get exception on the second call write_some:

boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> > at memory location 0x0021F520.

Does anybody know what is wrong?
 
C

Cholo Lennon

I have some problem with send data by boost::asio. My code:

void Connection::SendCommand(std::shared_ptr<ICommand> command)
{
int dataSize = command->GetSize();

vector<char> dataBuffer = vector<char>(dataSize);

stringstream ss;
binary_oarchive oa(ss);
command->Serialize(oa);

if(_side == Server)
command->Execute();

binary_iarchive ia(ss);

ia.load_binary(&dataBuffer[0], dataSize);

int* header = new int[3];

header[0] = (int)(command->Type());
header[1] = (int)FromClientToServer;
header[2] = dataSize;

size_t s = _socket->write_some(buffer(header, 3*sizeof(int)));
size_t s1 = _socket->write_some(buffer(dataBuffer, dataSize*sizeof(char)));

delete[] header;
}

I get exception on the second call write_some:

boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> > at memory location 0x0021F520.

Does anybody know what is wrong?

The best place to ask about boost libraries is:
gmane.comp.lib.boost.user (point your news reader to news.gmane.org)

Regards
 
C

Christopher Pisz

I have some problem with send data by boost::asio. My code:

void Connection::SendCommand(std::shared_ptr<ICommand> command)
{
int dataSize = command->GetSize();

vector<char> dataBuffer = vector<char>(dataSize);

stringstream ss;
binary_oarchive oa(ss);
command->Serialize(oa);

if(_side == Server)
command->Execute();

binary_iarchive ia(ss);

ia.load_binary(&dataBuffer[0], dataSize);

int* header = new int[3];

header[0] = (int)(command->Type());
header[1] = (int)FromClientToServer;
header[2] = dataSize;

size_t s = _socket->write_some(buffer(header, 3*sizeof(int)));
size_t s1 = _socket->write_some(buffer(dataBuffer, dataSize*sizeof(char)));

delete[] header;
}

I get exception on the second call write_some:

boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> > at memory location 0x0021F520.

Does anybody know what is wrong?


Funny, I had the what I think might be the same error today when I
upgraded to boost 1.53 and Visual Studio 2012. Did you debug through it
and see where it was being thrown from in the boost source?
 
P

Przemek Biernat

Funny, I had the what I think might be the same error today when I

upgraded to boost 1.53 and Visual Studio 2012. Did you debug through it

and see where it was being thrown from in the boost source?

Now I get this error on read in function in file read.hpp.
When I call io_service.run() on the client then the server try to read data, but I'm not sending at this moment and I get error in function read.

inline std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers)
{
boost::system::error_code ec;
std::size_t bytes_transferred = read(s, buffers, transfer_all(), ec);
boost::asio::detail::throw_error(ec, "read");
return bytes_transferred;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top