Boost http server example

Source: Internet
Author: User

Examples

Examples


Allocation

This example shows how to customise the allocation of memory associated with asynchronous operations.

  • Boost_asio/example/allocation/server. cpp


Buffers

This example demonstrates how to create reference counted buffers that can be used with socket read and write operations.

  • Boost_asio/example/buffers/reference_counted.cpp


Chat

This example implements a chat server and client. The programs use a custom protocol with a fixed length message header and variable length message body.

  • Boost_asio/example/chat/chat_message.hpp
  • Boost_asio/example/chat/chat_client.cpp
  • Boost_asio/example/chat/chat_server.cpp

The following POSIX-specific chat client demonstrates how to use the posix: stream_descriptor class to perform console input and output.

  • Boost_asio/example/chat/posix_chat_client.cpp


Echo

A collection of simple clients and servers, showing the use of both synchronous and asynchronous operations.

  • Boost_asio/example/echo/async_tcp_echo_server.cpp
  • Boost_asio/example/echo/async_udp_echo_server.cpp
  • Boost_asio/example/echo/blocking_tcp_echo_client.cpp
  • Boost_asio/example/echo/blocking_tcp_echo_server.cpp
  • Boost_asio/example/echo/blocking_udp_echo_client.cpp
  • Boost_asio/example/echo/blocking_udp_echo_server.cpp


Fork

These POSIX-specific examples show how to use Boost. Asio in conjunction withfork()System call. The first example extends strates the steps required to start a daemon process:

  • Boost_asio/example/fork/daemon. cpp

The second example demonstrates how it is possible to fork a process from within a completion handler.

  • Boost_asio/example/fork/process_per_connection.cpp


HTTP Client

Example programs implementing simple HTTP 1.0 clients. These examples show how to use the read_until and async_read_until functions.

  • Boost_asio/example/http/client/sync_client.cpp
  • Boost_asio/example/http/client/async_client.cpp


HTTP Server

This example extends strates the use of asio in a simple single-threaded server implementation of HTTP 1.0. It demonstrates how to perform a clean shutdown by canceling all outstanding asynchronous operations.

  • Boost_asio/example/http/server/connection. cpp
  • Boost_asio/example/http/server/connection. hpp
  • Boost_asio/example/http/server/connection_manager.cpp
  • Boost_asio/example/http/server/connection_manager.hpp
  • Boost_asio/example/http/server/header. hpp
  • Boost_asio/example/http/server/main. cpp
  • Boost_asio/example/http/server/mime_types.cpp
  • Boost_asio/example/http/server/mime_types.hpp
  • Boost_asio/example/http/server/reply. cpp
  • Boost_asio/example/http/server/reply. hpp
  • Boost_asio/example/http/server/request. hpp
  • Boost_asio/example/http/server/request_handler.cpp
  • Boost_asio/example/http/server/request_handler.hpp
  • Boost_asio/example/http/server/request_parser.cpp
  • Boost_asio/example/http/server/request_parser.hpp
  • Boost_asio/example/http/server. cpp
  • Boost_asio/example/http/server. hpp


HTTP Server 2

An HTTP server using an io_service-per-CPU design.

  • Boost_asio/example/http/server2/connection. cpp
  • Boost_asio/example/http/server2/connection. hpp
  • Boost_asio/example/http/server2/header. hpp
  • Boost_asio/example/http/server2/io_service_pool.cpp
  • Boost_asio/example/http/server2/io_service_pool.hpp
  • Boost_asio/example/http/server2/main. cpp
  • Boost_asio/example/http/server2/mime_types.cpp
  • Boost_asio/example/http/server2/mime_types.hpp
  • Boost_asio/example/http/server2/reply. cpp
  • Boost_asio/example/http/server2/reply. hpp
  • Boost_asio/example/http/server2/request. hpp
  • Boost_asio/example/http/server2/request_handler.cpp
  • Boost_asio/example/http/server2/request_handler.hpp
  • Boost_asio/example/http/server2/request_parser.cpp
  • Boost_asio/example/http/server2/request_parser.hpp
  • Boost_asio/example/http/server2/server. cpp
  • Boost_asio/example/http/server2/server. hpp


HTTP Server 3

An HTTP server using a single io_service and a thread pool callingio_service::run().

  • Boost_asio/example/http/server3/connection. cpp
  • Boost_asio/example/http/server3/connection. hpp
  • Boost_asio/example/http/server3/header. hpp
  • Boost_asio/example/http/server3/main. cpp
  • Boost_asio/example/http/server3/mime_types.cpp
  • Boost_asio/example/http/server3/mime_types.hpp
  • Boost_asio/example/http/server3/reply. cpp
  • Boost_asio/example/http/server3/reply. hpp
  • Boost_asio/example/http/server3/request. hpp
  • Boost_asio/example/http/server3/request_handler.cpp
  • Boost_asio/example/http/server3/request_handler.hpp
  • Boost_asio/example/http/server3/request_parser.cpp
  • Boost_asio/example/http/server3/request_parser.hpp
  • Boost_asio/example/http/server3/server. cpp
  • Boost_asio/example/http/server3/server. hpp


