All Projects → mabrarov → Asio_samples

mabrarov / Asio_samples

Licence: other
Examples (code samples) describing the construction of active objects on the top of Boost.Asio. A code-based guide for client/server creation with usage of active object pattern by means of Boost C++ Libraries.

Projects that are alternatives of or similar to Asio samples

Boost Asio Study
Examples and toturials for C++ Boost Asio library.
Stars: ✭ 144 (-24.61%)
Mutual labels:  boost, network, asio
Cpp Bredis
Boost::ASIO low-level redis client (connector)
Stars: ✭ 117 (-38.74%)
Mutual labels:  boost, network, asio
SierraChartZorroPlugin
A Zorro broker API plugin for Sierra Chart, written in Win32 C++.
Stars: ✭ 22 (-88.48%)
Mutual labels:  asynchronous, boost, asio
Cxxhttp
Asynchronous, Header-only C++ HTTP-over-(TCP|UNIX Socket|STDIO) Library
Stars: ✭ 24 (-87.43%)
Mutual labels:  asynchronous, asio
asio-extensions
Additional functionality built on top of (Boost.)Asio
Stars: ✭ 16 (-91.62%)
Mutual labels:  boost, asio
Beast
HTTP and WebSocket built on Boost.Asio in C++11
Stars: ✭ 3,241 (+1596.86%)
Mutual labels:  boost, asio
texugo
🦡 Fast, flexible, multiplatform, lightweight and, dependency-free message gateway
Stars: ✭ 18 (-90.58%)
Mutual labels:  boost, asio
Vibe Core
Repository for the next generation of vibe.d's core package.
Stars: ✭ 56 (-70.68%)
Mutual labels:  asynchronous, network
Tk Listen
A library that allows to listen network sockets with proper resource limits and error handling
Stars: ✭ 27 (-85.86%)
Mutual labels:  asynchronous, network
Collie
An asynchronous event-driven network framework( port netty ) written in D.
Stars: ✭ 60 (-68.59%)
Mutual labels:  asynchronous, network
Qtnetworkng
QtNetwork Next Generation. A coroutine based network framework for Qt/C++, with more simpler API than boost::asio.
Stars: ✭ 125 (-34.55%)
Mutual labels:  network, asio
mtxclient
Client API library for Matrix, built on top of Boost.Asio
Stars: ✭ 21 (-89.01%)
Mutual labels:  boost, asio
boost beast websocket echo
A collection of Demo applications to try to help you understand how Asio and Beast work
Stars: ✭ 12 (-93.72%)
Mutual labels:  boost, asio
Message Io
Event-driven message library for building network applications easy and fast.
Stars: ✭ 321 (+68.06%)
Mutual labels:  asynchronous, network
asio-grpc
Asynchronous gRPC with Asio/unified executors
Stars: ✭ 100 (-47.64%)
Mutual labels:  asynchronous, asio
Luaasio
Simple transparent non-blocking TCP I/O for LuaJIT, Based on Boost.Asio and Lua coroutine.
Stars: ✭ 56 (-70.68%)
Mutual labels:  network, asio
Webcc
Lightweight C++ HTTP client and server library based on Asio for embedding purpose.
Stars: ✭ 167 (-12.57%)
Mutual labels:  boost, asio
boost-wintls
Native Windows TLS stream wrapper for use with boost::asio
Stars: ✭ 24 (-87.43%)
Mutual labels:  boost, asio
ufw
A minimalist framework for rapid server side applications prototyping in C++ with dependency injection support.
Stars: ✭ 19 (-90.05%)
Mutual labels:  boost, asio
Cpp Rotor
Event loop friendly C++ actor micro-framework
Stars: ✭ 111 (-41.88%)
Mutual labels:  boost, asio

Asio samples

Release License

Branch Linux Windows Coverage Coverity Scan
master Travis CI build status AppVeyor CI build status Code coverage status Coverity Scan status
develop Travis CI build status AppVeyor CI build status Code coverage status

Extended examples for Boost.Asio.

Building with Docker container

Refer to docker/builder/README.md for instruction on how to build Linux version with existing Docker images.

Build manual

