没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
Addison Wesley : UNIX
Network Programming
Volume 1, Third Edition: The
Sockets Networking API
Addison Wesley : UNIX Network Programming Volume 1, Third Edition: The Sockets Networking API
1
目录
Main Page .......................................................................................................................................... 12
Table of content ................................................................................................................................. 13
Copyright ........................................................................................................................................... 23
Addison-Wesley Professional Computing Series ............................................................................... 25
Foreword ........................................................................................................................................... 27
Preface ............................................................................................................................................... 28
Introduction ............................................................................................................................... 28
Changes from the Second Edition.............................................................................................. 29
Using This Book.......................................................................................................................... 30
Source Code and Errata Availability ........................................................................................... 30
Acknowledgments ..................................................................................................................... 31
Part 1: Introduction and TCP/IP ......................................................................................................... 32
Chapter 1. Introduction ............................................................................................................. 32
1.1 Introduction ................................................................................................................. 33
1.2 A Simple Daytime Client .............................................................................................. 36
1.3 Protocol Independence................................................................................................ 41
1.4 Error Handling: Wrapper Functions ............................................................................. 42
1.5 A Simple Daytime Server ............................................................................................. 45
1.6 Roadmap to Client/Server Examples in the Text .......................................................... 49
1.7 OSI Model .................................................................................................................... 51
1.8 BSD Networking History............................................................................................... 52
1.9 Test Networks and Hosts ............................................................................................. 54
1.10 Unix Standards ........................................................................................................... 60
1.11 64-Bit Architectures ................................................................................................... 63
1.12 Summary .................................................................................................................... 64
Exercises ............................................................................................................................ 65
Chapter 2. The Transport Layer: TCP, UDP, and SCTP ................................................................. 66
2.1 Introduction ................................................................................................................. 66
2.2 The Big Picture ............................................................................................................. 67
2.3 User Datagram Protocol (UDP) .................................................................................... 70
2.4 Transmission Control Protocol (TCP) ............................................................................ 71
2.5 Stream Control Transmission Protocol (SCTP) ............................................................. 72
2.6 TCP Connection Establishment and Termination ......................................................... 73
2.7 TIME_WAIT State ......................................................................................................... 80
2.8 SCTP Association Establishment and Termination ....................................................... 82
2.9 Port Numbers ............................................................................................................... 87
2.10 TCP Port Numbers and Concurrent Servers ............................................................... 90
2.11 Buffer Sizes and Limitations ....................................................................................... 92
2.12 Standard Internet Services ........................................................................................ 99
2.13 Protocol Usage by Common Internet Applications .................................................. 100
Addison Wesley : UNIX Network Programming Volume 1, Third Edition: The Sockets Networking API
2
2.14 Summary .................................................................................................................. 101
Exercises .......................................................................................................................... 102
Part 2: Elementary Sockets .............................................................................................................. 103
Chapter 3. Sockets Introduction .............................................................................................. 103
3.1 Introduction ............................................................................................................... 104
3.2 Socket Address Structures ......................................................................................... 104
3.3 Value-Result Arguments ............................................................................................ 112
3.4 Byte Ordering Functions ............................................................................................ 115
3.5 Byte Manipulation Functions ..................................................................................... 119
3.6 'inet_aton', 'inet_addr', and 'inet_ntoa' Functions ................................................... 121
3.7 'inet_pton' and 'inet_ntop' Functions ....................................................................... 122
3.8 'sock_ntop' and Related Functions ............................................................................ 125
3.9 'readn', 'writen', and 'readline' Functions ................................................................. 128
3.10 Summary .................................................................................................................. 134
Exercises .......................................................................................................................... 134
Chapter 4. Elementary TCP Sockets ......................................................................................... 135
4.1 Introduction ............................................................................................................... 136
4.2 'socket' Function ........................................................................................................ 137
4.3 'connect' Function ..................................................................................................... 140
4.4 'bind' Function ........................................................................................................... 143
4.5 'listen' Function .......................................................................................................... 146
4.6 'accept' Function ........................................................................................................ 152
4.7 'fork' and 'exec' Functions.......................................................................................... 155
4.8 Concurrent Servers .................................................................................................... 158
4.9 'close' Function .......................................................................................................... 161
4.10 'getsockname' and 'getpeername' Functions .......................................................... 162
4.11 Summary .................................................................................................................. 165
Exercises .......................................................................................................................... 165
Chapter 5. TCP Client/Server Example ..................................................................................... 166
5.1 Introduction ............................................................................................................... 167
5.2 TCP Echo Server: 'main' Function .............................................................................. 168
5.3 TCP Echo Server: 'str_echo' Function ........................................................................ 169
5.4 TCP Echo Client: 'main' Function ............................................................................... 170
5.5 TCP Echo Client: 'str_cli' Function .............................................................................. 171
5.6 Normal Startup .......................................................................................................... 172
5.7 Normal Termination ................................................................................................... 175
5.8 POSIX Signal Handling ................................................................................................ 177
5.9 Handling 'SIGCHLD' Signals ........................................................................................ 181
5.10 'wait' and 'waitpid' Functions .................................................................................. 184
5.11 Connection Abort before 'accept' Returns .............................................................. 189
5.12 Termination of Server Process ................................................................................. 191
5.13 'SIGPIPE' Signal......................................................................................................... 193
5.14 Crashing of Server Host ........................................................................................... 195
5.15 Crashing and Rebooting of Server Host ................................................................... 196
Addison Wesley : UNIX Network Programming Volume 1, Third Edition: The Sockets Networking API
3
5.16 Shutdown of Server Host ......................................................................................... 196
5.17 Summary of TCP Example ........................................................................................ 197
5.18 Data Format ............................................................................................................. 198
5.19 Summary .................................................................................................................. 202
Exercises .......................................................................................................................... 203
Chapter 6. I/O Multiplexing: The 'select' and 'poll' Functions ................................................. 204
6.1 Introduction ............................................................................................................... 205
6.2 I/O Models ................................................................................................................. 206
6.3 'select' Function ......................................................................................................... 212
6.4 'str_cli' Function (Revisited) ....................................................................................... 219
6.5 Batch Input and Buffering .......................................................................................... 222
6.6 'shutdown' Function .................................................................................................. 225
6.7 'str_cli' Function (Revisited Again) ............................................................................. 227
6.8 TCP Echo Server (Revisited) ....................................................................................... 229
6.9 'pselect' Function ....................................................................................................... 235
6.10 'poll' Function .......................................................................................................... 237
6.11 TCP Echo Server (Revisited Again) ........................................................................... 240
6.12 Summary .................................................................................................................. 243
Exercises .......................................................................................................................... 244
Chapter 7. Socket Options ....................................................................................................... 244
7.1 Introduction ............................................................................................................... 245
7.2 'getsockopt' and 'setsockopt' Functions .................................................................... 246
7.3 Checking if an Option Is Supported and Obtaining the Default ................................. 248
7.4 Socket States .............................................................................................................. 253
7.5 Generic Socket Options ............................................................................................. 254
7.6 IPv4 Socket Options ................................................................................................... 270
7.7 ICMPv6 Socket Option ............................................................................................... 272
7.8 IPv6 Socket Options ................................................................................................... 272
7.9 TCP Socket Options .................................................................................................... 275
7.10 SCTP Socket Options ................................................................................................ 278
7.11 'fcntl' Function ......................................................................................................... 291
7.12 Summary .................................................................................................................. 294
Exercises .......................................................................................................................... 294
Chapter 8. Elementary UDP Sockets ........................................................................................ 296
8.1 Introduction ............................................................................................................... 297
8.2 'recvfrom' and 'sendto' Functions ............................................................................. 298
8.3 UDP Echo Server: 'main' Function ............................................................................. 300
8.4 UDP Echo Server: 'dg_echo' Function ........................................................................ 301
8.5 UDP Echo Client: 'main' Function .............................................................................. 303
8.6 UDP Echo Client: 'dg_cli' Function ............................................................................. 304
8.7 Lost Datagrams .......................................................................................................... 305
8.8 Verifying Received Response ..................................................................................... 306
8.9 Server Not Running .................................................................................................... 309
8.10 Summary of UDP Example ....................................................................................... 311
Addison Wesley : UNIX Network Programming Volume 1, Third Edition: The Sockets Networking API
4
8.11 'connect' Function with UDP ................................................................................... 313
8.12 'dg_cli' Function (Revisited) ..................................................................................... 317
8.13 Lack of Flow Control with UDP ................................................................................ 318
8.14 Determining Outgoing Interface with UDP .............................................................. 323
8.15 TCP and UDP Echo Server Using 'select' .................................................................. 324
8.16 Summary .................................................................................................................. 327
Exercises .......................................................................................................................... 328
Chapter 9. Elementary SCTP Sockets ....................................................................................... 329
9.1 Introduction ............................................................................................................... 330
9.2 Interface Models ........................................................................................................ 331
9.3 'sctp_bindx' Function ................................................................................................. 336
9.4 'sctp_connectx' Function ........................................................................................... 337
9.5 'sctp_getpaddrs' Function ......................................................................................... 338
9.6 'sctp_freepaddrs' Function ........................................................................................ 338
9.7 'sctp_getladdrs' Function ........................................................................................... 338
9.8 'sctp_freeladdrs' Function ......................................................................................... 339
9.9 'sctp_sendmsg' Function ........................................................................................... 339
9.10 'sctp_recvmsg' Function .......................................................................................... 340
9.11 'sctp_opt_info' Function .......................................................................................... 341
9.12 'sctp_peeloff' Function ............................................................................................ 341
9.13 'shutdown' Function ................................................................................................ 342
9.14 Notifications............................................................................................................. 343
9.15 Summary .................................................................................................................. 351
Exercises .......................................................................................................................... 351
Chapter 10. SCTP Client/Server Example ................................................................................. 351
10.1 Introduction ............................................................................................................. 352
10.2 SCTP One-to-Many-Style Streaming Echo Server: 'main' Function ......................... 353
10.3 SCTP One-to-Many-Style Streaming Echo Client: 'main' Function .......................... 356
10.4 SCTP Streaming Echo Client: 'str_cli' Function ........................................................ 357
10.5 Exploring Head-of-Line Blocking .............................................................................. 360
10.6 Controlling the Number of Streams ......................................................................... 367
10.7 Controlling Termination ........................................................................................... 368
10.8 Summary .................................................................................................................. 370
Exercises .......................................................................................................................... 370
Chapter 11. Name and Address Conversions .......................................................................... 371
11.1 Introduction ............................................................................................................. 372
11.2 Domain Name System (DNS) ................................................................................... 373
11.3 'gethostbyname' Function ....................................................................................... 377
11.4 'gethostbyaddr' Function ......................................................................................... 381
11.5 'getservbyname' and 'getservbyport' Functions...................................................... 382
11.6 'getaddrinfo' Function.............................................................................................. 387
11.7 'gai_strerror' Function ............................................................................................. 394
11.8 'freeaddrinfo' Function ............................................................................................ 395
11.9 'getaddrinfo' Function: IPv6 ..................................................................................... 395
剩余1133页未读,继续阅读
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0
最新资源