Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Examples

C++03 Examples
C++11 Examples
Allocation

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

Buffers

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

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.

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

Echo

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

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:

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

HTTP Client

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

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.

HTTP Server 2

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

HTTP Server 3

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

HTTP Server 4

A single-threaded HTTP server implemented using stackless coroutines.

ICMP

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

Invocation

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

Iostreams

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

Multicast

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

Serialization

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

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<>.

SOCKS 4

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

SSL

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

Timeouts

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

Timers

Examples showing how to customise deadline_timer using different time types.

Porthopper

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

Nonblocking

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

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.

UNIX Domain Sockets

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

Windows

An example showing how to use the Windows-specific function TransmitFile with Boost.Asio.

Allocation

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

Buffers

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

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.

Echo

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

Futures

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

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.

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.


PrevUpHomeNext