Review:Unix Network Programming, Vol. 1
UNIX Network Programming, 2nd Ed, Volume 1; Networking APIs: Sockets and XTI | |
author | W. Richard Stevens |
pages | |
publisher | Prentice-Hall, Inc. |
rating | 10 |
reviewer | Arjen Laarhoven |
ISBN | 0-13-490012-X |
summary | This new edition of UNIX Network Programming explains almost every detail of network programming on the UNIX platform thoroughly and clearly. New concepts which have become mainstream since the first edition of 1990, like multithreaded programs are explained, as are the mechanics of IPv4 and IPv6 interoperability which will become important in a few years. |
When you start with UNIX programming, and have mastered the basics,
the first thing most people want to try out is network programming (at
least, I wanted to :-). A lot of people who work with UNIX or Linux
have access to a networked environment, and work with networked
applications and tools on daily basis. There are a lot of papers and
tutorials on socket
programming floating around on the
Net, but these mostly describe the basic mechanics. In a very short
time, you can create small client-server programs which work quite
nice. But there is a lot more to UNIX network programming than just
being able to open sockets and send data back and forth.
At this point, this new edition of UNIX Network Programming enters the scene. The material from the first edition (almost 9 years old now) is greatly expanded to describe todays standards and new additions to the UNIX environment, like multithreading and IPv4/IPv6 interoperability.
This new edition of UNIX Network Programming is split into 3 volumes, of which 2 are published (Volume 2 is "Interprocess Communications", and 3 will describe important networking applications which). The main reason for this split is that the topic of network programming has expanded much since 1990. Also, the individual topics are much more elaborately described than the first edition.
An important addition to this new edition is the use of multithreaded
programs in addition to the fork
and select
implementation models. Multithreaded programs are a hot topic these
days, as they make network programming easier in a lot of situations,
and perform better on platforms with multiple processors.
Another important topic is the use of IPv6 and its interoperability with the current IPv4 standard. A great deal of information is provided about making programs protocol-independent. This will be an important part of network programming, when IPv6 becomes more mainstream.
The first edition of this book described more protocols than just
TCP/IP. Now, almost 9 years later, TCP/IP is the clear winner of the
battle with protocols like OSI and XNS. Also, the socket
API for network programming has become the "de facto" standard. But
the socket
API is not the only one which is described.
The last part of the book describes the XTI (the X/Open Transport
Interface) networking API, which originated at SysV and is part of the
X/Open Unix 98 specification. Some parts of the interface has
provisions to accommodate these other protocols, and are mentioned
where applicable, but the focus is on TCP/IP
Other nice things are the coverage of the low-level networking APIs,
like the BPF (BSD Packet Layer Filter), the DLPI (Data Link Provider
Interface) and the Linux (!) SOCK_PACKET interface. These 3
interfaces are mostly platform and/or OS dependent, so there is also
information about the libpcap
library (used in
tcpdump
, for example), which provides portable access to
these low-level networking capabilities.
Not all the things described in UNP2V1 are available on all UNIX platforms, so some things will not work on the platform on which you are developing your network applications. But most UNIX vendors are hard at work to implement all the standards. Sun Solaris and DEC UNIX 4 are currently the most capable platforms in this respect. There is good information on the networking capabilities of Linux, and the Linux community is hard at work to let it adhere to the standards decribed in this book.
What's in it for me?
If you are looking for more in-depth information about creating networking applications on the UNIX platform, UNP2V1 is for you. Not only descriptions of the various functions are provided, but things are explained thoroughly and often accompanied by example programs, which you can run and tinker with. Every chapter is ended by a section of exercises, with which you can test your understanding of the material covered in the chapter. Not only theoretical questions are asked, but a lot of exercises require you to compile, run and change the example programs and figure out what is happening because of the changes.Instead of just describing the interfaces, there is also information provided on how the TCP/IP protocol works. Stevens has found it very enlightening to know some of the mechanics of the protocol, because you know what is going on "under the hood" and can track down problems very quickly. In some discussions, Stevens refers to his TCP/IP Illustrated series, which provide much more details on the complete TCP/IP protocol suite.
Debugging is a large part of the programming process, and network
programming requires some additional tools to diagnose and solve
problems in network applications. Stevens explains how to use tools
like netstat
, tcpdump
, ifconfig
and his own sock
programs to help you debug your network
applications.
Designing a network application (and especially servers) can be done
in various ways. The most important concepts are the
fork
ing model, the select
model and the use
of multithreading. In a separate chapter, Stevens describes the pros
and cons of the different models, illustrated by examples and
performance measurements. This way, you can make an informed decision
on how to design your network application.
What's Good?
The first printing did not provide enough information in the captions of the example programs. Stevens goes through a number of revisions of a program, to include the information just covered. The problem was that you did not know if a program was not optimal or even buggy, unless you read the text. This has been changed in the new printings. Also, the first printing has a lot of typos, and some errors but these bugs have been fixed in the new printings. Stevens maintains a very detailed errata list, so you can debug your copy of UNP2V1 if necessary.I think that you have to read through this book at least once to use it as a reference. This way, you know what is possible, and can look up the parts you want when you need it. This is not a bad thing IMHO, because you have to understand the basic concepts before you can do anything useful.
The information in the front and back of the cover help you to find important functions, macro's and datastructures quickly. Also, the index is very good.
I have heard people complaining there is no information provided on network programming using the Win32 platform. These people seem unable to read titles of books. Also, the standards described in this book are standards which are created by POSIX and X/Open, and the UNIX community itself. Therefore, it is highly unlikely that they will change radically in the future. Microsoft controls the Win32 API completely, and can do with it what they want.
What's bad?
IMHO, nothing. I am aware that the book is not cheap, and that the split into multiple volumes also does not help to cut the price. But to find out this kind of information in a depth comparable with what is described in UNP2V1 yourself will cost huge amount of time (and in the case of a professional programmer, a lot of money). This review is about the contents of the books and the quality of information, and not about price.Stevens keeps up-to-date errata on his home page, so when bugs or inconsistencies are discovered, you can find them quickly there. You can buy this book at Amazon.
Table of Contents (abbreviated)
Part 1. Introduction and TCP/IP- Chapter 1. Introduction
- Chapter 2. The Transport Layer: TCP and UDP
Part 2. Elementary Sockets
- Chapter 3. Sockets Introduction
- Chapter 4. Elementary Sockets
- Chapter 5. TCP Client-Server Example
- Chapter 6. I/O Multiplexing: The
select
andpoll
functions - Chapter 7. Socket Options
- Chapter 8. Elementary UDP Sockets
- Chapter 9. Elementary Name and Address Conversions
Part 3. Advanced Sockets
- Chapter 10. IPv4 and IPv6 Interoperability
- Chapter 11. Advanced Name and Address Conversions
- Chapter 12. Daemon Processes and
inetd
Superserver - Chapter 13. Advanced I/O Functions
- Chapter 14. Unix Domain Protocols
- Chapter 15. Nonblocking I/O
- Chapter 16.
ioctl
Operations - Chapter 17. Routing Sockets
- Chapter 18. Broadcasting
- Chapter 19. Multicasting
- Chapter 20. Advanced UDP Sockets
- Chapter 21. Out-of-Band Data
- Chapter 22. Signal-Driven I/O
- Chapter 23. Threads
- Chapter 24. IP Options
- Chapter 25. Raw Sockets
- Chapter 26. Datalink Access
- Chapter 27. Client-Server Design Alternatives
Part 4. XTI: X/Open Transport Interface
- Chapter 28. XTI: TCP Clients
- Chapter 29. XTI: Name and Address Functions
- Chapter 30. XTI: TCP Servers
- Chapter 31. XTI: UDP Clients and Servers
- Chapter 32. XTI Options
- Chapter 33. Streams
- Chapter 34. XTI: Additional Functions
Appendix A. IPv4, IPv4, ICMPv4, and ICMPv6
Appendix B. Virtual Networks
Appendix C. Debugging Techniques
Appendix D. Miscellaneous Source Code
Appendix E. Solutions to Selected Exercises
Bibliography
Index
Review:Unix Network Programming, Vol. 1 More Login
Review:Unix Network Programming, Vol. 1
Related Links Top of the: day, week, month.
Slashdot Top Deals