I use Boost.Asio for network operations, they should (and, in fact, cannot create complex data structures or anything else), remain quite low, because I cannot afford the luxury of serialization overhead (and libs I found that offered good enough performance, it seemed to be bad for my case).
The problem is the async record that I am making from the client (in QT, but that should probably be irrelevant here). The callback specified in async_writeis not called, ever, and I absolutely do not understand why. The code:
void SpikingMatrixClient::addMatrix() {
std::cout << "entered add matrix" << std::endl;
int action = protocol::Actions::AddMatrix;
int matrixSize = this->ui->editNetworkSize->text().toInt();
std::ostream out(&buf);
out.write(reinterpret_cast<const char*>(&action), sizeof(action));
out.write(reinterpret_cast<const char*>(&matrixSize), sizeof(matrixSize));
boost::asio::async_write(*connection.socket(), buf.data(),
boost::bind(&SpikingMatrixClient::onAddMatrix, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
which calls the first record. Callback
void SpikingMatrixClient::onAddMatrix(const boost::system::error_code& error, size_t bytes_transferred) {
std::cout << "entered onAddMatrix" << std::endl;
if (!error) {
buf.consume(bytes_transferred);
requestMatrixList();
} else {
QString message = QString::fromStdString(error.message());
this->ui->statusBar->showMessage(message, 15000);
}
}
, . - - , ?
P.S. , , , . , .