Discussion:
[asio-users] write_some error
przemek.biernat
2013-07-01 19:22:49 UTC
Permalink
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_inje
ctor<boost::system::system_error> > at memory location 0x0021F520.

Does anybody know what is wrong?
Green, Cliff
2013-07-01 20:35:42 UTC
Permalink
The only immediate problem I see is the "write_some".

Loading...