You are previewing TCP/IP Sockets in C, 2nd Edition.
O'Reilly logo
TCP/IP Sockets in C, 2nd Edition

Book Description

TCP/IP Sockets in C: Practical Guide for Programmers, 2nd 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.



  • Includes completely new and expanded sections that address the IPv6 network environment, defensive programming, and the select() system call, thereby allowing the reader to program in accordance with the most current standards for internetworking.
  • Streamlined and concise tutelage in conjunction with line-by-line code commentary allows readers to quickly program web-based applications without having to wade through unrelated and discursive networking tenets.
  • Grants the reader access to online source code, which the can then be used to directly implement sockets programming procedures.

Table of Contents

  1. Cover
  2. Title Page
  3. Copyright
  4. Preface to the Second Edition
    1. Changes from the First Edition
    2. Platform Requirements and Portability
  5. Table of Contents
  6. Chapter 1: Introduction
    1. 1.1 Networks, Packets, and Protocols
    2. 1.2 About Addresses
    3. 1.3 About Names
    4. 1.4 Clients and Servers
    5. 1.5 What Is a Socket?
    6. Exercises
  7. Chapter 2: Basic TCP Sockets
    1. 2.1 IPv4 TCP Client
    2. 2.2 IPv4 TCP Server
    3. 2.3 Creating and Destroying Sockets
    4. 2.4 Specifying Addresses
    5. 2.5 Connecting a Socket
    6. 2.6 Binding to an Address
    7. 2.7 Handling Incoming Connections
    8. 2.8 Communication
    9. 2.9 Using IPv6
    10. Exercises
  8. Chapter 3: Of Names and Address Families
    1. 3.1 Mapping Names to Numbers
    2. 3.2 Writing Address-Generic Code
    3. 3.3 Getting Names from Numbers
    4. Exercises
  9. Chapter 4: Using UDP Sockets
    1. 4.1 UDP Client
    2. 4.2 UDP Server
    3. 4.3 Sending and Receiving with UDP Sockets
    4. 4.4 Connecting a UDP Socket
    5. Exercises
  10. Chapter 5: Sending and Receiving Data
    1. 5.1 Encoding Integers
    2. 5.2 Constructing, Framing, and Parsing Messages
    3. 5.3 Wrapping Up
    4. Exercises
  11. Chapter 6: Beyond Basic Socket Programming
    1. 6.1 Socket Options
    2. 6.2 Signals
    3. 6.3 Nonblocking I/O
    4. 6.4 Multitasking
    5. 6.5 Multiplexing
    6. 6.6 Multiple Recipients
    7. Exercises
  12. Chapter 7: Under the Hood
    1. 7.1 Buffering and TCP
    2. 7.2 Deadlock Danger
    3. 7.3 Performance Implications
    4. 7.4 TCP Socket Life Cycle
    5. 7.5 Demultiplexing Demystified
    6. Exercises
  13. Chapter 8: Socket Programming in C++
    1. 8.1 PracticalSocket Library Overview
    2. 8.2 Plus One Service
    3. Exercises
    4. 8.3 Survey Service
    5. 8.4 Survey Service, Mark 2
    6. Exercises
  14. References
  15. Instructions for online access