没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Network programming has been around for a very long time, and it's definitely not a task for the faint-hearted. Boost.Asio provides an excellent abstraction over it, making sure that with a minimal amount of coding, you can create beautiful client-server applications and have tons of fun doing it. And it throws some extra non-networking features, just as a bonus! Code that uses Boost.Asio is compact, easy to read, and if you follow what I describe in the book, it is bug-free.
资源推荐
资源详情
资源评论
Boost.Asio C++ Network Programming
Copyright © 2013 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
Production Reference: 1120213
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78216-326-8
www.packtpub.com
Cover Image by J.Blaminsky (milak6@wp.pl)
Table of Contents
Preface 1
Chapter 1: Getting Started with Boost.Asio 5
What is Boost.Asio? 5
History 6
Dependencies 7
Building Boost.Asio 7
Important macros 8
Synchronous versus asynchronous 8
Exceptions versus error codes 11
Threading in Boost.Asio 12
Not just networking 13
Timers 14
The io_service class 15
Summary 19
Chapter 2: Boost.Asio Fundamentals 21
The Network API 21
Boost.Asio namespaces 21
IP addresses 22
Endpoints 22
Sockets 23
Synchronous error codes 24
Socket member functions 24
Other considerations 31
The read/write/connect free functions 35
The connect functions 35
The read/write functions 36
Table of Contents
[ ii ]
Asynchronous programming 40
The need for going asynchronous 40
Asynchronous run(), run_one(), poll(), poll_one() 44
Running forever 44
The run_one(), poll(), poll_one() functions 45
Asynchronous work 47
Asynchronous post() versus dispatch() versus wrap() 50
Staying alive 52
Summary 55
Chapter 3: Echo Server/Clients 57
TCP Echo server/clients 58
TCP synchronous client 59
TCP synchronous server 60
TCP asynchronous client 61
TCP asynchronous server 64
The code 66
UDP Echo server/clients 66
UDP synchronous Echo client 67
UDP synchronous Echo server 68
Summary 68
Chapter 4: Client and Server 69
The synchronous client/server 70
Synchronous client 70
Synchronous server 73
The asynchronous client/server 77
Asynchronous client 78
Asynchronous server 82
Summary 86
Chapter 5: Synchronous Versus Asynchronous 87
Mixing synchronous and asynchronous programming 87
Passing client to server messages and vice versa 88
Synchronous I/O in client applications 89
Synchronous I/O in server applications 92
Threading in a synchronous server 94
Asynchronous I/O in client applications 96
Asynchronous I/O in server applications 98
Threading in an asynchronous server 101
Asynchronous operations 104
Implementing proxies 108
Summary 111
剩余149页未读,继续阅读
资源评论
nn123456789
- 粉丝: 14
- 资源: 128
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功