asio 0.3.8rc3 Home | Reference | Tutorial | Examples | Design
Examples

http/server/connection.hpp

Go to the documentation of this file.
00001 //
00002 // connection.hpp
00003 // ~~~~~~~~~~~~~~
00004 //
00005 // Copyright (c) 2003-2007 Christopher M. Kohlhoff (chris at kohlhoff dot com)
00006 //
00007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
00008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00009 //
00010 
00011 #ifndef HTTP_CONNECTION_HPP
00012 #define HTTP_CONNECTION_HPP
00013 
00014 #include <asio.hpp>
00015 #include <boost/array.hpp>
00016 #include <boost/noncopyable.hpp>
00017 #include <boost/shared_ptr.hpp>
00018 #include <boost/enable_shared_from_this.hpp>
00019 #include "reply.hpp"
00020 #include "request.hpp"
00021 #include "request_handler.hpp"
00022 #include "request_parser.hpp"
00023 
00024 namespace http {
00025 namespace server {
00026 
00027 class connection_manager;
00028 
00030 class connection
00031   : public boost::enable_shared_from_this<connection>,
00032     private boost::noncopyable
00033 {
00034 public:
00036   explicit connection(asio::io_service& io_service,
00037       connection_manager& manager, request_handler& handler);
00038 
00040   asio::ip::tcp::socket& socket();
00041 
00043   void start();
00044 
00046   void stop();
00047 
00048 private:
00050   void handle_read(const asio::error_code& e,
00051       std::size_t bytes_transferred);
00052 
00054   void handle_write(const asio::error_code& e);
00055 
00057   asio::ip::tcp::socket socket_;
00058 
00060   connection_manager& connection_manager_;
00061 
00063   request_handler& request_handler_;
00064 
00066   boost::array<char, 8192> buffer_;
00067 
00069   request request_;
00070 
00072   request_parser request_parser_;
00073 
00075   reply reply_;
00076 };
00077 
00078 typedef boost::shared_ptr<connection> connection_ptr;
00079 
00080 } // namespace server
00081 } // namespace http
00082 
00083 #endif // HTTP_CONNECTION_HPP
asio 0.3.8rc3 Home | Reference | Tutorial | Examples | Design