Prerequisites

  • C++ toolchain (one of):

    • MinGW with MSYS make

      MinGW-W64 4.9+

    • Visual Studio (Visual C++)

      2008, 2010, 2012, 2013, 2015, 2017, 2019 are tested versions

    • GCC with make

      4.6+

    • Clang with make

      3.6+

  • CMake

    3.1+, consider using the latest version of CMake because it supports recent versions of libraries

  • Boost

    1.47+, the latest tested version is 1.74

  • Google Test

    Optional, copy of 1.7.0 version is shipped with this project and is used if no other instance is found

  • Qt

    Optional, 4.0+, both 4.x and 5.x are supported with default preference to 5.x

  • ICU

    Optional, required if static Qt 5.x is used, version should match Qt requirements / version which was used to build static Qt

Assumptions

  • %...% syntax is used for Windows Command Prompt and ${...} syntax is used for *nix shell
  • Windows Command Prompt with configured Windows SDK environment is used on Windows
  • Directory with generated project files and with built binaries is specified in asio_samples_build_dir environment variable
  • This repository is cloned into directory specified in asio_samples_home_dir environment variable
  • ICU is located at directory specified by icu_home_dir environment variable
  • Header files of Boost are located at directory specified by boost_headers_dir environment variable
  • Binary files of Boost are located at directory specified by boost_libs_dir environment variable
  • Qt 5.x is located at directory specified by qt5_home_dir environment variable
  • Qt 4.x is located at directory specified by qt4_home_dir environment variable
  • Google Test is located at directory specified by gtest_home_dir environment variable
  • build type is specified in build_type environment variable and is one of:
    • Debug
    • Release
    • RelWithDebInfo
    • MinSizeRel
  • cmake_generator environment variable is CMake generator
    • Visual Studio 14 2015 - Visual Studio 2015
    • Visual Studio 15 2017 - Visual Studio 2017
    • Visual Studio 16 2019 - Visual Studio 2019
    • Visual Studio 12 2013 - Visual Studio 2013
    • Visual Studio 10 2010 - Visual Studio 2010
    • Visual Studio 9 2008 - Visual Studio 2008
    • NMake Makefiles - NMake
    • MinGW Makefiles - MinGW makefiles
    • Unix Makefiles - *nix makefiles
  • cmake_platform environment variable is CMAKE_GENERATOR_PLATFORM
    • Win32 - x86 platform when using Visual Studio
    • x64 - amd64 (x64) platform when using Visual Studio

Building of CMake project is usually performed in 2 steps:

  1. Generation of project for build system
  2. Building generated project with build system

Generation of project for build system

Assuming current directory is asio_samples_build_dir.

Windows Command Prompt, Visual Studio CMake generator:

cmake ... -G "%cmake_generator%" -A "%cmake_platform%" "%asio_samples_home_dir%"

Windows Command Prompt, NMake / MinGW makefiles CMake generator

cmake ... -G "%cmake_generator%" "%asio_samples_home_dir%"

*nix shell

cmake ... -G "${cmake_generator}" "${asio_samples_home_dir}"

where ... are optional parameters which are described below.

Use MA_TESTS CMake variable to exclude tests from build (tests are included by default):

cmake -D MA_TESTS=OFF ...

