Example #1
0
        virtual void on_async_response_received(
            error_code const & ec,
            size_t bytes_transferred,
            session_ptr sess
        )
        {
            std::cout << ec << " Response received: (" << bytes_transferred << ") ";
            sess->dump_buffer(bytes_transferred);
            std::cout << std::endl;

            if(!ec)
            {
                if(sess->data_buffer[1] == 0x5a)
                {
                    sess->handler(error_code());
                }
                else
                {
                    sess->handler(error_code(boost::asio::error::connection_refused));
                }
            }
            else
            {
                sess->handler(ec);
            }
        }
Example #2
0
 virtual void on_async_request_sent(
     error_code const & ec,
     session_ptr sess
 )
 {
     if(!ec)
     {
         boost::asio::async_read(
             sess->socket.get(),
             boost::asio::buffer(sess->data_buffer),
             boost::asio::transfer_at_least(8),
             boost::bind(
                 &socks4_proxy::on_async_response_received,
                 this,
                 boost::asio::placeholders::error,
                 boost::asio::placeholders::bytes_transferred,
                 sess
             )
         );
     }
     else
     {
         sess->handler(ec);
     }
 }