c++ - socket migration from boost::asio::io_service to another epoll loop -
i've boost asio socket. after handshaking phase on over custom protocol. want take out socket's native handle io_service , put in own epoll based loop running on different thread.
so after reading last message of handshaking phase not invoking boost::asio::async_read
. taking native handle , adding own epoll loop.
but on client side broken pipe
error.
i've tried delay client before tries write, when delay several seconds gets broken pipe. in delayed time there supposed reader on server side, epoll loop.
void hc::common::connection::handle_read(hc::common::connection::state s, const boost::system::error_code& error, std::size_t bytes){ hook_read(error, bytes); if(!error){ switch(s){ case header: _packet.parse_header(); ............ break; case body: bool keep_reading = available(); // virtual << here returns false overridden method _packet.clear(); if(keep_reading){ boost::asio::async_read(_socket, boost::asio::buffer(_packet.data(), hc::common::packet::header_length), boost::asio::transfer_at_least(hc::common::packet::header_length), boost::bind(&hc::common::connection::handle_read, shared_from_this(), header, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); } break; } } }
Comments
Post a Comment