This book includes enough easy to read explanations of actual working code that you can within a few hours have a client/server socket connection up and working. Both the text and the code are well written and easy to follow. Advanced information about non-blocking I/O allowed me to quickly implement background socket reads without tying up a foreground process. The annoying occurrences of
Author(s): Michael J. Donahoo, Kenneth L. Calvert
Series: The Morgan Kaufmann Practical Guides Series
Edition: 2
Publisher: Morgan Kaufmann
Year: 2009
Language: English
Pages: 196
Tags: Библиотека;Компьютерная литература;Компьютерные сети;
Cover Page
......Page 1
Copyright......Page 2
Preface......Page 3
Networks, Packets, and Protocols......Page 8
Writing Down IP Addresses......Page 11
Port Numbers......Page 12
Special Addresses......Page 13
Clients and Servers......Page 14
What Is a Socket?......Page 15
IPv4 TCP Client......Page 18
IPv4 TCP Server......Page 24
Creating and Destroying Sockets......Page 29
Generic Addresses......Page 30
IPv6 Addresses......Page 31
Binary/String Address Conversion......Page 32
Getting a Socket's Associated Addresses......Page 33
Binding to an Address......Page 34
Handling Incoming Connections......Page 35
Using IPv6......Page 37
Mapping Names to Numbers......Page 41
Accessing the Name Service......Page 42
Details, Details......Page 46
Writing Address-Generic Code......Page 47
Generic TCP Client......Page 49
Generic TCP Server......Page 52
IPv4--IPv6 Interoperation......Page 55
Getting Names from Numbers......Page 56
4 Using UDP Sockets......Page 58
UDP Client......Page 59
UDP Server......Page 62
Sending and Receiving with UDP Sockets......Page 65
Connecting a UDP Socket......Page 66
5 Sending and Receiving Data......Page 68
Sizes of Integers......Page 69
Byte Ordering......Page 71
Signedness and Sign Extension......Page 72
Encoding Integers by Hand......Page 73
Wrapping TCP Sockets in Streams......Page 76
Structure Overlays: Alignment and Padding......Page 78
Strings and Text......Page 81
Bit-Diddling: Encoding Booleans......Page 83
Constructing, Framing, and Parsing Messages......Page 84
Framing......Page 91
Text-Based Message Encoding......Page 96
Binary Message Encoding......Page 99
Putting It All Together......Page 101
Wrapping Up......Page 102
Socket Options......Page 104
Signals......Page 105
Nonblocking I/O......Page 111
Nonblocking Sockets......Page 112
Asynchronous I/O......Page 113
Timeouts......Page 117
Multitasking......Page 121
Per-Client Processes......Page 122
Per-Client Thread......Page 128
Constrained Multitasking......Page 131
Multiplexing......Page 133
Multiple Recipients......Page 138
Broadcast......Page 139
Multicast......Page 142
Broadcast vs. Multicast......Page 147
7 Under the Hood......Page 148
Buffering and TCP......Page 150
Deadlock Danger......Page 153
Performance Implications......Page 154
Connecting......Page 155
Closing a TCP Connection......Page 159
Demultiplexing Demystified......Page 163
8 Socket Programming in C++......Page 166
PracticalSocket Library Overview......Page 167
Plus One Server......Page 169
Plus One Client......Page 171
Survey Service......Page 173
Survey Support Functions......Page 174
Survey Server......Page 177
Survey Client......Page 181
Survey Service, Mark 2......Page 183
Socket Address Support......Page 184
Socket iostream Interface......Page 185
Enhanced Survey Server......Page 186
Enhanced Survey Client......Page 191
Administrative Client......Page 192
Running Server and Clients......Page 193
References......Page 195