From ff01b716711b97c2fcaa709ea97f7650f106aa10 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 7 Oct 2016 14:13:19 +0200 Subject: Added ASIO networking library (nw) --- .../src/examples/cpp03/http/server/connection.hpp | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 3rdparty/asio/src/examples/cpp03/http/server/connection.hpp (limited to '3rdparty/asio/src/examples/cpp03/http/server/connection.hpp') diff --git a/3rdparty/asio/src/examples/cpp03/http/server/connection.hpp b/3rdparty/asio/src/examples/cpp03/http/server/connection.hpp new file mode 100644 index 00000000000..6193b486443 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp03/http/server/connection.hpp @@ -0,0 +1,83 @@ +// +// connection.hpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef HTTP_CONNECTION_HPP +#define HTTP_CONNECTION_HPP + +#include +#include +#include +#include +#include +#include "reply.hpp" +#include "request.hpp" +#include "request_handler.hpp" +#include "request_parser.hpp" + +namespace http { +namespace server { + +class connection_manager; + +/// Represents a single connection from a client. +class connection + : public boost::enable_shared_from_this, + private boost::noncopyable +{ +public: + /// Construct a connection with the given io_context. + explicit connection(asio::io_context& io_context, + connection_manager& manager, request_handler& handler); + + /// Get the socket associated with the connection. + asio::ip::tcp::socket& socket(); + + /// Start the first asynchronous operation for the connection. + void start(); + + /// Stop all asynchronous operations associated with the connection. + void stop(); + +private: + /// Handle completion of a read operation. + void handle_read(const asio::error_code& e, + std::size_t bytes_transferred); + + /// Handle completion of a write operation. + void handle_write(const asio::error_code& e); + + /// Socket for the connection. + asio::ip::tcp::socket socket_; + + /// The manager for this connection. + connection_manager& connection_manager_; + + /// The handler used to process the incoming request. + request_handler& request_handler_; + + /// Buffer for incoming data. + boost::array buffer_; + + /// The incoming request. + request request_; + + /// The parser for the incoming request. + request_parser request_parser_; + + /// The reply to be sent back to the client. + reply reply_; +}; + +typedef boost::shared_ptr connection_ptr; + +} // namespace server +} // namespace http + +#endif // HTTP_CONNECTION_HPP -- cgit v1.2.3-70-g09d2