TCP/IP Sockets in C: Practical Guide for Programmers, Second Edition is a quick and affordable way to gain the knowledge and skills needed to develop sophisticated and powerful web-based applications. The book's focused, tutorial-based approach enables the reader to master the tasks and techniques essential to virtually all client-server projects using sockets in C. This edition has been expanded to include new advancements such as support for IPv6 as well as detailed defensive programming strategies.
If you program using Java, be sure to check out this book's companion, TCP/IP Sockets in Java: Practical Guide for Programmers, 2nd Edition.
Author(s): Michael J. Donahoo; Kenneth L. Calvert
Edition: 2
Publisher: Morgan Kaufmann Publishers
Year: 2009
Language: English
Pages: 196
Tags: TCP-IP, TCP, IP
Cover Page
Copyright Page
Copyright
Preface
Preface
1 Introduction
1 Introduction
Networks, Packets, and Protocols
About Addresses
Writing Down IP Addresses
Dealing with Two Versions
Port Numbers
Special Addresses
About Names
Clients and Servers
What Is a Socket?
2 Basic TCP Sockets
2 Basic TCP Sockets
IPv4 TCP Client
IPv4 TCP Server
Creating and Destroying Sockets
Specifying Addresses
Generic Addresses
IPv4 Addresses
IPv6 Addresses
Generic Address Storage
Binary/String Address Conversion
Getting a Socket's Associated Addresses
Connecting a Socket
Binding to an Address
Handling Incoming Connections
Communication
Using IPv6
3 Of Names and Address Families
3 Of Names and Address Families
Mapping Names to Numbers
Accessing the Name Service
Details, Details
Writing Address-Generic Code
Generic TCP Client
Generic TCP Server
IPv4--IPv6 Interoperation
Getting Names from Numbers
4 Using UDP Sockets
4 Using UDP Sockets
UDP Client
UDP Server
Sending and Receiving with UDP Sockets
Connecting a UDP Socket
5 Sending and Receiving Data
5 Sending and Receiving Data
Encoding Integers
Sizes of Integers
Byte Ordering
Signedness and Sign Extension
Encoding Integers by Hand
Wrapping TCP Sockets in Streams
Structure Overlays: Alignment and Padding
Strings and Text
Bit-Diddling: Encoding Booleans
Constructing, Framing, and Parsing Messages
Framing
Text-Based Message Encoding
Binary Message Encoding
Putting It All Together
Wrapping Up
6 Beyond Basic Socket Programming
6 Beyond Basic Socket Programming
Socket Options
Signals
Nonblocking I/O
Nonblocking Sockets
Asynchronous I/O
Timeouts
Multitasking
Per-Client Processes
Per-Client Thread
Constrained Multitasking
Multiplexing
Multiple Recipients
Broadcast
Multicast
Broadcast vs. Multicast
7 Under the Hood
7 Under the Hood
Buffering and TCP
Deadlock Danger
Performance Implications
TCP Socket Life Cycle
Connecting
Closing a TCP Connection
Demultiplexing Demystified
8 Socket Programming in C++
8 Socket Programming in C++
PracticalSocket Library Overview
Plus One Service
Plus One Server
Plus One Client
Running Server and Client
Survey Service
Survey Support Functions
Survey Server
Survey Client
Running Server and Client
Survey Service, Mark 2
Socket Address Support
Socket iostream Interface
Enhanced Survey Server
Enhanced Survey Client
Administrative Client
Running Server and Clients
References
References