CMake project uses CMake find modules, so most of parameters comes from these CMake modules:

  • FindBoost CMake module

    CMake variables which can be specified in command line to locate and configure Boost:

    • BOOST_INCLUDEDIR - Boost headers directory

      Windows Command Prompt:

      -D BOOST_INCLUDEDIR="%boost_headers_dir%"
      

      *nix shell

      -D BOOST_INCLUDEDIR="${boost_headers_dir}"
      
    • BOOST_LIBRARYDIR - Boost libraries directory

      Windows Command Prompt:

      -D BOOST_LIBRARYDIR="%boost_libs_dir%"
      

      *nix shell

      -D BOOST_LIBRARYDIR="${boost_libs_dir}"
      
    • Boost_USE_STATIC_LIBS - force usage of static Boost, possible values are ON (use static libraries) and OFF (linkage type depends on platform)

    • Boost_NO_SYSTEM_PATHS - do not search for Boost in default system locations

  • cmake-qt CMake module (refer to Qt cmake manual also)

    CMake variables which can be specified in command line to locate Qt 5.x:

    • Qt5Core_DIR

      Windows Command Prompt:

      -D Qt5Core_DIR="%qt5_home_dir%/lib/cmake/Qt5Core"
      

      *nix shell

      -D Qt5Core_DIR="${qt5_home_dir}/lib/cmake/Qt5Core"
      
    • Qt5Gui_DIR

      Windows Command Prompt:

      -D Qt5Gui_DIR="%qt5_home_dir%/lib/cmake/Qt5Gui"
      

      *nix shell

      -D Qt5Gui_DIR="${qt5_home_dir}/lib/cmake/Qt5Gui"
      
    • Qt5Widgets_DIR

      Windows Command Prompt:

      -D Qt5Widgets_DIR="%qt5_home_dir%/lib/cmake/Qt5Widgets"
      

      *nix shell

      -D Qt5Widgets_DIR="${qt5_home_dir}/lib/cmake/Qt5Widgets"
      

    CMake variables which can be specified in command line to locate Qt 4.x:

    • QT_QMAKE_EXECUTABLE - path to qmake executable

      Windows Command Prompt:

      -D QT_QMAKE_EXECUTABLE="%qt4_home_dir%/bin/qmake.exe"
      

      *nix shell

      -D QT_QMAKE_EXECUTABLE="${qt4_home_dir}/bin/qmake.exe"
      

    MA_QT CMake variable can be used to avoid usage of Qt and to skip examples using Qt. Possible values are:

    • ON (default) - search for (require) and use Qt
    • OFF - do not search for Qt and skip building the parts which use Qt
  • FindGTest CMake module

    CMake variables which can be specified in command line to locate Google Test:

    • GTEST_ROOT - Google Test home directory

      Windows Command Prompt:

      -D GTEST_ROOT="%gtest_home_dir%"
      

      *nix shell

      -D GTEST_ROOT="${gtest_home_dir}"
      

    Note that if Google Test was built with CMake and MS Visual Studio then you have to "install" it somehow - just copying results of build (add "d" postfix into the name of debug artifacts) into Google Test root directory (or into "lib" sub-directory) would be enough for FindGTest.

    There is a copy of Google Test shipped as part of CMake project (refer to 3rdparty/gtest directory). It will be used in case FindGTest fails to find Google Test (so GTEST_ROOT is optional). Note that -D gtest_force_shared_crt=ON command line parameter is required in case shared C/C++ runtime is planned to be used with Google Test on Windows.

  • FindICU CMake module

    Used only if static Qt 5.x is identified.

    CMake variables which can be specified in command line to locate ICU:

    • ICU_ROOT - ICU home directory

      Windows Command Prompt:

      -D ICU_ROOT="%icu_home_dir%"
      

      *nix shell

      -D ICU_ROOT="${icu_home_dir}"
      

To build with static C/C++ runtime:

  • Use CMAKE_USER_MAKE_RULES_OVERRIDE CMake variable pointing to cmake/static_c_runtime_overrides.cmake

    Windows Command Prompt:

    -D CMAKE_USER_MAKE_RULES_OVERRIDE="%asio_samples_home_dir%/cmake/static_c_runtime_overrides.cmake"
    

    *nix shell

    -D CMAKE_USER_MAKE_RULES_OVERRIDE="${asio_samples_home_dir}/cmake/static_c_runtime_overrides.cmake"
    
  • Use CMAKE_USER_MAKE_RULES_OVERRIDE_CXX CMake variable pointing to cmake/static_cxx_runtime_overrides.cmake

    Windows Command Prompt:

    -D CMAKE_USER_MAKE_RULES_OVERRIDE_CXX="%asio_samples_home_dir%/cmake/static_cxx_runtime_overrides.cmake"
    

    *nix shell

    -D CMAKE_USER_MAKE_RULES_OVERRIDE_CXX="${asio_samples_home_dir}/cmake/static_cxx_runtime_overrides.cmake"
    
  • Static build of Qt

  • ICU_ROOT CMake variable pointing to ICU home directory (static build, required for Qt).

Note that on Windows cmake-qt searches for some system libraries (OpenGL) therefore to work correctly CMake should be executed after Windows SDK environment was set up (even if Visual Studio generator is used).

The CMake project searches for Qt 5.x first and if Qt 5.x is not found then it searches for Qt 4.x. This can be changed with MA_QT_MAJOR_VERSION CMake variable which can be specified in command line.

