Realistic 3D camera system
3D camera system components
server.hpp
Go to the documentation of this file.
1 //
2 // server.hpp
3 // ~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10 
11 #ifndef HTTP_SERVER4_SERVER_HPP
12 #define HTTP_SERVER4_SERVER_HPP
13 
14 #include <asio.hpp>
15 #include <string>
16 #include <boost/array.hpp>
17 #include <boost/function.hpp>
18 #include <boost/shared_ptr.hpp>
19 #include "request_parser.hpp"
20 
21 namespace http {
22 namespace server4 {
23 
24 struct request;
25 struct reply;
26 
29 {
30 public:
33  explicit server(asio::io_service& io_service,
34  const std::string& address, const std::string& port,
35  boost::function<void(const request&, reply&)> request_handler);
36 
38  void operator()(
40  std::size_t length = 0);
41 
42 private:
43  typedef asio::ip::tcp tcp;
44 
46  boost::function<void(const request&, reply&)> request_handler_;
47 
49  boost::shared_ptr<tcp::acceptor> acceptor_;
50 
52  boost::shared_ptr<tcp::socket> socket_;
53 
55  boost::shared_ptr<boost::array<char, 8192> > buffer_;
56 
58  boost::shared_ptr<request> request_;
59 
61  boost::tribool valid_request_;
62 
64  request_parser request_parser_;
65 
67  boost::shared_ptr<reply> reply_;
68 };
69 
70 } // namespace server4
71 } // namespace http
72 
73 #endif // HTTP_SERVER4_SERVER_HPP
Provides core I/O functionality.
Definition: io_service.hpp:184
Encapsulates the flags needed for TCP.
Definition: tcp.hpp:45
Provides support for implementing stackless coroutines.
Definition: coroutine.hpp:241
A request received from a client.
Definition: request.hpp:22
server(asio::io_service &io_service, const std::string &address, const std::string &port, boost::function< void(const request &, reply &)> request_handler)
Definition: server.cpp:18
Parser for incoming requests.
Class to represent an error code value.
Definition: error_code.hpp:80
A reply to be sent to a client.
Definition: reply.hpp:23
void operator()(asio::error_code ec=asio::error_code(), std::size_t length=0)
Perform work associated with the server.
Definition: server.cpp:31
The top-level coroutine of the HTTP server.
Definition: server.hpp:28