CONTENTS
Foreword = xvii
Preface = xix
Chapter 1 Introduction And Overview = 1
1.1 Use Of TCP/IP = 1
1.2 Designing Applications For A Distributed Environment = 2
1.3 Standard And Nonstandard Application Protocols = 2
1.4 An Example Of Standard Application Protocol Use = 2
1.5 An Example Connection = 3
1.6 Using TELNET To Access An Alternative Service = 4
1.7 Application Protocols And Software Flexibility = 5
1.8 Viewing Services From the Provider's Perspective = 6
1.9 The Remainder Of This Text = 7
1.10 Summary = 7
Chapter 2 The Client-Server Model And Software Design = 9
2.1 Introduction = 9
2.2 Motivation = 10
2.3 Terminology And Concepts = 10
2.4 Summary = 18
Chapter 3 Concurrent Processing In Client-Server Software = 21
3.1 Introduction = 21
3.2 Concurrency In Networks = 21
3.3 Concurrency In Servers = 23
3.4 Terminology And Concepts = 24
3.5 An Example Of Concurrent Process Creation = 26
3.6 Executing New Code = 31
3.7 Context Switching And Protocol Software Design = 31
3.8 Concurrency And Asynchronous I/O = 32
3.9 Summary = 32
Chapter 4 Program Interface To Protocols = 35
4.1 Introduction = 35
4.2 Loosely Specified Protocol Software Interface = 35
4.3 Interface Functionality = 36
4.4 Conceptual Interface Specification = 37
4.5 System Calls = 37
4.6 Two Basic Approaches To Network Communication = 38
4.7 The Basic I/O Functions Available In UNIX = 39
4.8 Using UNIX I/O With TCP/IP = 40
4.9 Summary = 40
Chapter 5 The Transport Layer Interface (TLI) = 43
5.1 Introduction = 43
5.2 Background = 43
5.3 Specifying A Protocol Interface = 44
5.4 The Basic TLI Abstractions = 45
5.5 Practical Limitations On Portability = 46
5.6 Programs, Linking, And Shared Libraries = 46
5.7 TLI Communication Descriptors = 47
5.8 Using A File Path To Specify Protocol Software = 48
5.9 Specifying An Endpoint Address = 48
5.10 An Address Structure For TCP/IP = 49
5.11 Principle Function Calls Used With TLI = 50
5.12 Summary Of TLI Functions Used With TCP/IP = 55
5.13 Utility Routines For Integer Conversion = 56
5.14 Using TLI Functions In A Program = 56
5.15 Predefined Structures And Symbolic Constants = 57
5.16 Summary = 58
Chapter 6 Algorithms And Issues In Client Software Design = 61
6.1 Introduction = 61
6.2 Learning Algorithms Instead Of Details = 61
6.3 Client Architecture = 62
6.4 Identifying The Location Of A Server = 62
6.5 Parsing An Address Argument = 64
6.6 Looking Up A Domain Name = 65
6.7 Looking Up A Well-Known Port By Name = 66
6.8 Port Numbers And Network Byte Order = 66
6.9 The TCP Client Algorithm = 67
6.10 Allocating A Descriptor = 67
6.11 Choosing A Local Protocol Port Number = 68
6.12 A Fundamental Problem In Choosing A Local IP Address = 68
6.13 Connecting To A Server With TCP = 69
6.14 Communicating With The Server Using TCP = 69
6.15 Reading A Response From A TCP Connection = 70
6.16 Terminating A TCP Connection = 71
6.17 Programming A UDP Client = 72
6.18 Communicating With A Server Using UDP = 73
6.19 Deallocating A Descriptor That Uses UDP = 73
6.20 A Warning About UDP Unreliability = 73
6.21 Summary = 74
Chapter 7 Example Client Software = 77
7.1 Introduction = 77
7.2 The Importance Of Small Examples = 77
7.3 Hiding Details = 78
7.4 An Example Procedure Library For Client Programs = 78
7.5 Implementation Of ClientTCP = 79
7.6 Implementation Of ClientUDP = 81
7.7 A Procedure That Forms Connections = 82
7.8 Using The Example Library = 84
7.9 The DAYTIME Service = 85
7.10 Implementation Of A TCP Client For DAYTIME = 85
7.11 Reading From A TCP Connection = 87
7.12 The TIME Service = 88
7.13 Accessing The TIME Service = 88
7.14 Accurate Times And Network Delays = 89
7.15 A UDP Client For The TIME Service = 89
7.16 The ECHO Service = 92
7.17 A TCP Client For The ECHO Service = 92
7.18 A UDP Client For The ECHO Service = 94
7.19 Summary = 96
Chapter 8 Algorithms And Issues In Server Software Design = 99
8.1 Introduction = 99
8.2 The Conceptual Server Algorithm = 99
8.3 Concurrent Vs. Iterative Servers = 100
8.4 Connection-Oriented Vs. Connectionless Access = 100
8.5 Connection-Oriented Servers = 101
8.6 Connectionless Servers = 101
8.7 Failure, Reliability, And Statelessness = 102
8.8 Optimizing Stateless Servers = 103
8.9 Four Basic Types Of Servers = 105
8.10 Request Processing Time = 106
8.11 Iterative Server Algorithms = 106
8.12 An Iterative, Connection-Oriented Server Algorithm = 107
8.13 Binding To A Well-Known Address Using INADDR_ANY = 107
8.14 Waiting For A Connection Request = 108
8.15 Accepting Connections And Using Them = 108
8.16 An Iterative, Connectionless Server Algorithm = 108
8.17 Forming A Reply Address In A Connectionless Server = 109
8.18 Concurrent Server Algorithms = 109
8.19 Master And Slave Processes = 110
8.20 A Concurrent, Connectionless Server Algorithm = 110
8.21 A Concurrent, Connection-Oriented Server Algorithm = 111
8.22 Using Separate Programs As Slaves = 112
8.23 Apparent Concurrency Using A Single Process = 112
8.24 When To Use Each Server Type = 113
8.25 A Summary of Server Types = 114
8.26 The Important Problem Of Server Deadlock = 115
8.27 Alternative Implementations = 116
8.28 Summary = 116
Chapter 9 Iterative, Connectionless Servers (UDP) = 119
9.1 Introduction = 119
9.2 Creating A Passive Descriptor = 119
9.3 Process Structure = 123
9.4 An Example TIME Server = 123
9.5 Summary = 126
Chapter 10 Iterative, Connection-Oriented Servers (TCP) = 129
10.1 Introduction = 129
10.2 Allocating A Passive TCP Descriptor = 129
10.3 A Server For The DAYTIME Service = 130
10.4 Process Structure = 130
10.5 An Example DAYTIME Server = 131
10.6 Closing Connections = 135
10.7 Connection Termination And Server Vulnerability = 136
10.8 Summary = 136
Chapter 11 Concurrent, Connection-Oriented Servers (TCP) = 139
11.1 Introduction = 139
11.2 Concurrent ECHO = 139
11.3 Iterative Vs. Concurrent Implementations = 140
11.4 Process Structure = 140
11.5 An Example Concurrent ECHO Server = 141
11.6 Notification Of Child Exit = 144
11.7 Summary = 144
Chapter 12 Single-Process, Concurrent Servers (TCP) = 147
12.1 Introduction = 147
12.2 Data-Driven Processing In A Server = 147
12.3 Data-Driven Processing With A Single Process = 148
12.4 Process Structure Of A Single-Process Server = 149
12.5 An Example Single-Process ECHO Server = 150
12.6 Summary = 152
Chapter 13 Multiprotocol Servers (TCP, UDP) = 155
13.1 Introduction = 155
13.2 The Motivation For Reducing The Number Of Servers = 155
13.3 Multiprotocol Server Design = 156
13.4 Process Structure = 156
13.5 An Example Multiprotocol DATIME Server = 157
13.6 The Concept Of Shared Code = 161
13.7 Concurrent Multiprotocol Servers = 161
13.8 Summary = 162
Chapter 14 Multiservice Servers (TCP, UDP) = 163
14.1 Introduction = 163
14.2 Consolidating Servers = 163
14.3 A Connectionless, Multiservice Server Design = 164
14.4 A Connection-Oriented, Multiservice Server Design = 165
14.5 A Concurrent, Connection-Oriented, Multiservice Server = 166
14.6 A Single-Process, Multiservice Server Implementation = 166
14.7 Invoking Separate Programs From A Multiservice Server = 167
14.8 Multiservice, Multiprotocol Designs = 168
14.9 An Example Multiservice Server = 169
14.10 The UNIX Super Server, Inetd = 175
14.11 Summary = 176
Chapter 15 Uniform, Efficient Management Of Server Concurrency = 179
15.1 Introduction = 179
15.2 Choosing Between An Iterative And A Concurrent Design = 179
15.3 Level Of Concurrency = 180
15.4 Demand-Driven Concurrency = 181
15.5 The Cost Of Concurrency = 181
15.6 Overhead And Delay = 181
15.7 Small Delays Can Matter = 182
15.8 Process Preallocation = 183
15.9 Delayed Process Allocation = 187
15.10 The Uniform Basic For Both Techniques = 188
15.11 Combining Techniques = 189
15.12 Summary = 189
Chapter 16 Concurrency In Clients = 191
16.1 Introduction = 191
16.2 The Advantages Of Concurrency = 191
16.3 The Motivation For Exercising Control = 192
16.4 Concurrent Contact With Multiple Servers = 193
16.5 Implementing Concurrent Clients = 193
16.6 Single-Process Implementations = 195
16.7 An Example Concurrent Client That Uses ECHO = 196
16.8 Execution Of The Concurrent Client = 200
16.9 Concurrency In The Example Code = 202
16.10 Summary = 202
Chapter 17 Tunneling At The Transport And Application Levels = 205
17.1 Introduction = 205
17.2 Multiprotocol Environments = 205
17.3 Mixing Network Technologies = 207
17.4 Dynamic Circuit Allocation = 208
17.5 Encapsulation And Tunneling = 209
17.6 Tunneling Through An IP Internet = 209
17.7 Application-Level Tunneling Between Clients And Servers = 210
17.8 Summary = 211
Chapter 18 Application Level Gateways = 213
18.1 Introduction = 213
18.2 Clients And Servers In Constrained Environments = 213
18.3 Using Application Gateways = 215
18.4 Interoperability Through A Mail Gateway = 216
18.5 Implementation Of A Mail Gateway = 217
18.6 A Comparison Of Application Gateways And Tunneling = 217
18.7 Application Gateways And Limited Functionality Systems = 219
18.8 Application Gateway Used For Security = 220
18.9 Application Gateways And The Extra Hop Problem = 221
18.10 An Example Application Gateway = 223
18.11 Implementation Of An Application Gateway = 224
18.12 Code For The Application Gateway = 226
18.13 An Example Gateway Exchange = 227
18.14 Using Rfcd With UNIX's forward = 228
18.15 Summary = 228
Chapter 19 External Data Representation (XDR) = 231
19.1 Introduction = 231
19.2 Representations For Data In Computers = 231
19.3 The N-Squared Conversion Problem = 232
19.4 Network Standard Byte Order = 233
19.5 A De Facto Standard External Data Representation = 234
19.6 XDR Data Types = 235
19.7 Implicit Types = 236
19.8 Software Support For Using XDR = 236
19.9 XDR Library Routines = 236
19.10 Building A Message One Piece At A Time = 236
19.11 Conversion Routines In The XDR Library = 238
19.12 XDR Streams, I/O, and TCP = 240
19.13 Records, Record Boundaries, And Datagram I/O = 241
19.14 Summary = 241
Chapter 20 Remote Procedure Call Concept (RPC) = 243
20.1 Introduction = 243
20.2 Remote Procedure Call Model = 243
20.3 Two Paradigms For Building Distributed Programs = 244
20.4 A Conceptual Model For Conventional Procedure Calls = 245
20.5 An Extension Of the Procedural Model = 245
20.6 Execution Of Conventional Procedure Call And Return = 246
20.7 The Procedural Model In Distributed Systems = 247
20.8 Analogy Between Client-Server And RPC = 248
20.9 Distributed Computation As A Program = 249
20.10 Sun Microsystems' Remote Procedure Call Definition = 250
20.11 Remote Programs And Procedures = 250
20.12 Reducing The Number Of Arguments = 251
20.13 Identifying Remote Programs And Procedures = 251
20.14 Accommodating Multiple Versions Of A Remote Program = 252
20.15 Mutual Exclusion For Procedures In A Remote Program = 253
20.16 Communication Semantics = 254
20.17 At Least Once Semantics = 254
20.18 RPC Retransmission = 255
20.19 Mapping A Remote Program To A Protocol Port = 255
20.20 Dynamic Port Mapping = 256
20.21 RPC Port Mapper Algorithm = 257
20.22 Sun RPC Message Format = 259
20.23 Marshaling Arguments For A Remote Procedure = 260
20.24 Authentication = 260
20.25 An Example Of RPC Message Representation = 261
20.26 An Example Of The UNIX Authentication Field = 262
20.27 Summary = 263
Chapter 21 Distributed Program Generation (Rpcgen Concept) = 265
21.1 Introduction = 265
21.2 Using Remote Procedure Calls = 266
21.3 Programming Mechanisms To Support RPC = 267
21.4 Dividing A Program Into Local And Remote Procedures = 268
21.5 Adding Code For RPC = 269
21.6 Stub Procedures = 269
21.7 Multiple Remote Procedures And Dispatching = 270
21.8 Name Of The Client-Side Stub Procedure = 271
21.9 Using Rpcgen To Generate Distributed Programs = 272
21.10 Rpcgen Output And Interface Procedures = 272
21.11 Rpcgen Input And Output = 273
21.12 Using Rpcgen To Build A Client And Server = 274
21.13 Summary = 274
Chapter 22 Distributed Program Generation (Rpcgen Example) = 277
22.1 Introduction = 277
22.2 An Example To Illustrate Rpcgen = 278
22.3 Dictionary Lookup = 278
22.4 Eight Steps To A Distributed Application = 279
22.5 Step 1 : Build A Conventional Application Program = 280
22.6 Step 2 : Divide The Program Into Two Parts = 284
22.7 Step 3 : Create An Rpcgen Specification = 290
22.8 Step 4 : Run Rpcgen = 292
22.9 The .h File Produced By Rpcgen = 292
22.10 The XDR Conversion File Produced By Rpcgen = 294
22.11 The Client Code Produced By Rpcgen = 295
22.12 The Server Code Produced By Rpcgen = 297
22.13 Step 5 : Write Stub Interface Procedures = 302
22.14 Step 6 : Compile And Link The Client Program = 306
22.15 Step 7 : Compile And Link The Server Program = 309
22.16 Step 8 : Start The Server And Execute The Client = 312
22.17 Using The UNIX Make Utility = 312
22.18 Summary = 315
Chapter 23 Network File System Concepts (NFS) = 317
23.1 Introduction = 317
23.2 Remote File Access Vs. Transfer = 317
23.3 Operations On Remote Files = 318
23.4 File Access Among Heterogeneous Computers = 318
23.5 Stateless Servers = 319
23.6 NFS And UNIX File Semantics = 319
23.7 Review Of The UNIX File System = 319
23.8 Files Under NFS = 333
23.9 NFS File Types = 334
23.10 NFS File Modes = 334
23.11 NFS File Attributes = 335
23.12 NFS Client And Server = 336
23.13 NFS Client Operation = 337
23.14 NFS Client And UNIX = 338
23.15 NFS Mounts = 339
23.16 File Handle = 340
23.17 Handles Replace Path Names = 340
23.18 An NFS Client In UNIX = 342
23.19 File Positioning With A Stateless Server = 342
23.20 Operations On Directories = 343
23.21 Reading A Directory Statelessly = 343
23.22 Multiple Hierarchies In An NFS Server = 344
23.23 The Mount Protocol = 344
23.24 Summary = 345
Chapter 24 Network File System Protocol (NFS, Mount) = 347
24.1 Introduction = 347
24.2 Using RPC To Define A Protocol = 347
24.3 Defining A Protocol With Data Structures And Procedures = 348
24.4 NFS Constant, Type, And Dta Declarations = 349
24.5 NFS Procedures = 352
24.6 Semantics Of NFS Operations = 353
24.7 The Mount Protocol = 357
24.8 Procedures In The Mount Protocol = 359
24.9 Semantics of Mount Operations = 359
24.10 NFS And Mount Authentication = 360
24.11 Summary = 362
Chapter 25 A TELNET Client (Program Structure) = 365
25.1 Introduction = 365
25.2 Overview = 366
25.3 A TELNET Client Algorithm = 368
25.4 Terminal I/O In UNIX = 369
25.5 Establishing Terminal Modes = 371
25.6 Global Variable Used For Stored State = 373
25.7 Restoring Terminal Modes Before Exit = 374
25.8 Client Suspension And Resumption = 375
25.9 Finite State Machine Specification = 376
25.10 Embedding Commands In A TELNET Data Stream = 377
25.11 Option Negotiation = 378
25.12 Request/Offer Symmetry = 378
25.13 TELNET Character Definitions = 378
25.14 A Finite State Machine For Data From The Server = 380
25.15 Transitions Among States = 380
25.16 A Finite State Machine Implementation = 382
25.17 A Compact FSM Representation = 383
25.18 Keeping The Compact Representation At Run-Time = 384
25.19 Implementation Of A Compact Representation = 385
25.20 Building An FSM Transition Matrix = 386
25.21 The TCP Output Finite State Machine = 388
25.22 Definitions For The TCP Output FSM = 390
25.23 The Option Subnegotiation Finite State Machine = 391
25.24 Definitions For The Option Subnegotiation FSM = 392
25.25 FSM Initialization = 393
25.26 Arguments For The TELNET Client = 393
25.27 The Heart Of The TELNET Client = 395
25.28 Implementation Of The Main FSM = 400
25.29 Summary = 401
Chapter 26 A TELNET Client (Implementation Details) = 403
26.1 Introduction = 403
26.2 The FSM Action Procedures = 403
26.3 Recording The Type Of An Option Request = 404
26.4 Performing No Operation = 405
26.5 Responding To WILL/WONT For The Echo Option = 405
26.6 Responding To WILL/WONT For Unsupported Options = 407
26.7 Responding To WILL/WONT For The No Go-Ahead Option = 408
26.8 Generating DO/DONT For Binary Transmission = 409
26.9 Responding To DO/DONT For Unsupported Options = 410
26.10 Responding To DO/DONT For Transmit Binary Option = 411
26.11 Responding To DO/DONT For The Terminal Type Option = 413
26.12 Option Subnegotiation = 414
26.13 Sending Terminal Type Information = 415
26.14 Terminating Subnegotiation = 417
26.15 Sending A Character To The Server = 417
26.16 Displaying Incoming Data On The User's Terminal = 419
26.17 Using Termcap To Control The User's Terminal = 423
26.18 Writing A Block Of Data To The Server = 424
26.19 Interacting With The Client Process = 426
26.20 Responding To Illegal Commands = 426
26.21 Scripting To A File = 427
26.22 Implementation Of Scripting = 427
26.23 Initialization Of Scripting = 428
26.24 Collecting Characters Of The Script File Name = 429
26.25 Opening A Script File = 430
26.26 Terminating Scripting = 432
26.27 Printing Status Information = 433
26.28 Summary = 434
Chapter 27 Practical Hints And Techniques For UNIX Servers = 437
27.1 Introduction = 437
27.2 Operating In Background = 437
27.3 Programming A Server To Operate In Background = 438
27.4 Open Descriptors And Inheritance = 439
27.5 Programming A Server To Close Inherited Descriptors = 440
27.6 Signals From The Controlling TTY = 440
27.7 Process Groups And Sessions = 440
27.8 Programming A Server To Change Its TTY And Session = 441
27.9 Moving To A Safe And Known Directory = 441
27.10 Programming a Server To Change Directories = 442
27.11 The UNIX Umask = 442
27.12 Programming A Server To Set Its Umask = 443
27.13 Descriptors For Standard I/O = 443
27.14 Programming A Server To Open Standard Descriptors = 443
27.15 Mutual Exclusion For The Server = 444
27.16 Programming A Server To Avoid Multiple Copies = 444
27.17 Recording A Server's Process ID = 445
27.18 Programming a Server To Record Its Process ID = 445
27.19 Waiting For A Child Process To Exit = 446
27.20 Programming a Server To Wait For Each Child To Exit = 446
27.21 Extraneous Signals = 446
27.22 Programming A Server To Ignore Extraneous Signals = 446
27.23 Using A System Log Facility = 447
27.24 Summary = 452
Appendix 1 TLI Library Functions = 455
Appendix 2 Manipulation Of UNIX File Descriptors = 483
Bibliography = 487
Index = 495