Unix Network Programming, Vol. 1 160
Unix Network Programming, Vol. 1: The Sockets Networking API, Third Edition | |
author | W. Richard Stevens, Bill Fenner, Andrew M. Rudoff |
pages | 1024 |
publisher | Addison-Wesley |
rating | 9 |
reviewer | Alex Moskalyuk |
ISBN | 0131411551 |
summary | Ultimate reference guide for network programming, protocol implementation, server-client applications on Unix |
Those just starting in the field will eventually come across so many "Stevens book" references that it will eventually end up in their library. In a nutshell: Unix Network Programming is a must for anyone involved in writing network-enabled clients or server applications, requiring a variety of protocols.
The first edition of the book came out in 1990, and quickly became the college textbook and professional reference for anyone trying to get experience in the field. This is the third edition of first volume of Unix Network Programming, titled The Sockets Networking API. Volume 2 deals with Interprocess Communications and so far exists only in the 2nd edition. W. Richard Stevens didn't live to see the 3rd edition published, and the new book has Bill Fenner and Andrew M. Rudoff listed as co-authors.
The table of contents for Unix Network Programming provides a very good overview of what's packed into 31 chapters and 5 appendices that provide 950 pages of information on network programming (Addison Wesley states it's 1024 pages, but page 947 is the start of the bibliography, followed by an index which was designed by W. Richard Stevens himself for better usability). The book starts with the basics, with an introduction to network protocols and OSI model in chapters 1 and 2. The authors move on to socket programming (supporting TCP, UDP, and SCTP protocols), providing a working example of a TCP client-server application (Chapter 5) as well as SCTP client-server (Chapter 10). DNS service is covered in Chapter 10, with some additions dealing with IPv6 implementations.
The largest part of the book -- Advanced Sockets -- covers a wide range of technologies and generally it's not expected that you cover this part chapter by chapter. Chapter 12 would be of special use for anyone dealing with IPv4 and IPv6 implementations simultaneously. The authors provide an example of an IPv4 client working with an IPv6 server and vice versa. Then it proceeds to daemon processes, I/O operations on Unix, threads, raw sockets, advanced techniques for programming UDP and SCTP sockets, broadcasting and multicasting technologies, finishing off with the chapter on streams.
To avoid recapping the table of contents, it's worth mentioning that if you're an experienced network developer and have read previous editions of Stevens' book, you will find that that the book has been updated with IPv6 APIs and example code (including interoperation with IPv4 in aforementioned Chapter 12), information on the POSIX Single Unix Spec v3, a chapter on key management for IPsec (19), and three new chapters (9,10,23) on SCTP.
But wait a minute, what about the second edition, didn't it have 34 chapters, while this third one has only 31? Description of the XTI (X/Open Transport Interface) is gone, and that used to fill chapters 28,29,30,31 and 32 of the previous edition. The authors note that XTI API "has fallen out of common use and even the most recent POSIX specification does not bother to cover it." T/TCP (TCP for Transactions) is dropped as well, so if your applications still rely on either XTI or T/TCP, perhaps donating the 2nd edition to the local church library can wait.
The information above would be of interest to the professionals in the field, but what about the beginners? Can a reader expect to become proficient with developing network applications by absorbing Stevens' book? Unix Network Programming indeed makes a very good effort to be as inviting and simple as possible to the first-time reader, even while it is trying to be informative for those who've read the chapters several times. The authors generally start with the description of the solved problem, then specify the ways to solve the problem in English -- only after that do they introduce an example solution in C. The code is quite clean and universal to be re-used on Unix boxes with C++, Perl, etc. Where a proper OS function call is necessary, it's used with an explanation of what it does, and where the functionality asks for a new function, the authors introduce their own.
Don't let the word Unix in the title fool you into thinking that you will need a separate book for Win32 platform (or Linux, for that matter). Apparently, there are differences in OS-specific function calls, but as far as protocols and implementation of specific functionality, the book would provide useful examples for Microsoft developers as well. What about Apple Mac OS X? On page xxi the authors claim the code has been tested on Mac OS X on PowerPC, HP-UX 11i on PA-RISC, AIX 5.1 on PowerPC, FreeBSD 4.8 on x86, Linux 2.4.7 on x86, FreeBSD 5.1 on SPARC and Solaris 9 on SPARC.
If you're reading the book for the first time, but have been through a network class before, you might skip Chapters 1 and 2, where the basics of network interaction (port numbers, OSI model, Internet protocol suite, netstat command, TCP connections, etc.) are covered. It makes sense to peruse the starting chapters if you are not familiar with SCTP.
Since many colleges in the United States and around the world use this title for their network programming classes, a handful of exercises follows each chapter. The questions are not programming projects, just quick self-test opportunities, e.g. Chapter 18 (Routing Sockets) is followed by the question: "What would you expect the sdl_len field of a datalink socket address structure to contain for a device named eth10 whose link-layer address is a 64-bit IEEE EUI-64 address?"
Some of the things from Stevens' book (like the desire to write a wrapper function for everything) might drive you crazy, although if you accept the author's style and follow the textbook by typing up and trying the source code, you will end up with a rather nice API library for all occasions by the time you get through the first two parts. It would also certainly be nice if the book, despite the title, included at least an appendix on Windows-specific implementations for those developing clients for the Microsoft platform.
Unix Network Programming is indispensable if any part of your professional or academic career involves writing client-server applications or programs requiring network communications. A good knowledge of C and familiarity with Unix internals is required, while the book is gentle enough to provide good guidance for the beginner in the network programming field. As W. Richard Stevens' mentioned in one of the interviews, "When I hit something that I don't understand, I take a detour and learn something new. This often makes my books late by a few months, but I think accuracy and completeness are essential."
You can purchase Unix Network Programming, Vol. 1: The Sockets Networking API, Third Edition from bn.com. Slashdot welcomes readers' book reviews -- to submit a review for consideration, read the book review guidelines, then visit the submission page.
In Wayne's World II (Score:5, Informative)
http://www.roguewave.com/support/docs/hppdocs/t
An excellent introduction and reference for the various Unix C IPC mechanisms. Also famous as the book that the girl of Garth's dreams is carrying at the end of Wayne's World II.
Re:In Wayne's World II (Score:3, Offtopic)
I hate to use Corba/RPC for IPC if applications are running on the same hardware , albeit diff. VMs.
Re:In Wayne's World II (Score:1, Informative)
Re:In Wayne's World II (Score:1, Interesting)
Network programming Vol 2 covers IPC (Score:2)
People get this mixed up alot. The poorly named (in my opinion) Networking Programing Vol II covers IPC(message que/shared memory....) Network programming Vol I covers sockets (udp/tcp etc).
I still think it funny the book is in waynes world..
Re:In Wayne's World II (Score:3, Interesting)
So much work! (Score:5, Funny)
If there were only some software to fill that gap...
It's called HTTP (Score:1, Insightful)
Does just what you describe.
Re:So much work! (Score:2)
other must have books by richard stevens (Score:5, Informative)
Re:other must have books by richard stevens (Score:5, Informative)
Advanced Programming in the UNIX Enviornment [kohala.com]
otherwise known as "Why didn't I just start with this in the first place."
In general, I've found that Stevens [kohala.com], as well as Douglas Comer [purdue.edu] are two authors who can always be trusted to deliver material that is both relevant and enlightening.
Re:other must have books by richard stevens (Score:4, Informative)
The only down side to the book is it tends to skirt around error checking- which is required to provide simple summaries.
If you've read APUE, check out Beginning Linux Programming- and don't let the word Beginning throw you-it covers advanced topics quite well.
BTW- my opinions are based on the 1st edition, for the at the time when it originally came out.
Re:other must have books by richard stevens (Score:2)
Linux Application Development and Unix Network Programming. I use the UNP book more but the LAD is good for Linux specific tweaking.
Re:other must have books by richard stevens (Score:1)
Re:other must have books by richard stevens (Score:1)
Re:other must have books by richard stevens (Score:1)
A Great Resource (Score:5, Insightful)
Re:A Great Resource (Score:2)
Re:A Great Resource (Score:2)
Do you also get your shoes resoled and your TV repaired? What century are you living in?
--
Re:A Great Resource (Score:2, Informative)
The cost of replacing the book would have been around $70 US.
The cost of having the book rebound was only $25.
*[Elementary school mathematics happens]*
I had a nicely functional book and $45 left in my pocket.
--
Re:A Great Resource (Score:2)
well, other then historical books, or high monetary resale books.
I'm surprised its so cheap.
Live and learn.
Re:A Great Resource (Score:1)
However, I _do_ get my shoes resoled (you don't just throw away a $A300 pair of RMWilliams boots because the soles and heels are worn) and I have been known to get TV sets repaired as well.
SCTP? (Score:4, Interesting)
Re:SCTP? (Score:5, Informative)
http://www.iec.org/online/tutorials/sct
Re:SCTP? (Score:4, Funny)
I was thinking it was another train protocol.
Re:SCTP? (Score:2)
Re:SCTP? (Score:1)
Re:SCTP? (Score:2)
Like Mazda's rotary engine?
winky add for those who don't know humor... or an attempt thereof.
Re:SCTP? (Score:1)
Re:SCTP? (Score:1)
Re:SCTP? (Score:1)
Other resources are available at www.sctp.org, www.sctp.de, and pel.cis.udel.edu
akin to... (Score:5, Funny)
would it also be akin to reviewing Battlefield Earth for Scientologists?
Re:akin to... (Score:2, Funny)
For shame!
shut up (Score:2)
L. Ron will _get_ you for that...
You better watch out (Score:2)
Re:akin to... (Score:3, Informative)
Re:akin to... (Score:2)
Scientology doesn't allow forks, and is horribly expensive. Free software can be forked, and needn't cost anything.
mmm... fines... (Score:2, Funny)
Re:mmm... fines... (Score:1)
Re:mmm... fines... (Score:2)
Re:mmm... fines... (Score:1)
So you're the reason I can't find that book! (Score:2)
Worth the read.. (Score:4, Funny)
.. assuming this "Unix" thing ever takes off..
Re:Worth the read.. (Score:1)
Looks like a referrer to me. (Score:3, Informative)
So, your referral fee is somehow better than Slashdots? For you maybe.
One of my favorites (Score:5, Interesting)
Re:One of my favorites (Score:1)
Tragically, he died back in 1999. Info at http://www.kohala.com [kohala.com].
True that (Score:5, Informative)
I have both this book and Microsoft's take on network coding [amazon.com]. The Stevens book has been much more useful, and not just because I've needed to write Windows clients and Linux servers that interoperate. There aren't many differences between Windows Sockets and the BSD socket interface:
If you keep this info in mind, you can apply most of what's in the Stevens book under Win32 nearly as easily as you can under Linux/*BSD/whatever. You'll also end up with network code that's reasonably easy to port elsewhere...more so than if you go for a larger percentage of Microsoft-specific socket calls (many BSD-style calls have WSA* near-equivalents that you can use).
Re:True that (Score:3, Informative)
having written network code that runs on both linux and windows, this book covers pretty much anything you need to write a program that will work with winsock/winsock2 as well as unix (even though it never specifically addresses windows). you will need to translate some of the calls to ms's names, but the functionality is essentially the same (even the ioctls are similar, although mapping those gets to be a real pain). just be sure to check the winsock docs.
a few minor things to watch out f
Re:True that (Score:2)
#define SOCKET int
#define closesocket close
#define SOCKET_ERROR (-1)
#define INVALID_SOCKET (-1)
(and headers to suit, invent null wrappers for the startup/cleanup stuff too).
Other things to watch out for:
Re:True that (Score:2)
I forgot about that...but then I usually wrap send & recv in functions that make sure the correct amount of data is sent/received. A couple of conditionals (#ifdef _MSC_VER for your Win32 code) are all it'd take to make it cross-platform...you keep sending/receiving if send/recv returns a negative value and errno==EINTR (POSIX) or WSAGetLastError()==WSAEINTR (Win32). (If you use n
Re:True that (Score:2)
Re:True that (Score:3, Interesting)
Actually, Microsoft documentation used to recommend reading "UNIX Network Programming" if you wanted to write TCP/IP programms on Windows.
Re:True that (Score:2)
Platform SDK: Windows Sockets 2: Additional Documentation [microsoft.com]
Check the last entry. :-) (Before that, they also list the three volumes of TCP/IP Illustrated.)
Re:True that (Score:2)
The points in parent comment are certainly valid, but dive in a little deeper, and it looks less promising.
publishers shmublishers (Score:2)
Re:publishers shmublishers (Score:2)
But seriously... textbooks tend to be alot more thorough and dense than X in 21 days or even oreilly type books. You are not going to be able to read this in a casual manner. He is actually alot more readable than most books of this nature, but still, its a textbook nonetheless.
Re:publishers shmublishers (Score:1)
May he rest in peace... (Score:2, Redundant)
-psy
Re:May he rest in peace... (Score:1)
Re:May he rest in peace... (Score:1)
Its been years, but... (Score:2)
The most useless part? The portmapper and the r* commands. Why? Because, IMHO, the portmapper really is a stupid service in the modern world (aside from protocols which now depend on it). Almost nobody in their right mind makes those kind of services. But I suppose, for completeness sake, I'm glad it was in there.
Good Review (Score:1)
Good job on another quality book review
1st, 2nd and now the 3rd edition (Score:1)
Re:1st, 2nd and now the 3rd edition (Score:2, Informative)
What about Volume 3 - Applications? (Score:2, Interesting)
I'd love to get this third edition, though... I was used to read UNPv1 before going to bed
Or ... (Score:2)
A challenging book (Score:2)
I also don't like his examples, which tend to use his own libraries which makes them more confusing.
Note that Vol II is IPC and is similarly useful/ challenging.
Are any of the Stevens books available online? (Score:2)
Re:Are any of the Stevens books available online? (Score:1)
Standard disclaimer: I have nothing to do with o'reilly, but I do like using their online book thingy [oreilly.com].
I am wondering... (Score:1)
Repeat! (Score:3, Informative)
This book was already reviewed [slashdot.org] on Slashdot.
Okay, okay, that was five years ago (to the day!), but how much can really have changed?
How much can really have changed? (Score:2)
Hang on a second... (Score:1)
In a nutshell: Unix Network Programming is a must for anyone involved in writing network-enabled clients or server applications
I thought the publisher was Addison-Whatever, not O'Reilly?
Guru of Gurus (Score:1)
about Stevens over at Salon.
Unix Network Programming Series is pulp (Score:1)
But even his collection of vaporware APIs is not my biggest problem with this series. It's too long. Far too long. You buy it and think "wow, it's big, I've
Re:not to be morbid.... (Score:2, Funny)
I'm afraid you are too late. Having spent too much time without your protective gear, the Brainwave Ulterior Pattern and Knowledge Informational System (BUPKIS) has invaded your thoughts. You now only THINK you are wearing your hat when in fact you are on a CIA interrogation couch, drugged to the gills and hooked up to a machine that is busy fondling your deepest memories.
Of course, since you think you are content, does any of it matter? Isn't that good enough?
-removes his tinfoil ha
Re:It's surprising (Score:1, Insightful)
Here is the more common scenario in my experience (with Catholics, Baptists, non-denominational and other): While they read the bible, they start doing only do so years after forming their docterine, and then when the bible seems to contradict what they have learned they think that the bible itself is contradictory. They then ask someone more knowledgeable then them who provides some complicated tedium of doctorin
Re:It's surprising (Score:1, Flamebait)
Just like a book on Unix Socket Programming
Re:It's surprising (Score:1)
And if you read it closely enough, I believe you will find they have much the same message, underneath.
Re:Why program for unix (Score:4, Funny)
Good point all these
Re:Why program for unix (Score:2)
Yeah, something like: Don't ever create a programming "language" anything like this.
I took a quick glance at your recent posts; tell me, are these your real opinions, or do you troll for a living? :-)
Re:Wetbacks and other garbage (Score:1)