Possible values are:

  • 4 - search for Qt 4.x only

    -D MA_QT_MAJOR_VERSION=4
    
  • 5 - search for Qt 5.x only

    -D MA_QT_MAJOR_VERSION=5
    

Example of generation of Visual Studio 2015 project with:

  • static C/C++ runtime
  • static Boost
  • static Qt 5.x
  • internal copy of Google Test
  • x64 build
set "cmake_generator=Visual Studio 14 2015"
set "cmake_platform=x64"
cmake ^
-D CMAKE_USER_MAKE_RULES_OVERRIDE="%asio_samples_home_dir%/cmake/static_c_runtime_overrides.cmake" ^
-D CMAKE_USER_MAKE_RULES_OVERRIDE_CXX="%asio_samples_home_dir%/cmake/static_cxx_runtime_overrides.cmake" ^
-D ICU_ROOT="%icu_home_dir%" ^
-D BOOST_INCLUDEDIR="%boost_headers_dir%" ^
-D BOOST_LIBRARYDIR="%boost_libs_dir%" ^
-D Boost_NO_SYSTEM_PATHS=ON ^
-D Boost_USE_STATIC_LIBS=ON ^
-D Qt5Core_DIR="%qt5_home_dir%/lib/cmake/Qt5Core" ^
-D Qt5Gui_DIR="%qt5_home_dir%/lib/cmake/Qt5Gui" ^
-D Qt5Widgets_DIR="%qt5_home_dir%/lib/cmake/Qt5Widgets" ^
-G "%cmake_generator%" ^
-A "%cmake_platform%" ^
"%asio_samples_home_dir%"

Example of generation of makefiles on *nix with:

  • shared C/C++ runtime
  • static Boost
  • shared Qt 5.x
cmake_generator="Unix Makefiles" && \
cmake \
-D Boost_USE_STATIC_LIBS=ON \
-D MA_QT_MAJOR_VERSION=5 \
-D CMAKE_BUILD_TYPE=${build_type} \
-G "${cmake_generator}" \
"${asio_samples_home_dir}"

Example of generation of Visual Studio 2015 project with:

  • shared C/C++ runtime
  • static Boost (which uses shared C/C++ runtime)
  • shared Qt 5.x
  • internal copy of Google Test
  • x64 build
set "cmake_generator=Visual Studio 14 2015"
set "cmake_platform=x64"
cmake ^
-D BOOST_INCLUDEDIR="%boost_headers_dir%" ^
-D BOOST_LIBRARYDIR="%boost_libs_dir%" ^
-D Boost_NO_SYSTEM_PATHS=ON ^
-D Boost_USE_STATIC_LIBS=ON ^
-D gtest_force_shared_crt=ON ^
-D Qt5Core_DIR="%qt5_home_dir%/lib/cmake/Qt5Core" ^
-D Qt5Gui_DIR="%qt5_home_dir%/lib/cmake/Qt5Gui" ^
-D Qt5Widgets_DIR="%qt5_home_dir%/lib/cmake/Qt5Widgets" ^
-G "%cmake_generator%" ^
-A "%cmake_platform%" ^
"%asio_samples_home_dir%"

Example of generation of Visual Studio 2013 project with:

  • static C/C++ runtime
  • static Boost
  • static Qt 5
  • external Google Test
  • x64 build
  • Intel C++ Compiler XE 2015
set "cmake_generator=Visual Studio 12 2013"
set "cmake_platform=x64"
cmake ^
-D CMAKE_USER_MAKE_RULES_OVERRIDE="%asio_samples_home_dir%/cmake/static_c_runtime_overrides.cmake" ^
-D CMAKE_USER_MAKE_RULES_OVERRIDE_CXX="%asio_samples_home_dir%/cmake/static_cxx_runtime_overrides.cmake" ^
-D ICU_ROOT="%icu_home_dir%" ^
-D BOOST_INCLUDEDIR="%boost_headers_dir%" ^
-D BOOST_LIBRARYDIR="%boost_libs_dir%" ^
-D Boost_NO_SYSTEM_PATHS=ON ^
-D Boost_USE_STATIC_LIBS=ON ^
-D Qt5Core_DIR="%qt5_home_dir%/lib/cmake/Qt5Core" ^
-D Qt5Gui_DIR="%qt5_home_dir%/lib/cmake/Qt5Gui" ^
-D Qt5Widgets_DIR="%qt5_home_dir%/lib/cmake/Qt5Widgets" ^
-D GTEST_ROOT="%gtest_home_dir%" ^
-D CMAKE_C_COMPILER=icl ^
-D CMAKE_CXX_COMPILER=icl ^
-T "Intel C++ Compiler XE 15.0" ^
-G "%cmake_generator%" ^
-A "%cmake_platform%" ^
"%asio_samples_home_dir%"

