c++ - ASIO - respone to a client request does not work -


i have piece of code on server

    void sockettransportsession::doread() {     auto self(shared_from_this());     socket.async_read_some(ba::buffer(data),         [this, self](boost::system::error_code ec, std::size_t length) {             if (!ec) {                 //todo: process request                 socket.async_write_some(boost::asio::buffer(res, maxlen),                     [this, self](boost::system::error_code ec, std::size_t length) {                         assert(!ec);                         assert(length == maxlen);                         //read more                     doread();                 });             }         }); } 

what want read client request (process it, dummy now) , reply that, , repeat cycle i.e. read more client/process/...

in presented code asserts not fired (we have confirmation !ec , replay sent) in client code don't see response coming (i.e. client blocking read @ point , not receive nothing).

edit found writing server has expected behavior. seems not evident reason

void sockettransportsession::doread() {     auto self(shared_from_this());     socket.async_read_some(ba::buffer(data),         [this, self](boost::system::error_code ec, std::size_t length) {             if (!ec) {                 dowrite(length);             }         }); }  void sockettransportsession::dowrite(std::size_t length) {     auto self(shared_from_this());     ba::async_write(socket, ba::buffer(data),         [this, self](boost::system::error_code ec, std::size_t length) {             if (!ec) {                 doread();             }     }); } 

what happens here ?


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -