You are previewing Boost.Asio C++ Network Programming.
O'Reilly logo
Boost.Asio C++ Network Programming

Book Description

Enhance your skills with practical examples for C++ network programming

  • Augment your C++ network programming using Boost.Asio

  • Discover how Boost.Asio handles synchronous and asynchronous programming models

  • Practical examples of client/server applications

  • Learn how to deal with threading when writing network applications

  • Harness the power of Boost with plenty of examples that you can build upon

In Detail

Network programming is not new and it’s no secret that it’s not an easy task. Boost.Asio provides an excellent level of abstraction, making sure that with a minimal amount of coding you can create beautiful client/server applications, and have fun in the process!

"Boost.Asio C++ Network Programming" shows how to build client/server applications using a library that is part of the popular peer-reviewed Boost C++ Libraries. It analyzes whether you should go synchronous or asynchronous and the role that threading plays, whilst providing examples you can run and extend for yourself.

After covering the fundamentals of Boost.Asio you’ll discover how you can build synchronous and asynchronous clients and servers. You will also see how you can have your own asynchronous functions play nice with Boost.Asio. As a bonus, we will introduce co-routines, which make asynchronous programming a piece of cake. Nowadays, network programming is a must, no matter what type of programmer you are. "Boost.Asio C++ Network Programming" shows just how simple networking can be, if you’re using the right tools.

Table of Contents

  1. Boost.Asio C++ Network Programming
    1. Table of Contents
    2. Boost.Asio C++ Network Programming
    3. Credits
    4. About the Author
    5. About the Reviewers
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Getting Started with Boost.Asio
      1. What is Boost.Asio?
        1. History
        2. Dependencies
        3. Building Boost.Asio
        4. Important macros
      2. Synchronous versus asynchronous
      3. Exceptions versus error codes
      4. Threading in Boost.Asio
      5. Not just networking
      6. Timers
      7. The io_service class
      8. Summary
    9. 2. Boost.Asio Fundamentals
      1. The Network API
        1. Boost.Asio namespaces
        2. IP addresses
        3. Endpoints
        4. Sockets
          1. Synchronous error codes
          2. Socket member functions
            1. Connecting-related functions
            2. Read/write functions
            3. Socket control
            4. TCP versus UDP versus ICMP
            5. Miscellaneous functions
          3. Other considerations
            1. Socket buffers
            2. The buffer function wrapper
        5. The read/write/connect free functions
          1. The connect functions
          2. The read/write functions
            1. The read_until/async_read_until functions
            2. The *_at functions
      2. Asynchronous programming
        1. The need for going asynchronous
        2. Asynchronous run(), run_one(), poll(), poll_one()
          1. Running forever
          2. The run_one(), poll(), poll_one() functions
        3. Asynchronous work
        4. Asynchronous post() versus dispatch() versus wrap()
      3. Staying alive
      4. Summary
    10. 3. Echo Server/Clients
      1. TCP Echo server/clients
        1. TCP synchronous client
        2. TCP synchronous server
        3. TCP asynchronous client
        4. TCP asynchronous server
        5. The code
      2. UDP Echo server/clients
        1. UDP synchronous Echo client
        2. UDP synchronous Echo server
      3. Summary
    11. 4. Client and Server
      1. The synchronous client/server
        1. Synchronous client
        2. Synchronous server
      2. The asynchronous client/server
        1. Asynchronous client
        2. Asynchronous server
      3. Summary
    12. 5. Synchronous Versus Asynchronous
      1. Mixing synchronous and asynchronous programming
      2. Passing client to server messages and vice versa
      3. Synchronous I/O in client applications
      4. Synchronous I/O in server applications
        1. Threading in a synchronous server
      5. Asynchronous I/O in client applications
      6. Asynchronous I/O in server applications
        1. Threading in an asynchronous server
      7. Asynchronous operations
      8. Implementing proxies
      9. Summary
    13. 6. Boost.Asio – Other Features
      1. std streams and std buffer I/O
        1. Boost.Asio and the STL streams
        2. The streambuf class
        3. The free functions that deal with streambuf objects
      2. Co-routines
      3. Summary
    14. 7. Boost.Asio – Advanced Topics
      1. Asio versus Boost.Asio
      2. Debugging
        1. Handler tracking information
        2. An example
        3. Handler tracking to file
      3. SSL
      4. Boost.Asio Windows features
        1. Stream Handles
        2. Random access Handles
        3. Object Handles
      5. Boost.Asio POSIX features
        1. Local sockets
        2. Connecting local sockets
        3. POSIX file descriptors
        4. Fork
      6. Summary
    15. Index