Example of generation of Visual Studio 2015 project with:

  • shared C/C++ runtime
  • shared Boost
  • shared Qt 5
  • x64 build
  • Intel C++ Compiler 2016
set "cmake_generator=Visual Studio 14 2015"
set "cmake_platform=x64"
cmake ^
-D BOOST_INCLUDEDIR="%boost_headers_dir%" ^
-D BOOST_LIBRARYDIR="%boost_libs_dir%" ^
-D Boost_NO_SYSTEM_PATHS=ON ^
-D Boost_USE_STATIC_LIBS=OFF ^
-D gtest_force_shared_crt=ON ^
-D Qt5Core_DIR="%qt5_home_dir%/lib/cmake/Qt5Core" ^
-D Qt5Gui_DIR="%qt5_home_dir%/lib/cmake/Qt5Gui" ^
-D Qt5Widgets_DIR="%qt5_home_dir%/lib/cmake/Qt5Widgets" ^
-D CMAKE_C_COMPILER=icl ^
-D CMAKE_CXX_COMPILER=icl ^
-T "Intel C++ Compiler 16.0" ^
-G "%cmake_generator%" ^
-A "%cmake_platform%" ^
"%asio_samples_home_dir%"

Example of generation of Visual Studio 2010 project with:

  • shared C/C++ runtime
  • static Boost (which uses shared C/C++ runtime)
  • shared Qt 4.x
  • x86 build
set "cmake_generator=Visual Studio 10 2010"
set "cmake_platform=Win32"
cmake ^
-D BOOST_INCLUDEDIR="%boost_headers_dir%" ^
-D BOOST_LIBRARYDIR="%boost_libs_dir%" ^
-D Boost_NO_SYSTEM_PATHS=ON ^
-D Boost_USE_STATIC_LIBS=ON ^
-D gtest_force_shared_crt=ON ^
-D QT_QMAKE_EXECUTABLE="%qt4_home_dir%/bin/qmake.exe" ^
-G "%cmake_generator%" ^
-A "%cmake_platform%" ^
"%asio_samples_home_dir%"

Example of generation of Visual Studio 2008 project with:

  • static C/C++ runtime
  • static Boost
  • static Qt 4.x
  • x86 build
set "cmake_generator=Visual Studio 9 2008"
set "cmake_platform=Win32"
cmake ^
-D CMAKE_USER_MAKE_RULES_OVERRIDE="%asio_samples_home_dir%/cmake/static_c_runtime_overrides.cmake" ^
-D CMAKE_USER_MAKE_RULES_OVERRIDE_CXX="%asio_samples_home_dir%/cmake/static_cxx_runtime_overrides.cmake" ^
-D BOOST_INCLUDEDIR="%boost_headers_dir%" ^
-D BOOST_LIBRARYDIR="%boost_libs_dir%" ^
-D Boost_NO_SYSTEM_PATHS=ON ^
-D Boost_USE_STATIC_LIBS=ON ^
-D QT_QMAKE_EXECUTABLE="%qt4_home_dir%/bin/qmake.exe" ^
-G "%cmake_generator%" ^
-A "%cmake_platform%" ^
"%asio_samples_home_dir%"

Building generated project with build system

Building of generated project can be done using chosen (during generation of project) build system or using CMake.

CMake command to build generated project (Windows Command Prompt):

cmake --build "%asio_samples_build_dir%" --config "%build_type%"

CMake command to build generated project (*nix shell):

cmake --build "${asio_samples_build_dir}" --config "${build_type}"

Running tests

Assuming current directory is asio_samples_build_dir.

CTest command to run built tests (Windows Command Prompt):

ctest --build-config "%build_type%"

CTest command to run built tests (*nix shell):

ctest --build-config "${build_type}"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].