logo资料库

Boost.Asio C++ Network Programming 2nd edition.pdf

第1页 / 共244页
第2页 / 共244页
第3页 / 共244页
第4页 / 共244页
第5页 / 共244页
第6页 / 共244页
第7页 / 共244页
第8页 / 共244页
资料共244页,剩余部分请下载后查看
Boost.Asio C++ Network Programming Second Edition
Credits
About the Authors
Acknowledgements
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Simplifying Your Network Programming in C++
Setting up the MinGW compiler and Text Editor
Installing MinGW-w64
Setting up the Path environment
Choosing and installing the Text Editor
Using the GCC C++ compiler
Compiling a C++ program
Compiling multiple source files
Compiling and linking a program separately
Detecting a warning in the C++ program
Knowing other important options in the GCC C++ compiler
Troubleshooting in the GCC C++ compiler
Help for command-line options
Version numbers
The verbose compilation
Summary
2. Understanding the Networking Concepts
An introduction to networking systems
The OSI reference model
The Physical layer
The Data Link layer
The Network layer
The Transport layer
The Session layer
The Presentation layer
The Application layer
The TCP/IP reference model
Understanding TCP and UDP
Transmission Control Protocol
User Datagram Protocol
Understanding ports
Exploring the Internet Protocol
Internet Protocol Version 4 – IPv4
Internet Protocol Version 6 – IPv6
Using TCP/IP tools for troubleshooting
The ipconfig command
Displaying the full configuration information
Displaying DNS
Flushing DNS
Renewing the IP address
Releasing the IP address
The ping command
The tracert command
The pathping command
The netstat command
The telnet command
Summary
3. Introducing the Boost C++ Libraries
Introducing the C++ standard template library
Introducing the Boost C++ libraries
Advantages of Boost libraries
Preparing Boost libraries for the MinGW compiler
Downloading Boost libraries
Deploying Boost libraries
Using Boost libraries
Building Boost libraries
Summary
4. Getting Started with Boost.Asio
Getting closer to the Boost.Asio library
Examining the I/O service in the Boost.Asio library
Using and blocking the run() function
Using the non-blocking poll() function
Removing the work object
Dealing with many threads
Understanding the Boost.Bind library
Wrapping a function invocation
Working with the Boost.Bind library
Synchronizing data access with the Boost.Mutex library
Giving some work to the I/O service
Using the post() function
Using the dispatch() function
Summary
5. Delving into the Boost.Asio Library
Serializing the I/O service work
Using the strand function
Wrapping a handler through the strand object
Handling exceptions and errors
Handling an exception
Handling an error
Timing the work execution using the timer class
An expiring timer
Using the timer along with the boost::bind function
Using the timer along with the boost::strand function
Summary
6. Creating a Client-server Application
Establishing a connection
A synchronous client
An asynchronous client
An asynchronous server
Reading and writing to the socket
The Send() and OnSend() functions
The Recv() and OnRecv() functions
Wrapping the network code
Developing a client and server program
Creating a simple echo server
Creating a simple client program
Summary
7. Debugging the Code and Solving the Error
Choosing a debugging tool
Installing a debugging tool
Preparing a file for debugging
Running the program under GDB
Starting the debugging process
The continuing and stepping debugging process
Printing the source code
Setting and deleting the breakpoint
Printing a variable value
Modifying a variable value
Calling the command prompt
Solving the error
What's next?
Summary
Index
Boost.Asio C++ Network Programming Second Edition
Table of Contents Boost.Asio C++ Network Programming Second Edition Credits About the Authors Acknowledgements About the Reviewers www.PacktPub.com Support files, eBooks, discount offers, and more Why subscribe? Free access for Packt account holders Preface What this book covers What you need for this book Who this book is for Conventions Reader feedback Customer support Downloading the example code Errata Piracy Questions 1. Simplifying Your Network Programming in C++ Setting up the MinGW compiler and Text Editor Installing MinGW-w64 Setting up the Path environment Choosing and installing the Text Editor Using the GCC C++ compiler Compiling a C++ program Compiling multiple source files Compiling and linking a program separately Detecting a warning in the C++ program Knowing other important options in the GCC C++ compiler Troubleshooting in the GCC C++ compiler Help for command-line options Version numbers The verbose compilation Summary 2. Understanding the Networking Concepts An introduction to networking systems The OSI reference model
The Physical layer The Data Link layer The Network layer The Transport layer The Session layer The Presentation layer The Application layer The TCP/IP reference model Understanding TCP and UDP Transmission Control Protocol User Datagram Protocol Understanding ports Exploring the Internet Protocol Internet Protocol Version 4 – IPv4 Internet Protocol Version 6 – IPv6 Using TCP/IP tools for troubleshooting The ipconfig command Displaying the full configuration information Displaying DNS Flushing DNS Renewing the IP address Releasing the IP address The ping command The tracert command The pathping command The netstat command The telnet command Summary 3. Introducing the Boost C++ Libraries Introducing the C++ standard template library Introducing the Boost C++ libraries Advantages of Boost libraries Preparing Boost libraries for the MinGW compiler Downloading Boost libraries Deploying Boost libraries Using Boost libraries Building Boost libraries Summary 4. Getting Started with Boost.Asio Getting closer to the Boost.Asio library Examining the I/O service in the Boost.Asio library Using and blocking the run() function Using the non-blocking poll() function
Removing the work object Dealing with many threads Understanding the Boost.Bind library Wrapping a function invocation Working with the Boost.Bind library Synchronizing data access with the Boost.Mutex library Giving some work to the I/O service Using the post() function Using the dispatch() function Summary 5. Delving into the Boost.Asio Library Serializing the I/O service work Using the strand function Wrapping a handler through the strand object Handling exceptions and errors Handling an exception Handling an error Timing the work execution using the timer class An expiring timer Using the timer along with the boost::bind function Using the timer along with the boost::strand function Summary 6. Creating a Client-server Application Establishing a connection A synchronous client An asynchronous client An asynchronous server Reading and writing to the socket The Send() and OnSend() functions The Recv() and OnRecv() functions Wrapping the network code Developing a client and server program Creating a simple echo server Creating a simple client program Summary 7. Debugging the Code and Solving the Error Choosing a debugging tool Installing a debugging tool Preparing a file for debugging Running the program under GDB Starting the debugging process The continuing and stepping debugging process Printing the source code
Setting and deleting the breakpoint Printing a variable value Modifying a variable value Calling the command prompt Solving the error What's next? Summary Index
Boost.Asio C++ Network Programming Second Edition
Boost.Asio C++ Network Programming Second Edition Copyright © 2015 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: February 2013 Second published: September 2015 Production reference: 1100915 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78528-307-9 www.packtpub.com
分享到:
收藏