Slashdot Mirror


Unix Network Programming, Vol. 1

prostoalex writes "Reviewing Richard Stevens' Unix Network Programming is akin to reviewing the New Testament for a Christian audience, or The Elements of Style for English majors. Everyone who is somehow involved in network programming on Unix/Linux systems generally refers to the tome as ultimate learning resource and the best reference out there." Read on for the rest of Alex's review. 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.

28 of 160 comments (clear)

  1. nemox by Anonymous Coward · · Score: -1, Offtopic

    almost make me miss fp!!!!

    -tirel of GNAA

  2. Does it cover gentoo? by Anonymous Coward · · Score: -1, Offtopic

    I just installed gentoo and now I can't think of anything to do with it. What is gentoo good for?

  3. Lamenting the dead - What Killed FreeBSD by Anonymous Coward · · Score: -1, Offtopic
    The End of FreeBSD

    [ed. note: in the following text, former FreeBSD developer Mike Smith gives his reasons for abandoning FreeBSD]

    When I stood for election to the FreeBSD core team nearly two years ago, many of you will recall that it was after a long series of debates during which I maintained that too much organisation, too many rules and too much formality would be a bad thing for the project.

    Today, as I read the latest discussions on the future of the FreeBSD project, I see the same problem; a few new faces and many of the old going over the same tired arguments and suggesting variations on the same worthless schemes. Frankly I'm sick of it.

    FreeBSD used to be fun. It used to be about doing things the right way. It used to be something that you could sink your teeth into when the mundane chores of programming for a living got you down. It was something cool and exciting; a way to spend your spare time on an endeavour you loved that was at the same time wholesome and worthwhile.

    It's not anymore. It's about bylaws and committees and reports and milestones, telling others what to do and doing what you're told. It's about who can rant the longest or shout the loudest or mislead the most people into a bloc in order to legitimise doing what they think is best. Individuals notwithstanding, the project as a whole has lost track of where it's going, and has instead become obsessed with process and mechanics.

    So I'm leaving core. I don't want to feel like I should be "doing something" about a project that has lost interest in having something done for it. I don't have the energy to fight what has clearly become a losing battle; I have a life to live and a job to keep, and I won't achieve any of the goals I personally consider worthwhile if I remain obligated to care for the project.

    Discussion

    I'm sure that I've offended some people already; I'm sure that by the time I'm done here, I'll have offended more. If you feel a need to play to the crowd in your replies rather than make a sincere effort to address the problems I'm discussing here, please do us the courtesy of playing your politics openly.

    From a technical perspective, the project faces a set of challenges that significantly outstrips our ability to deliver. Some of the resources that we need to address these challenges are tied up in the fruitless metadiscussions that have raged since we made the mistake of electing officers. Others have left in disgust, or been driven out by the culture of abuse and distraction that has grown up since then. More may well remain available to recruitment, but while the project is busy infighting our chances for successful outreach are sorely diminished.

    There's no simple solution to this. For the project to move forward, one or the other of the warring philosophies must win out; either the project returns to its laid-back roots and gets on with the work, or it transforms into a super-organised engineering project and executes a brilliant plan to deliver what, ultimately, we all know we want.

    Whatever path is chosen, whatever balance is struck, the choosing and the striking are the important parts. The current indecision and endless conflict are incompatible with any sort of progress.

    Trying to dissect the above is far beyond the scope of any parting shot, no matter how distended. All I can really ask of you all is to let go of the minutiae for a moment and take a look at the big picture. What is the ultimate goal here? How can we get there with as little overhead as possible? How would you like to be treated by your fellow travellers?

    Shouts

    To the Slashdot "BSD is dying" crowd - big deal. Death is part of the cycle; take a look at your soft, pallid bodies and consider that right this very moment, parts of you are dying. See? It's not so bad.

    To the bulk of the FreeBSD committerbase and the developer community at large - keep your eyes on the real goals. I

  4. FreeBSD by cft · · Score: -1, Offtopic

    is really great for network programming, it has one of the cleanest APIs and fastest TCP/IP stacks ever make. I swear if my boss makes me move to linux I will quit the job, it's that good!

  5. Re:Why program for unix by Anonymous Coward · · Score: -1, Offtopic

    I agree. I just installed Gentoo. "The greatest distro evar" they say. It took me 4 days of work to get from downloading the CD to my mouse scroll wheel working in Mozilla. Linux is truly not ready for prime time.

  6. 8===D -_- by Anonymous Coward · · Score: -1, Offtopic

    Bukkake!
    ke ke ke

  7. Re:So much work! by Trigun · · Score: 0, Offtopic

    Try PyQT and Kugar.

    It's powerful, and once you get past the whole OOP thing, it's brain-dead to use.

    I'm still waiting for Crystal Reports on Unix tho... It's a better program.

  8. not to be morbid.... by carpe_noctem · · Score: -1, Offtopic

    Ok, I don't mean this to be offensive in any way, but how in the hell did stevens die? None of the obituaries say, and I'm a bit curious. How do we know that he didn't disappear into the bowels of the CIA or something? -puts on tinfoil hat-

    --
    "Quoting famous computer scientists out of context is the root of all evil (or at least most of it) in programming." - K
    1. Re:not to be morbid.... by Anonymous Coward · · Score: -1, Offtopic
      I thought he died from an infection caused by sexual impaling. Maybe I'm thinking of Donald Knuth.


      Whatever. Even if you didn't read his work, you probably benefitted from his contributions to unix culture. Truly a slashdot icon, etc. etc.

    2. Re:not to be morbid.... by RevDobbs · · Score: 0, Offtopic
      Of course, since you think you are content, does any of it matter? Isn't that good enough?

      I figured it out!

      The original Matrix was so good that people started actually believeing that we are in a Matrix. In order to suppress those ideas, the Machines made sure that the two subsequent movies sucked so much ass that people would rebel against the truth-telling nature of the movies, and hence reject their message.

      My god, the conspiracy grows... maybe it was AN AGENT that kill W. Richard Stevens to slow down would-be rebel hackers!!! Maybe Theo deRaddt is actually an Agent trying to harvest the best in human computer security ideas just to make their own systems un-crackable!!!

      ::shudder:: it boggles the mind... down right hurts to think of such things... and I think that pain is just further proof of a conspiracy... ouch

  9. Re:Why program for unix by webtre · · Score: -1, Offtopic

    You comapre that to the millions and millions of driver problems that happen every day to win32 users? You sir, are an idiot. Sure, gentoo has problems, but then carrying that over to say that "every single lunix distribution is a piece of shit" is unintelligent, ignorant, and makes you a mindless automiton for the corporate FUD controllers to manipuate easily. An A/C is just that, A COWARD.

    --
    litigious bastards
    suck it sco!
  10. Re:So much work! by nick+this · · Score: -1, Offtopic

    You, sir, have been trolled.

  11. Actually... by Anonymous Coward · · Score: -1, Offtopic

    My university emphasized The Chicago Manual of Style over Elements of Style.

    Go figure.

  12. yawn by Anonymous Coward · · Score: -1, Offtopic

    instead of reviewing boring books, maybe slashdot could be a forum for people to post sex stories involving Kathleen Fent?

  13. Aw, the truth hurts by Anonymous Coward · · Score: -1, Offtopic

    Eh, fanboy?

  14. Re:Why program for unix by Anonymous Coward · · Score: -1, Offtopic
    I've never had a driver problem with win32 (windows 2k and xp).


    I have, however, had to recompile the kernel from a red hat distro in order to get my logitech mouseman to work.

  15. Re:So much work! by Trigun · · Score: 0, Offtopic

    Yeah, I know.

  16. Dear Readers by Letter · · Score: -1, Offtopic
    Dear Readers,

    Reviewing this book is like reviewing internet porn for slashdot readers!

    Whackin',
    Beyonce

  17. It's surprising by Enrico+Pulatzo · · Score: -1, Offtopic

    how many Christians don't read the New Testament (or Old, for that matter).

    1. Re:It's surprising by DAldredge · · Score: -1, Offtopic

      It isn't the Christians that do not read the Bible. It is all those 'religious' people that claim to be Christians that haven't read the Bible.

    2. Re:It's surprising by thryllkill · · Score: -1, Offtopic

      The Old testament should be read for reference, or entertainment only, since it pertains to the Jewish religion, and most Christians are Christian of non-Jewish ethnicity, or Gentile Christians. Not to mention that fact that the message of the New Testament (peace and all that hippy love your neighbor stuff) is in opposition to a lot of the Old Testament killing, murdering, scourging, raping, and death type stuff.

      I am a Christian and my hackles get raised evertime I hear someone substantiate their beliefs based on the Old Testament.

      --

      Note to self: No more arguing with the faithful.

    3. Re:It's surprising by rutledjw · · Score: -1, Offtopic
      This is totally off-topic, but what the heck, I never have any spare time to post anymore so I'll take what I can get.

      Let's not also forget that the Old Testament has a ton of prophecy. Concerning everything from Christ to end-times. Also, there are a lot of powerful metaphors concerning sins of the past and how they relate to our lives. As for the hate stuff, I agree. I will happily argue with anyone who justifies (for example) beating up, or even disliking homosexuals based on Biblical text.

      --

      Computer Science is Applied Philosophy
    4. Re:It's surprising by Hulfs · · Score: -1, Offtopic
      I am a Christian and my hackles get raised evertime I hear someone substantiate their beliefs based on the Old Testament.

      The orthodoxy of the Holy Catholic (meaning universal...not Roman Catholic) has and always will uphold that the Jewish Scriptures (aka Old Testament) are authoritative AND inspired. You are wading into the waters of early church heretic, Marcion (~AD 138), who argued the same beliefs you do. He insisted that the OT is inferior to the NT canon he had assembled (this in addition to his polytheistic beliefs). His heretical teachings were actually a strong force in the early church's assembly of their own canon (read: the New Testament). For a rebuttal of all things Marcion read Tertullian's Against Marcion.

  18. TRY rotten.com. THEY HAVE PICS by Anonymous Coward · · Score: -1, Offtopic

    Of Fent.

  19. Re:In Wayne's World II by frodo+from+middle+ea · · Score: 2, Offtopic
    Can C IPC APIs (shmem/message Qs/pipes) be used in VM environments (read IBM m/cs running muliple linuxes) ?


    I hate to use Corba/RPC for IPC if applications are running on the same hardware , albeit diff. VMs.

    --
    for the last time people, I am "frodo from middle eaRTH", not "middle eaST".
  20. Re:Why program for unix by Anonymous Coward · · Score: -1, Offtopic
    I have, however, had to recompile the kernel from a red hat distro in order to get my logitech mouseman to work.

    Perhaps you should upgrade from Red Hat 6.0. Mice with wheels (USB and PS/2) have been recognized out-of-the-box for years with no configuring required.

  21. Poor Hitlary by Anonymous Coward · · Score: -1, Offtopic

    Poor Hitlary. It seems that she found a bit of trouble locating troops that wanted to dine with her during her Thanksgiving trip to Iraq. At least our troops have the good sense to know when someone detests everything they fight for.

  22. SCO UPDATE! IMPORTANT! by Anonymous Coward · · Score: -1, Offtopic
    SCO Must Prove Existence Of Santa Claus in Thirty Days

    By Brian Briggs

    Salt Lake City, UT - Supreme Court Judge Isaiah Moore ruled that SCO must show proof of Santa Claus in the next 30 days, or he will dismiss their lawsuit against all Christians and companies profiting from the Christmas holiday.

    SCO, formerly known as Santa Cruz Operations, recently changed their name to Santa Claus Operations. This change was widely regarded as a move to improve their image after their controversial claims about Linux. Critics of the name change say it's just another fantasy created by SCO CEO Kris Kringle, formerly known as Darl McBride, to profit through litigation.

    In a recent press release SCO said it would begin sending out invoices to anyone who celebrates or profits from Christmas in the next couple of weeks including corporations and individuals. A price list for SCO Christmas licenses which companies and individuals need to celebrate the holiday without violating SCO's intellectual property rights were released as well.

    "Children can avoid penalties by sending 10% of their Christmas gifts to SCO," said Kringle.

    Followers of the case consider the judge's decision a defeat for SCO, because they feel the company cannot prove the existence of Santa Claus.

    Kringle was confident that SCO would prevail in the lawsuit. He said, "We have hundreds of e-mails addressed to Kris_Kringle@sco.com. Under Federal law it is illegal to route e-mail to the wrong location intentionally. This proves without a doubt that Santa Claus exists and he works at SCO."

    Chief Counsel for the company Fred Gailey said he planned to print out these e-mails and place them in giant mailbags to dump on the judge's desk. "When the judge sees the number of e-mails we've received he will have to rule in our favor, or face breaking the hearts of his grandchildren."

    "Christmas existed long before the existence of SCO," said VP of marketing for Giantco, Clayton Moneybags. "In fact I heard that at one point it was about celebrating the birth of Jesus."

    SCO Vice president, Jesus Christ countered, "Don't you think we thought of that one too?"