Boost.Asio C++ Network Programming


Boost.Asio C++ Network Programming
eBook: $21.99
Formats: PDF, PacktLib, ePub and Mobi formats
$18.69
save 15%!
Print + free eBook + free PacktLib access to the book: $56.98    Print cover: $34.99
$34.99
save 39%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Reviews
Support
Sample Chapters
  • 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

Book Details

Language : English
Paperback : 156 pages [ 235mm x 191mm ]
Release Date : February 2013
ISBN : 1782163263
ISBN 13 : 9781782163268
Author(s) : John Torjo
Topics and Technologies : All Books, Application Development, Open Source

Table of Contents

Preface
Chapter 1: Getting Started with Boost.Asio
Chapter 2: Boost.Asio Fundamentals
Chapter 3: Echo Server/Clients
Chapter 4: Client and Server
Chapter 5: Synchronous Versus Asynchronous
Chapter 6: Boost.Asio – Other Features
Chapter 7: Boost.Asio – Advanced Topics
Index
  • Chapter 1: Getting Started with Boost.Asio
    • What is Boost.Asio?
      • History
      • Dependencies
      • Building Boost.Asio
      • Important macros
    • Synchronous versus asynchronous
    • Exceptions versus error codes
    • Threading in Boost.Asio
    • Not just networking
    • Timers
    • The io_service class
    • Summary
    • Chapter 2: Boost.Asio Fundamentals
      • The Network API
        • Boost.Asio namespaces
        • IP addresses
        • Endpoints
        • Sockets
          • Synchronous error codes
          • Socket member functions
          • Other considerations
        • The read/write/connect free functions
          • The connect functions
          • The read/write functions
      • Asynchronous programming
        • The need for going asynchronous
        • Asynchronous run(), run_one(), poll(), poll_one()
          • Running forever
          • The run_one(), poll(), poll_one() functions
        • Asynchronous work
        • Asynchronous post() versus dispatch() versus wrap()
      • Staying alive
      • Summary
      • Chapter 3: Echo Server/Clients
        • TCP Echo server/clients
          • TCP synchronous client
          • TCP synchronous server
          • TCP asynchronous client
          • TCP asynchronous server
          • The code
        • UDP Echo server/clients
          • UDP synchronous Echo client
          • UDP synchronous Echo server
        • Summary
        • Chapter 4: Client and Server
          • The synchronous client/server
            • Synchronous client
            • Synchronous server
          • The asynchronous client/server
            • Asynchronous client
            • Asynchronous server
          • Summary
          • Chapter 5: Synchronous Versus Asynchronous
            • Mixing synchronous and asynchronous programming
            • Passing client to server messages and vice versa
            • Synchronous I/O in client applications
            • Synchronous I/O in server applications
              • Threading in a synchronous server
            • Asynchronous I/O in client applications
            • Asynchronous I/O in server applications
              • Threading in an asynchronous server
            • Asynchronous operations
            • Implementing proxies
            • Summary
              • Chapter 7: Boost.Asio – Advanced Topics
                • Asio versus Boost.Asio
                • Debugging
                  • Handler tracking information
                  • An example
                  • Handler tracking to file
                • SSL
                • Boost.Asio Windows features
                  • Stream Handles
                  • Random access Handles
                  • Object Handles
                • Boost.Asio POSIX features
                  • Local sockets
                  • Connecting local sockets
                  • POSIX file descriptors
                  • Fork
                • Summary

                John Torjo

                John Torjo is a renown C++ expert. He has been programming for over 15 years, most of which were spent doing C++. Sometimes, he also codes C# or Java. He’s also enjoyed writing articles about programming in C++ Users Journal (currently, Dr. Dobbs) and other magazines. In his spare time, he likes playing poker and driving fast cars. One of his freelance projects lets him combine two of his passions, programming and poker. You can reach him at john.code@torjo.com.

                Code Downloads

                Download the code and support files for this book.


                Submit Errata

                Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                Errata

                - 2 submitted: last submission 01 Aug 2013

                Errata type: Code | Page number: 7

                We now use b2 instead of bjam to compile Boost (at least on Windows)

                Errata type: Code | Page number: 8

                In the code snippet, line using boost::asio; should be using namespace boost::asio.

                Errata type: Code | Page number: 9

                The header files to be included for all samples are:

                #include <boost/thread.hpp>
                #include <boost/asio.hpp>

                Errata type: Code | Page number: 15

                The very first line at page 15 says:

                sock.async_read_some (buffer(data, 512));

                It should be:

                sock.async_read_some (buffer(data, 512), read_handler);

                Sorry, there are currently no downloads available for this title.

                Frequently bought together

                Boost.Asio C++ Network Programming +    Mastering Object-oriented Python =
                50% Off
                the second eBook
                Price for both: €25.50

                Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                What you will learn from this book

                • How to easily reference Boost.Asio programming
                • Synchronous versus asynchronous using Boost.Asio
                • How threading affects programming using Boost.Asio
                • Create your own echo client and server
                • More examples of client/server applications, both synchronous and asynchronous
                • Implement your own asynchronous operations
                • Co-routines: asynchronous operations with a synchronous feel
                • Use Boost.Asio for SSL Networking
                • Debug Boost.Asio
                • Use Boost.Asio for more than just networking

                 

                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.

                Approach

                What you want is an easy level of abstraction, which is just what this book provides in conjunction with Boost.Asio. Switching to Boost.Asio is just a few extra #include directives away, with the help of this practical and engaging guide.

                Who this book is for

                This book is great for developers that need to do network programming, who don’t want to delve into the complicated issues of a raw networking API. You should be familiar with core Boost concepts, such as smart pointers and shared_from_this, resource classes (noncopyable), functors and boost::bind, boost mutexes, and the boost date/time library. Readers should also be familiar with “blocking” versus “non-blocking” operations.

                Code Download and Errata
                Packt Anytime, Anywhere
                Register Books
                Print Upgrades
                eBook Downloads
                Video Support
                Contact Us
                Awards Voting Nominations Previous Winners
                Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                Resources
                Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software