Asio (C++ library)

Asio C++ library
Original authorChristopher M. Kohlhoff
Stable release
1.38.2 / July 19, 2026; 3 months ago (2026-07-19)
Written inC++
TypeLibrary or framework
LicenseBoost Software License
Websitethink-async.com
Repository

Asio (asio) is a freely available, open-source, cross-platform C++ library for network programming. It provides developers with a asynchronous I/O model. The library has been developed by Christopher M. Kohlhoff since 2003.

Boost.Asio (boost::asio) was accepted into Boost on 30 December 2005 after a 20-day review.

As of 2024, Asio continues to evolve, with ongoing contributions from the community and enhancements to its functionality. The library is regularly updated to support the latest C++ standards and best practices in network programming. Developers are encouraged to explore the extensive documentation and tutorials available on the official Asio website, which cover a wide range of topics, from basic usage to advanced features. Boost.Asio also supports working with C++20 coroutines.

API

The API below is expressed in terms of the original asio library, whose namespace is asio; its Boost counterpart instead uses the boost::asio namespace.

Execution

  • asio::io_context: the context for asynchronous I/O, which monitors asynchronous tasks and maintains a queue of completed operations ready to execute. Acts as an interface to the operating system's multiplexing mechanism.
  • asio::executor: a lightweight handle or strategy determining where and how a function a function/completion handler should run.

Network I/O

  • asio::steady_timer, asio::system_timer: time-management objects used to delay execution or enforce timeouts on operations
  • asio::posix::stream_descriptor, asio::windows::stream_handle: OS-specific abstractions for native files/pipes/console streams
  • asio::ip::icmp: the flags and types needed for Internet Control Message Protocol (ICMP).
    • asio::ip::udp::endpoint: the ICMP endpoint type
    • asio::ip::udp::resolver: the ICMP resolver type
    • asio::ip::udp::socket: the ICMP socket type
  • asio::ip::tcp: the flags and types needed for Transmission Control Protocol (TCP).
    • asio::ip::tcp::acceptor: the TCP acceptor type
    • asio::ip::tcp::endpoint: the TCP endpoint type
    • asio::ip::tcp::iostream: the TCP iostream type
    • asio::ip::tcp::resolver: the TCP resolver type
    • asio::ip::tcp::socket: the TCP socket type
  • asio::ip::udp: the flags and types needed for User Datagram Protocol (UDP).
    • asio::ip::udp::endpoint: the UDP endpoint type
    • asio::ip::udp::resolver: the UDP resolver type
    • asio::ip::udp::socket: the UDP socket type

Data representation

Used to point to memory blocks without copying data, for wrapping over arrays and sequential containers, akin to std::span<T> and std::string_view.

  • asio::const_buffer: a read-only view of a memory block (for writing data out to a socket)
  • asio::mutable_buffer: a writable view of a memory block (for reading incoming data in from a socket)
  • asio::streambuf: a dynamically-resizing stream-style buffer (extends std::streambuf).

Concurrency control

  • asio::strand: a logical executor adapter for handler execution serialization; if an asio::io_context runs across a pool of multiple threads, handlers assigned to the same asio::strand are guaranteed to execute sequentially.

Completion tokens

Completion tokens are used to specify how to receive the result of an asynchronous operation, and are passed as the last argument of any function prefixed with "async". Traditionally, this is done with callbacks/lambdas.

  • asio::use_future: transforms the asynchronous function to return a std::future<T>.
  • asio::use_awaitable: converts the asynchronous signature into a coroutine frame, allowing the use of co_await.

Networking TS

The C++ Networking TS was itself based on asio, proposing asynchronous I/O and networking into the C++ standard library. It was implemented by some vendors, such as GCC.

The following headers were defined in the C++ networking TS. The symbols were placed in std::extensions::net (eventually for std::net).

NameDescription
<netfwd> Contains forward declarations of Networking TS components.
<executor> Provides asynchronous models for networking.
<io_context> Provides basic I/O services for networking.
<timer> Provides timer operations for networking.
<buffer> Provides buffers and buffer-oriented streams for networking.
<socket> Provides sockets and socket streams for networking.
<internet> Provides internet protocols for networking.
<net> Includes all Networking TS headers.

The networking API based on asio was first submitted to the C++ standards committee in 2006 for possible inclusion in the second Technical Report on C++ Library Extensions (TR2), however was not integrated, with the most recent development in 2020. Instead, in C++26, the std::execution framework (based on NVIDIA's stdexec library) was adopted into the C++ standard library as C++'s asynchronous programming framework, with an alternative asynchronous I/O API based on the Senders/Receiver model.

References

  1. ↑ "Asio C++ Library". think-async.com. Retrieved 2024-08-01.
  2. ↑ C++20 Coroutines Support, boost.org. Retrieved 16 April 2026
  3. ↑ Jonathan Wakely (4 April 2018). "Working Draft, C++ Extensions for Networking" (PDF). cplusplus.github.io. WG21.
  4. ↑ Michael Larabel (13 October 2018). "GCC9 Lands Initial C++ Networking TS Implementation". phoronix.com. Phoronix.
  5. ↑ cppreference.com (3 February 2026). "Extensions for networking". cppreference.com. cppreference.com.
  6. ↑ Christopher Kohlhoff (8 September 2006). "Networking Library Proposal for TR2" (PDF). open-std.org. WG21.
  7. ↑ Christopher Kohlhoff (18 January 2019). "Reconsider the Networking TS for inclusion in C++20". open-std.org. WG21.
  8. ↑ cppreference.com. "Execution control library (since C++26)". cppreference.com. cppreference.com. Retrieved 15 February 2026.
  9. ↑ Eric Niebler. "Welcome to stdexec". nvidia.github.io. Nvidia Corporation. Retrieved 11 July 2026.
  10. ↑ Sutter, Herb. "Trip report: Summer ISO C++ standards meeting (St Louis, MO, USA)". Sutter's Mill. Retrieved 6 September 2025.
  11. ↑ Michał Dominiak; Georgy Evtushenko; Lewis Baker; Lucian Radu Teodorescu; Lee Howes; Kirk Shoop; Michael Garland; Eric Niebler; Bryce Adelstein Lelbach (28 June 2024). "P2300R10 std::execution". open-std.org. WG21.
  12. ↑ Dietmar Kühl (12 October 2023). "Sender/Receiver Interface For Networking" (PDF). open-std.org. WG21.