This book teaches readers how to program Linux sockets, and gives them everything they need to know to make programs communicate effetively over networks.
It presents a comprehensive discussion of all relevant topics including: writing programs compatible with both Internet Protocol version 4 (IPv4) and IPv6, raw sockets, User Datagram Protocol (UDP), broadcasting /multicasting, server internals, and more, plus a section covering Posix threads.
It provides thorough coverage of programming with the TCP, UDP, and IP protocols, as well as lower-level raw sockets. The myriad of function calls, data structures, and options associated with the APIs are explained with well-chosen diagrams and tables.
After reading this book, the reader will be able to:
Differentiate basic datagrams vs. streaming sockets.
Differentiate unicast, broadcast, and multicast sockets.
Write socket-based network programs.
Write portable code for various OS'.
Implement client-server and peer communications
Increase network throughput using "connectionless" communications
Manage asynchronous I/O, I/O and multiple sockets.
Use signals, threading and processes to manage socket connections.
Understand new socket technologies like Mbone and 6bone.
Understand Remote Procedure Calls and how to implement them.
Understand the different socket addressing types.
Table of contents
- About the Author
- Tell Us What You Think!
I. Network Programming from the Client Perspective
1. Introducing the Cookbook Network Client
- Connecting the World with Sockets
- Talking the Talk: TCP/IP Addressing Overview
- Hearing the Server: The Client's Basic Algorithm
- Summary: What's Going On Behind the Scenes?
2. TCP/IP Network Language Fluency
- An IP Numbering Overview
- IP Host Port Numbers
- Network Byte Ordering
- Different Kinds of sockaddr
- UNIX Named Pipes
- Summary: Applying IP Numbering and Tools
3. Different Types of Internet Packets
- The Fundamental Network Packet
Dissecting the Various Packets
- Considering the Packet's Issues
- Packet Types
- How the IP Protocols Fit Together
- Snooping the Network with Tcpdump
- Writing a Custom Network Snooper
- Summary: Choosing the Best Packets for Sending Messages
4. Sending Messages Between Peers
- What Are Connection-Based Sockets?
- Example: Connecting to the HTTP Daemon
- What Are Connectionless Sockets?
- Sending a Direct Message
- Ensuring UDP Message Arrival
- Juggling Tasks: A Multitasking Introduction
- Summary: Connected Versus Connectionless Models
5. Understanding the Network Layering Model
- Solving the Network Challenge
- Open Systems Interconnection (OSI) Network Model
- Internet Protocol Suite
- Fundamental Differences Between OSI and IP
- What Services What?
- Summary: From Theory to Application
- 1. Introducing the Cookbook Network Client
II. The Server Perspective and Load Control
6. A Server Primer
- Mapping the Socket: The Server's General Program Flow
- A Simple Echo Server
General Rules About Defining Protocols
- Which Program Talks First?
- Which Program Drives the Conversation?
- What Level of Certification Do You Need?
- What Type of Data Do You Use?
- How Do You Handle Binary Data?
- How Do You Know when There Is a Deadlock?
- Do You Need Clock Synchronization?
- How and When Do You Restart the Connection?
- When Are You Finished?
- An Extended Example: An HTTP Directory Server
- Summary: The Server's Basic Elements
7. Dividing the Load: Multitasking
Defining Multitasking: Processes Versus Threads
- When to Use Multitasking
- Multitasking Characteristics
- Task Differences
- How Do I Create a Process?
- How Do I Create a Thread?
- The __clone() System Call: The Call for the Brave
- Task Communication
- Beating the Clock: Race Conditions and Mutexs
- Controlling Children and Killing Zombies
- Extending Current Clients and Servers
- Calling External Programs with the exec Server
- Summary: Distributing the Process Load
- Defining Multitasking: Processes Versus Threads
8. Choosing when to Wait for I/O
- I/O Blocking: Why?
- When Do I Block?
- Alternatives to I/O Blocking
- Comparing the Different I/O Programming Interactions
- Polling I/O
- Asynchronous I/O
- Solving Unwanted I/O Blocking with poll() and select()
- Implementing Timeouts
- Summary: Choosing the I/O Techniques
9. Breaking Performance Barriers
- Creating the Servlets Before the Client Arrives
- Extending Control with a Smart Select
- Delving Deeper into Socket Control
- Recovering the Socket Descriptor
- Sending Before Received: Message Interleave
- Noting File I/O Problems
- Using Demand-Based I/O to Recover CPU Time
- Sending High-Priority Messages
- Summary: Pulling Together Performance Features
10. Designing Robust Linux Sockets
- Using Conversion Tools
- Eyeing Return Values
- Capturing Signals
- Resource Management
- Critical Servers
- Client/Server Concurrency Issues
- Denial of Service Attacks
- Summary: Solid-as-a-Rock Servers
- 6. A Server Primer
III. Looking at Sockets Objectively
11. Saving Time with Objects
- The Software Engineering Evolution
- Reaching Programming Nirvana
- Laying the Object Foundation
- Object Features
- Extending Objects
- Special Forms
- Language Support
- Summary: Object-Oriented Thinking
12. Using Java's Networking API
- Exploring Different Java Sockets
- Connecting Through I/O
- Configuring the Java Socket
- Multitasking the Programs
- Implementation Limitations
- Summary: Java-Style Network Programming
13. Designing and Using a C++ Socket Framework
- Why Use C++ for Sockets Programming?
Laying Out the Framework
- Defining the General Features
- Grouping into Major Components
- Creating the Framework Hierarchy
- Defining Each Class's Capabilities
- Testing the Socket Framework
- Implementation Limitations
- Summary: A C++ Socket Framework Simplifies Programming
14. Limits to Objects
- Mind Over Objects
- Objects Don't Solve Everything
- Complexity Give and Take
- Project Management Dilemma
- Summary: Walk Carefully on Shale
- 11. Saving Time with Objects
IV. Advanced Sockets—Adding Value
15. Network Encapsulation with Remote Procedure Calls (RPCs)
- Revisiting the OSI Model
- Comparing Network and Procedural Programming
- Supplying Middleware Methods
- Creating RPCs with rpcgen
- Creating Non-Stateless Calls with Open Connections
- Summary: Creating an RPC Toolset
16. Adding Security to Network Programs and SSL
- Giving Permission to Work
- The Problem with the Internet
- Securing a Network Node
- Encrypting the Messages
- Secure Sockets Layer (SSL)
- Summary: The Secure Server
17. Sharing Messages with Multicast, Broadcast, and Mbone
- Broadcasting Messages to a Domain
Multicasting Messages to a Group
- Joining Multicast Groups
- Sending a Multicast Message
- How the Network Provides Multicasting
- Getting Out the Multicast Message
- Multicasting Limitations
- Summary: Efficient Message Sharing
18. The Power of Raw Sockets
- When Would You Use Raw Sockets?
- What Are the Limitations?
- Putting Raw Sockets to Work
- How Does Ping Work?
- How Does Traceroute Work?
- Summary: Making the Raw Decisions
19. IPv6: The Next Generation to IP
- Current Addressing Problems
- Trying Out IPv6
- IPv6 Pros and Cons
- Summary: Moving Your Code into the Future
- 15. Network Encapsulation with Remote Procedure Calls (RPCs)
A. Data Tables
- Domains: First Parameter to socket()
- Types: Second Parameter to socket()
- Protocol Definitions
- Standard Internet Port Assignments (First 100 Ports)
- HTTP 1.1 Status Codes
- Socket Options (get/setsockopt())
- Signal Definitions
- ICMP Codes
- IPv4 Multicast Allocation
- Proposed IPv6 Address Allocation
- ICMPv6 Codes
- IPv6 Multicast Scope Field
- IPv6 Multicast Flags Field
B. Networking API
Connecting to the Network
Communicating on a Channel
- Possible Errors
- Terminating Connections
Network Data Conversions
- htons() or htonl()
- ntohs() or ntohl()
- Network Addressing Tools
- Socket Controls
- Connecting to the Network
C. Kernel API Subset
- wait(), waitPID()
Files and So On
- bzero(), memset()
D. Object Classes
- C++ Exceptions
- C++ Support Classes
- C++ Messaging Classes
- C++ Socket Classes
- Java Exceptions
- Java Support Classes
- Java I/O Classes
- Java Socket Classes
- A. Data Tables
- Title: Linux® Socket Programming
- Release date: January 2001
- Publisher(s): Sams
- ISBN: 9780672319358
You might also like
Modern Software Engineering: Doing What Works to Build Better Software Faster
Improve Your Creativity, Effectiveness, and Ultimately, Your Code In Modern Software Engineering, continuous delivery pioneer David …
Domain-Driven Design: Tackling Complexity in the Heart of Software
“Eric Evans has written a fantastic book on how you can make the design of your …
Building Microservices, 2nd Edition
As organizations shift from monolithic applications to smaller, self-contained microservices, distributed systems have become more fine-grained. …
Software Architect's Handbook
A comprehensive guide to exploring software architecture concepts and implementing best practices Key Features Enhance your …