| Home | Libraries | People | FAQ | More

### C++11 Examples

##### Allocation

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

- boost_asio/example/cpp11/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/cpp11/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/cpp11/chat/chat_message.hpp
- boost_asio/example/cpp11/chat/chat_client.cpp
- boost_asio/example/cpp11/chat/chat_server.cpp

##### Echo

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

- boost_asio/example/cpp11/echo/async_tcp_echo_server.cpp
- boost_asio/example/cpp11/echo/async_udp_echo_server.cpp
- boost_asio/example/cpp11/echo/blocking_tcp_echo_client.cpp
- boost_asio/example/cpp11/echo/blocking_tcp_echo_server.cpp
- boost_asio/example/cpp11/echo/blocking_udp_echo_client.cpp
- boost_asio/example/cpp11/echo/blocking_udp_echo_server.cpp

##### Fork

These POSIX-specific examples show how to use Boost.Asio in conjunction with the `fork()` system call. The first example illustrates the steps required to start a daemon process:

- boost_asio/example/cpp11/fork/daemon.cpp

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

- boost_asio/example/cpp11/fork/process_per_connection.cpp

##### Futures

This example demonstrates how to use std::future in conjunction with Boost.Asio's asynchronous operations.

- boost_asio/example/cpp11/futures/daytime_client.cpp

##### Handler Tracking

This example shows how to implement custom handler tracking.

- boost_asio/example/cpp11/handler_tracking/custom_tracking.hpp

##### HTTP Server

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

- boost_asio/example/cpp11/http/server/connection.cpp
- boost_asio/example/cpp11/http/server/connection.hpp
- boost_asio/example/cpp11/http/server/connection_manager.cpp
- boost_asio/example/cpp11/http/server/connection_manager.hpp
- boost_asio/example/cpp11/http/server/header.hpp
- boost_asio/example/cpp11/http/server/main.cpp
- boost_asio/example/cpp11/http/server/mime_types.cpp
- boost_asio/example/cpp11/http/server/mime_types.hpp
- boost_asio/example/cpp11/http/server/reply.cpp
- boost_asio/example/cpp11/http/server/reply.hpp
- boost_asio/example/cpp11/http/server/request.hpp
- boost_asio/example/cpp11/http/server/request_handler.cpp
- boost_asio/example/cpp11/http/server/request_handler.hpp
- boost_asio/example/cpp11/http/server/request_parser.cpp
- boost_asio/example/cpp11/http/server/request_parser.hpp
- boost_asio/example/cpp11/http/server/server.cpp
- boost_asio/example/cpp11/http/server/server.hpp

##### Multicast

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

- boost_asio/example/cpp11/multicast/receiver.cpp
- boost_asio/example/cpp11/multicast/sender.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/cpp11/nonblocking/third_party_lib.cpp

##### Operations

Examples showing how to implement composed asynchronous operations as reusable library functions.

- boost_asio/example/cpp11/operations/composed_1.cpp
- boost_asio/example/cpp11/operations/composed_2.cpp
- boost_asio/example/cpp11/operations/composed_3.cpp
- boost_asio/example/cpp11/operations/composed_4.cpp
- boost_asio/example/cpp11/operations/composed_5.cpp
- boost_asio/example/cpp11/operations/composed_6.cpp
- boost_asio/example/cpp11/operations/composed_7.cpp
- boost_asio/example/cpp11/operations/composed_8.cpp

##### SOCKS 4

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

- boost_asio/example/cpp11/socks4/sync_client.cpp
- boost_asio/example/cpp11/socks4/socks4.hpp

##### Spawn

Example of using the boost::asio::spawn() function, a wrapper around the Boost.Coroutine library, to implement a chain of asynchronous operations using stackful coroutines.

- boost_asio/example/cpp11/spawn/echo_server.cpp

##### SSL

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

- boost_asio/example/cpp11/ssl/client.cpp
- boost_asio/example/cpp11/ssl/server.cpp

##### Timeouts

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

- boost_asio/example/cpp11/timeouts/async_tcp_client.cpp
- boost_asio/example/cpp11/timeouts/blocking_tcp_client.cpp
- boost_asio/example/cpp11/timeouts/blocking_token_tcp_client.cpp
- boost_asio/example/cpp11/timeouts/blocking_udp_client.cpp
- boost_asio/example/cpp11/timeouts/server.cpp

##### Timers

Example showing how to customise basic_waitable_timer using a different clock type.

- boost_asio/example/cpp11/timers/time_t_timer.cpp

##### UNIX Domain Sockets

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

- boost_asio/example/cpp11/local/connect_pair.cpp
- boost_asio/example/cpp11/local/iostream_client.cpp
- boost_asio/example/cpp11/local/stream_server.cpp
- boost_asio/example/cpp11/local/stream_client.cpp