HTTP Server 4

A single-threaded HTTP server implemented using stackless coroutines.

  • Boost_asio/example/http/server4/coroutine. hpp
  • Boost_asio/example/http/server4/file_handler.cpp
  • Boost_asio/example/http/server4/file_handler.hpp
  • Boost_asio/example/http/server4/header. hpp
  • Boost_asio/example/http/server4/main. cpp
  • Boost_asio/example/http/server4/mime_types.cpp
  • Boost_asio/example/http/server4/mime_types.hpp
  • Boost_asio/example/http/server4/reply. cpp
  • Boost_asio/example/http/server4/reply. hpp
  • Boost_asio/example/http/server4/request. hpp
  • Boost_asio/example/http/server4/request_parser.cpp
  • Boost_asio/example/http/server4/request_parser.hpp
  • Boost_asio/example/http/server4/server. cpp
  • Boost_asio/example/http/server4/server. hpp
  • Boost_asio/example/http/server4/unyield. hpp
  • Boost_asio/example/http/server4/yield. hpp


ICMP

This example shows how to use raw sockets with ICMP to ping a remote host.

  • Boost_asio/example/icmp/ping. cpp
  • Boost_asio/example/icmp/ipv4_header.hpp
  • Boost_asio/example/icmp/icmp_header.hpp


Invocation

This example shows how to customise handler invocation. Completion handlers are added to a priority queue rather than executed immediately.

  • Boost_asio/example/invocation/prioritised_handlers.cpp


Iostreams

Two examples showing how to use ip: tcp: iostream.

  • Boost_asio/example/iostreams/daytime_client.cpp
  • Boost_asio/example/iostreams/daytime_server.cpp
  • Boost_asio/example/iostreams/http_client.cpp


Multicast

An example showing the use of multicast to transmit packets to a group of subscribers.

  • Boost_asio/example/multicast/receiver. cpp
  • Boost_asio/example/multicast/sender. cpp


Serialization

This example shows how Boost. Serialization can be used with asio to encode and decode structures for transmission over a socket.

  • Boost_asio/example/serialization/client. cpp
  • Boost_asio/example/serialization/connection. hpp
  • Boost_asio/example/serialization/server. cpp
  • Boost_asio/example/serialization/stock. hpp


Services

This example demonstrates how to integrate custom functionality (in this case, for logging) into asio's io_service, and how to use a custom service with basic_stream_socket <>.

  • Boost_asio/example/services/basic_logger.hpp
  • Boost_asio/example/services/daytime_client.cpp
  • Boost_asio/example/services/logger. hpp
  • Boost_asio/example/services/logger_service.cpp
  • Boost_asio/example/services/logger_service.hpp
  • Boost_asio/example/services/stream_socket_service.hpp


SOCKS 4

Example client program implementing the SOCKS 4 protocol for communication via a proxy.

  • Boost_asio/example/socks4/sync_client.cpp
  • Boost_asio/example/socks4/socks4.hpp


SSL

Example client and server programs showing the use of the ssl: stream <> template with asynchronous operations.

  • Boost_asio/example/ssl/client. cpp
  • Boost_asio/example/ssl/server. cpp


Timeouts

A collection of examples showing how to cancel long running asynchronous operations after a period of time.

  • Boost_asio/example/timeouts/async_tcp_client.cpp
  • Boost_asio/example/timeouts/blocking_tcp_client.cpp
  • Boost_asio/example/timeouts/blocking_udp_client.cpp
  • Boost_asio/example/timeouts/server. cpp


Timers

Examples showing how to customise deadline_timer using different time types.

  • Boost_asio/example/timers/tick_count_timer.cpp
  • Boost_asio/example/timers/time_t_timer.cpp


Porthopper

Example between strating mixed synchronous and asynchronous operations, and how to use Boost. Lambda with Boost. Asio.

  • Boost_asio/example/porthopper/protocol. hpp
  • Boost_asio/example/porthopper/client. cpp
  • Boost_asio/example/porthopper/server. cpp


Nonblocking

Example demonstrating reactor-style operations for integrating a third-party library that wants to perform the I/O operations itself.

  • Boost_asio/example/nonblocking/third_party_lib.cpp


UNIX Domain Sockets

Examples showing how to use UNIX domain (local) sockets.

  • Boost_asio/example/local/connect_pair.cpp
  • Boost_asio/example/local/stream_server.cpp
  • Boost_asio/example/local/stream_client.cpp


Windows

An example showing how to use the Windows-specific functionTransmitFileWith Boost. Asio.

  • Boost_asio/example/windows/transmit_file.cpp
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.