Implementing an asynchronous TCP server

An asynchronous TCP server is a part of a distributed application that satisfies the following criteria:

  • Acts as a server in the client-server communication model
  • Communicates with client applications over TCP protocol
  • Uses the asynchronous I/O and control operations
  • May handle multiple clients simultaneously

A typical asynchronous TCP server works according to the following algorithm:

  1. Allocate an acceptor socket and bind it to a particular TCP port.
  2. Initiate the asynchronous accept operation.
  3. Spawn one or more threads of control and add them to the pool of threads that run the Boost.Asio event loop.
  4. When the asynchronous accept operation completes, initiate a new one to accept the next connection request.
  5. Initiate ...

Get Boost.Asio C++ Network Programming Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.