Network Programming with Perl

Book description

"This is a superb book. Another splendid book from Lincoln, whose mastery and lucid exposition make this a must-have for the serious Perl programmer."
--Jon Orwant, Chief Technology Officer, O'Reilly & Associates
Founder of The Perl Journal, author of Mastering Algorithms with Perl, (O'Reilly & Associates)
and co-author of Programming Perl, Third Edition (O'Reilly & Associates)

Network Programming with Perl is a comprehensive, example-rich guide to creating network-based applications using the Perl programming language. Among its many capabilities, modern Perl provides a straightforward and powerful interface to TCP/IP, and this book shows you how to leverage these capabilities to create robust, maintainable, and efficient custom client/server applications.

The book quickly moves beyond the basics to focus on high-level, application programming concepts, tools, and techniques. Readers will find a review of basic networking concepts and Perl fundamentals, including Perl's I/O functions, process model, and object-oriented extensions. In addition, the book examines a collection of the best third-party modules in the Comprehensive Perl Archive Network, including existing network protocols for e-mail, news, and the Web.

The core of the book focuses on methods and alternatives for designing TCP-based client/server systems and more advanced techniques for specialized applications. Specific topics covered include:

  • The Berkeley Sockets API

  • The TCP protocol and the IO::Socket API

  • FTP filesharing service

  • The Net::Telnet module for adapting clients to interactive network services

  • SMTP, including how to create and send e-mails with multimedia attachments

  • POP, IMAP, and NNTP for receiving and processing e-mail

  • HTTP and the LWP module for communicating with Web servers

  • Forking servers and the UNIX and Windows inetd daemons

  • Perl's experimental multithreaded API

  • Multiplexed operations and nonblocking I/O

  • Bulletproofing servers

  • TCP urgent data

  • UDP protocol and servers

  • Broadcasting and multicasting

  • Interprocess communication with UNIX-domain sockets

Useful, working programs demonstrate ideas and techniques in action, including a real-time chat and messaging system, a program for processing e-mail containing MIME attachments, a program for mirroring an FTP site, and a Web robot.

Network Programming with Perl focuses on TCP/IP rather than just the common Web protocols. Modeled after the critically acclaimed TCP/IP Illustrated by W. Richard Stevens, this book achieves a level of detail far superior to most. It is an essential resource for network administrators and Perl programmers who are creating network applications.


Table of contents

  1. Copyright
  2. Preface
  3. Acknowledgments
  4. Basics
    1. Input/Output Basics
      1. Perl and Networking
      2. Networking Made Easy
      3. Filehandles
      4. Using Object-Oriented Syntax with the IO::Handle and IO::File Modules
      5. Summary
    2. Processes, Pipes, and Signals
      1. Processes
      2. Pipes
      3. Signals
      4. Summary
    3. Introduction to Berkeley Sockets
      1. Clients, Servers, and Protocols
      2. Berkeley Sockets
      3. Socket Addressing
      4. A Simple Network Client
      5. Network Names and Services
      6. Network Analysis Tools
      7. Summary
    4. The TCP Protocol
      1. A TCP Echo Client
      2. Socket Functions Related to Outgoing Connections
      3. A TCP Echo Server
      4. Adjusting Socket Options
      5. Other Socket-Related Functions
      6. Exceptional Conditions during TCP Communications
      7. Summary
    5. The IO::Socket API
      1. Using IO::Socket
      2. IO::Socket Methods
      3. More Practical Examples
      4. Concurrent Clients
      5. Summary
  5. Developing Clients for Common Services
    1. FTP and Telnet
      1. Net::FTP
      2. Net::Telnet
      3. Summary
    2. SMTP: Sending Mail
      1. Introduction to the Mail Modules
      2. Net::SMTP
      3. MailTools
      4. MIME-Tools
      5. Summary
    3. POP, IMAP, and NNTP
      1. The Post Office Protocol
      2. The IMAP Protocol
      3. Internet News Clients
      4. A News-to-Mail Gateway
      5. Summary
    4. Web Clients
      1. Installing LWP
      2. LWP Basics
      3. LWP Examples
  6. Developing TCP Client/Server Systems
    1. Forking Servers and the inetd Daemon
      1. Standard Techniques for Concurrency
      2. Running Example: A Psychotherapist Server
      3. The Psychotherapist as a Forking Server
      4. A Client Script for the Psychotherapist Server
      5. Daemonization on UNIX Systems
      6. Starting Network Servers Automatically
      7. Using the inetd Super Daemon
      8. Summary
    2. Multithreaded Applications
      1. About Threads
      2. A Multithreaded Psychiatrist Server
      3. A Multithreaded Client
      4. Summary
    3. Multiplexed Applications
      1. A Multiplexed Client
      2. The IO::Select Module
      3. A Multiplexed Psychiatrist Server
      4. Summary
    4. Nonblocking I/O
      1. Creating Nonblocking I/O Handles
      2. Using Nonblocking Handles
      3. Using Nonblocking Handles with Line-Oriented I/O
      4. A Generic Nonblocking I/O Module
      5. Nonblocking Connects and Accepts
      6. Summary
    5. Bulletproofing Servers
      1. Using the System Log
      2. Setting User Privileges
      3. Taint Mode
      4. Using chroot()
      5. Handling HUP and Other Signals
      6. Summary
    6. Preforking and Prethreading
      1. Preforking
      2. Prethreading
      3. Performance Measures
      4. Summary
    7. IO::Poll
      1. Using IO::Poll
      2. IO::Poll Events
      3. IO::Poll Methods
      4. A Nonblocking TCP Client Using IO::Poll
      5. Summary
  7. Advanced Topics
    1. TCP Urgent Data
      1. "Out-of-Band" Data and the Urgent Pointer
      2. Using TCP Urgent Data
      3. The sockatmark() Function
      4. A Travesty Server
      5. Summary
    2. The UDP Protocol
      1. A Time of Day Client
      2. Creating and Using UDP Sockets
      3. UDP Errors
      4. Using UDP Sockets with IO::Socket
      5. Sending to Multiple Hosts
      6. UDP Servers
      7. Increasing the Robustness of UDP Applications
      8. Summary
    3. UDP Servers
      1. An Internet Chat System
      2. The Chat Client
      3. The Chat Server
      4. Detecting Dead Clients
      5. Summary
    4. Broadcasting
      1. Unicasting versus Broadcasting
      2. Broadcasting Explained
      3. Sending and Receiving Broadcasts
      4. Broadcasting Without the Broadcast Address
      5. Enhancing the Chat Client to Support Resource Discovery
      6. Summary
    5. Multicasting
      1. Multicast Basics
      2. Using Multicast
      3. Sample Multicast Applications
      4. Summary
    6. UNIX-Domain Sockets
      1. Using UNIX-Domain Sockets
      2. A "Wrap" Server
      3. Using UNIX-Domain Sockets for Datagrams
      4. Summary
  8. Additonal Source Code
    1. Net::NetmaskLite (Chapter 3)
    2. (Chapters 8 and 9)
    3. IO::LineBufferedSet (Chapter 13)
    4. IO::LineBufferedSessionData (Chapter 13)
    5. DaemonDebug (Chapter 14)
    6. Text::Travesty (Chapter 17)
    7. (Chapter 21)
  9. Perl Error Codes and Special Variables
    1. System Error Constants
    2. Magic Variables Affecting I/O
    3. Other Perl Globals
  10. Internet Reference Tables
    1. Assigned Port Numbers
    2. Registered Port Numbers
    3. Internet Multicast Addresses
  11. Bibliography
    1. Perl Programming
    2. TCP/IP and Berkeley Sockets
    3. Network Server Design
    4. Multicasting
    5. Application-Level Protocols

Product information

  • Title: Network Programming with Perl
  • Author(s): Lincoln D. Stein
  • Release date: December 2000
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 0201615711