8 #include <boost/bind.hpp>
18 : _strand (ioService), _socket (ioService), _requestHandler (ioHandler) {
29 _socket.async_read_some (boost::asio::buffer (_buffer),
30 _strand.wrap (boost::bind (&Connection::handleRead,
32 boost::asio::placeholders::error,
33 boost::asio::placeholders::bytes_transferred)));
37 void Connection::handleRead (
const boost::system::error_code& iErrorCode,
38 std::size_t bytes_transferred) {
41 const bool hasBeenSuccessfull = _requestHandler.
handleRequest (_request,
44 if (hasBeenSuccessfull ==
true) {
46 boost::asio::async_write (_socket, _reply.
to_buffers(),
47 _strand.wrap (boost::bind (&Connection::handleWrite,
49 boost::asio::placeholders::error)));
53 boost::asio::async_write (_socket, _reply.
to_buffers(),
54 _strand.wrap (boost::bind (&Connection::handleWrite,
56 boost::asio::placeholders::error)));
69 void Connection::handleWrite (
const boost::system::error_code& iErrorCode) {
73 boost::system::error_code ignored_ec;
74 _socket.shutdown (boost::asio::ip::tcp::socket::shutdown_both,