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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.