Stein presents full, working scripts, calling attention to particularly interesting lines and passages by repeating them in the text. If a program makes use of an unusual or previously undiscussed function (and lots of them do, because one of the author's missions is to introduce the contents of specialized libraries), its syntax and legal parameters will be documented and a concise statement of its behavior provided. The example programs are the best part of this book, though. As the problems get more complicated, it's fun to watch Stein solve them with efficient, attractive code. Unless you're a really experienced professional, you'll be able to study the examples in this book and learn a lot. --David Wall
- Perl function libraries and techniques that allow programs to interact with resources over a network
- IO::Socket library
- Net::FTP library
- Net::Telnet library
- Net::SMTP library
- Chat problems
- Internet Message Access Protocol (IMAP) issues
- Markup-language parsing
- Internet Protocol (IP) broadcasting and multicasting
From the Inside Flap
This Book's Audience Network Programming with Perl is written for novice and intermediate Perl programmers. I assume you know the basics of Perl programming, including how to write loops, how to construct if-else statements, how to write regular expression pattern matches, the concept of the automatic $_ variable, and the basics of arrays and hashes. You should have access to a Perl interpreter and some experience writing, running, and debugging scripts. Just as important, you should have access to a computer that is connected both to a local area network and to the Internet! Although the recipes in Chapter 10 on setting Perl-based network servers to start automatically when a machine is booted do require superuser (administrative) access, none of the other examples require privileged access to a machine.
This book does take advantage of the object-oriented features in Perl version 5 and higher, but most chapters do not assume a deep knowledge of this system. Chapter 1 addresses all the details you will need as a casual user of Perl objects.
This book is a thorough review of the TCP/IP protocol at the lowest level, or a guide to installing and configuring network hubs, routers, and name servers. Many good books on the mechanics of the TCP/IP protocol and network administration are listed in the references in Appendix D. Roadmap This book is organized into four main parts, Basics, Developing Cients for Common Services, Developing TCP Client/Server Systems, and Advanced Topics. Part I, Basics, introduces the fundamentals of TCP/IP network communications.
Chapters 1 and 2, Networking Basics and Processes, Pipes, and Signals, review Perl's functions and variables for input and output, discuss the exceptions that can occur during I/O operations, and use the piped filehandle as the basis for introducing sockets. These chapters also review Perl's process model, including signals and forking, and introduce Perl's object-oriented extensions. Chapter 3, Introduction to Berkeley Sockets, discusses the basics of Internet networking and describes IP addresses, network ports, and the principles of client/server applications. It then turns to the Berkeley Socket API, which provides the programmer's interface to TCP/IP. Chapters 4 and 5, The TCP Protocol and The IO::Socket API and Simple TCP Applications, show the basics of TCP, the networking protocol that provides reliable stream-oriented communications. These chapters demonstrate how to create client and server applications and then introduce examples that show the power of technique as well as some common roadblocks.
Part II, Developing Clients for Common Services, looks at a collection of the best third-party modules that developers have contributed to the Comprehensive Perl Archive Network (CPAN).
Chapter 6, FTP and Telnet, introduces modules that provide access to the FTP file-sharing service, as well as to the flexible Net::Telnet module which allows you to create clients to access all sorts of network services. E-mail is still the dominant application on the Internet, and Chapter 7, SMTP: Sending Mail, introduces half of the equation. This chapter shows you how to create e-mail messages on the fly, including binary attachments, and send them to their destinations. Chapter 8, POP, IMAP, and NNTP: Processing Mail and Netnews, covers the other half of e-mail, explaining modules that make it possible to receive mail from mail drop systems and process their contents, including binary attachments. Chapter 9, Web Clients, discusses the LWP module, which provides everything you need to talk to Web servers, download and process HTML documents, and parse XML.
Part III, Developing TCP Client/Server Systems--the longest part of the book--discusses the alternatives for designing TCP-based client/server systems. The major example used in these chapters is an interactive psychotherapist server, based on Joseph Weizenbaum's classic Eliza program.
Chapter 10, Forking Servers and the inetd Daemon, covers the common type of TCP server that forks a new process to handle each incoming connection. This chapter also covers the UNIX and Windows inetd daemons, which allow programs not specifically designed for networking to act as servers. Chapter 11, Multithreaded Applications, explains Perl's experimental multithreaded API, and shows how it can greatly simplify the design of TCP clients and servers. Chapters 12 and 13, Multiplexed Operations and Nonblocking I/O, discuss the select() call, which enables an application to process multiple I/O streams concurrently without using multiprocessing or multithreading. Chapter 14, Bulletproofing Servers, discusses techniques for enhancing the reliability and maintainability of network servers. Among the topics are logging, signal handling, and exceptions, as well as the important topic of network security. Chapter 15, Preforking and Prethreading, presents the forki