...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The following platform and compiler combinations are regularly tested:
The following platforms may also work:
__USE_W32_SOCKETS
must be defined.)
The following libraries must be available in order to link programs that use Boost.Asio:
boost::system::error_code
and boost::system::system_error
classes.
spawn()
to launch coroutines.
read_until()
or async_read_until()
overloads that take a boost::regex
parameter.
Furthermore, some of the examples also require the Boost.Thread, Boost.Date_Time or Boost.Serialization libraries.
Note | |
---|---|
With MSVC or Borland C++ you may want to add |
You may build the subset of Boost libraries required to use Boost.Asio and its examples by running the following command from the root of the Boost download package:
b2 --with-system --with-thread --with-date_time --with-regex --with-serialization stage
This assumes that you have already built b2
. Consult the Boost.Build
documentation for more details.
By default, Boost.Asio is a header-only library. However, some developers may
prefer to build Boost.Asio using separately compiled source code. To do this,
add #include <boost/asio/impl/src.hpp>
to one (and only
one) source file in a program, then build the program with BOOST_ASIO_SEPARATE_COMPILATION
defined in the project/compiler settings. Alternatively, BOOST_ASIO_DYN_LINK
may be defined to build a separately-compiled Boost.Asio as part of a shared
library.
If using Boost.Asio's SSL support, you will also need to add #include
<boost/asio/ssl/impl/src.hpp>
.
The macros listed in the table below may be used to control the behaviour of Boost.Asio.
Macro |
Description |
---|---|
|
Enables Boost.Asio's buffer debugging support, which can help identify when invalid buffers are used in read or write operations (e.g. if a std::string object being written is destroyed before the write operation completes).
When using Microsoft Visual C++ 11.0 or later, this macro is defined
automatically if the compiler's iterator debugging support is enabled,
unless
When using g++, this macro is defined automatically if standard library
debugging is enabled ( |
|
Explictly disables Boost.Asio's buffer debugging support. |
|
Explicitly disables |
|
Explicitly disables |
|
Explicitly disables |
|
Explicitly disables |
|
Explicitly disables I/O completion ports support on Windows, forcing
the use of a |
|
Explicitly disables Boost.Asio's threading support, independent of whether or not Boost as a whole supports threads. |
|
By default, Boost.Asio will automatically define |
|
By default, Boost.Asio will automatically define |
|
When compiling for Windows using Microsoft Visual C++ or Borland
C++, Boost.Asio will automatically link in the necessary Windows
SDK libraries for sockets support (i.e. |
|
Enables use of the
The * It will only cancel asynchronous operations that were initiated in the current thread. * It can appear to complete without error, but the request to cancel the unfinished operations may be silently ignored by the operating system. Whether it works or not seems to depend on the drivers that are installed. For portable cancellation, consider using one of the following alternatives: * Disable asio's I/O completion port backend by defining BOOST_ASIO_DISABLE_IOCP. * Use the socket object's close() function to simultaneously cancel the outstanding operations and close the socket. |
|
Disables uses of the |
|
Determines the number of buckets in Boost.Asio's internal Some examples:
* Defining
* Defining |
A mailing list specifically for Boost.Asio may be found on SourceForge.net. Newsgroup access is provided via Gmane.
Users are encouraged to share examples, tips and FAQs on the Boost.Asio wiki, which is located at http://think-async.com/Asio/.