#include <iostream>
#include <boost/bind.hpp>
#include <boost/asio.hpp>

class session {
public:
    session(boost::asio::io_service& io_service) :
            io_service_(io_service), socket_(io_service), deleted_(false), timeout_(
                    new boost::asio::deadline_timer(io_service_)) {
        std::cout << "Session constructed" << std::endl;
    }
    ~session() {
        delete timeout_;
        std::cout << "Session destructed" << std::endl;
    }

    boost::asio::ip::tcp::socket& socket() {
        return socket_;
    }
    void del() {
        if (!deleted_) {
            deleted_ = true;
            delete this;
        }
    }
    void start(session* new_session) {
        socket_.async_read_some(
                boost::asio::buffer(data_, max_length - 1),
                boost::bind(&session::handle_read, this,
                        boost::asio::placeholders::error,
                        boost::asio::placeholders::bytes_transferred));
        timeout_->expires_from_now(boost::posix_time::milliseconds(10000));
        timeout_->async_wait(
                boost::bind(&session::wait_callback, this,
                        boost::asio::placeholders::error));

    }
    void wait_callback(const boost::system::error_code& error) {
        if (!error) {
            this->socket().shutdown(
                    boost::asio::ip::tcp::socket::shutdown_both);
            this->socket().close();
            this->del();
        }

    }
    void handle_read(const boost::system::error_code& error,
            size_t bytes_transferred) {
        if (!error) {
            timeout_->cancel();
            data_[bytes_transferred] = '\0';
            if (NULL != strstr(data_, "quit")) {
                this->socket().shutdown(
                        boost::asio::ip::tcp::socket::shutdown_both);
                this->socket().close();
                io_service_.stop();
            } else {
                boost::asio::async_write(
                        socket_,
                        boost::asio::buffer(data_, bytes_transferred),
                        boost::bind(&session::handle_write, this,
                                boost::asio::placeholders::error));

                socket_.async_read_some(
                        boost::asio::buffer(data_, max_length - 1),
                        boost::bind(&session::handle_read, this,
                                boost::asio::placeholders::error,
                                boost::asio::placeholders::bytes_transferred));
                timeout_->expires_from_now(
                        boost::posix_time::milliseconds(10000));
                timeout_->async_wait(
                        boost::bind(&session::wait_callback, this,
                                boost::asio::placeholders::error));
            }
        } else {
            this->del();
        }
    }

    void handle_write(const boost::system::error_code& error) {
        if (!error) {
            //
        } else {
            this->del();
        }
    }

private:
    boost::asio::io_service& io_service_;
    boost::asio::ip::tcp::socket socket_;
    enum {
        max_length = 1024
    };
    char data_[max_length];
    boost::asio::deadline_timer* timeout_;
    bool deleted_;
};

class server {
public:
    server(boost::asio::io_service& io_service, short port) :
            io_service_(io_service), acceptor_(
                    io_service,
                    boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(),
                            port)) {
        new_session_ = new session(io_service_);
        acceptor_.async_accept(
                new_session_->socket(),
                boost::bind(&server::handle_accept, this,
                        boost::asio::placeholders::error));
        std::cout << "Server constructed" << std::endl;
    }
    ~server() {
        delete new_session_;
        std::cout << "Server destructed" << std::endl;
    }
    void handle_accept(const boost::system::error_code& error) {
        if (!error) {
            new_session_->start(new_session_);
            new_session_ = new session(io_service_);
            acceptor_.async_accept(
                    new_session_->socket(),
                    boost::bind(&server::handle_accept, this,
                            boost::asio::placeholders::error));
        } else {
        }
    }

private:
    boost::asio::io_service& io_service_;
    boost::asio::ip::tcp::acceptor acceptor_;
    session* new_session_;
};

int main(int argc, char* argv[]) {
    try {
        boost::asio::io_service io_service;
        server s(io_service, 9999);
        io_service.run();
    } catch (std::exception& e) {
        std::cerr << "Exception: " << e.what() << "\n";
    }
    return 0;
}

Dr memory:

 ERRORS FOUND:
    203 unique,  1254 total unaddressable access(es)
     35 unique,   629 total uninitialized access(es)
      0 unique,     0 total invalid heap argument(s)
      0 unique,     0 total warning(s)
     17 unique,    39 total,   2198 byte(s) of leak(s)
      4 unique,    46 total,   2800 byte(s) of possible leak(s)
ERRORS IGNORED:
      0 user-suppressed,     0 default-suppressed error(s)
      0 user-suppressed,     2 default-suppressed leak(s)
     56 ignored assumed-innocuous system leak(s)
    152 still-reachable allocation(s)
      0 error(s) beyond -report_max
      0 leak(s) beyond -report_leak_max

skąd te wszystkie błędy - siedzę nad tym drugi dzień i nie mam już pomysłów?