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.

160 comments

  1. In Wayne's World II by Anonymous Coward · · Score: 5, Informative

    according to:

    http://www.roguewave.com/support/docs/hppdocs/tp ru g/29-1.html

    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.

    1. 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".
    2. Re:In Wayne's World II by Anonymous Coward · · Score: 1, Informative

      VM are separated by the VM software, so you should not be able to communicate between them. I've had to write TCP/IP applications between CMS and MV (it's been awhile, so those may be the wrong OS names). It feels silly, but they are, after, virtually separate machines.

    3. Re:In Wayne's World II by Anonymous Coward · · Score: 1, Interesting

      Can someone explain why this is offtopic. A question about UNIX IPC API, which closely relates to IPC capabilities of TCP/IP ? Sigh...

    4. Re:In Wayne's World II by Anonymous Coward · · Score: 0

      Some people just didn't understand Wayne's World II.

      If you play, they will come.

    5. Re:In Wayne's World II by Anonymous Coward · · Score: 0

      I remember spending an hour poring over the first edition at the university bookstore totally bumming that I couldn't afford this book that so wonderfully explained things that even a dense moron like me could get an idea of what was going on. Dejectedly, I placed the book back on the shelf. Later that night, with what little money I had, I went to the cheapo university theater to watch Wayne's World II. When I saw the scene with the girl carrying that same Unix Networking book I almost literally fell on the floor laughing. As silly as it sounds, that movie made me feel a little better about things.

    6. Re:In Wayne's World II by cant_get_a_good_nick · · Score: 2, Interesting

      There was a cool write-up of this in Salon right after he died. See the last couple paragraphs of the second page. Kind of cool for a guy that helped so many people, most of them who never got to thank him.

    7. Re:In Wayne's World II by Anonymous Coward · · Score: 0

      Hmm. I have all of Stevens' books (fantastic BTW) and none of them look like the book the Garth is holding. However, the blue text on white background looks very much like an earlier version of a book that I also have - Bach's "The Design of the UNIX Operating System".

      See Amazon's picture here.

  2. So much work! by ObviousGuy · · Score: 5, Funny

    What there ought to be is some sort of environment where developers can use a simple markup language to describe a GUI and have some easy to use hooks back to a server machine which could run some code and generate reports to be delivered back to the GUI.

    If there were only some software to fill that gap...

    --
    I have been pwned because my /. password was too easy to guess.
    1. 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.

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

      Yeah, I know.

    3. Re:So much work! by SharpFang · · Score: 1

      XUL

      --
      45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
  3. other must have books by richard stevens by gokulpod · · Score: 5, Informative
    --
    My mom never taught me to sign.
    1. Re:other must have books by richard stevens by goodviking · · Score: 5, Informative

      And my personal favorite:

      Advanced Programming in the UNIX Enviornment

      otherwise known as "Why didn't I just start with this in the first place."

      In general, I've found that Stevens, as well as Douglas Comer are two authors who can always be trusted to deliver material that is both relevant and enlightening.

    2. Re:other must have books by richard stevens by jemfinch · · Score: 1

      Um, given that this review is on UNIX Network Programming, I don't know if it quite qualifies as "other must have books by richard stevens" :)

    3. Re:other must have books by richard stevens by ipjohnson · · Score: 1

      I also personally really like the unix programming guide for system V (o'reilly book). Covers not only networking and IPC but a whole host of other things from file system to process monitoring (it says system V in the title but cover a slew of unixs).

    4. Re:other must have books by richard stevens by jcoy42 · · Score: 3, Informative

      Yes, APUE is excellent- but after reading that, take a look at Beginning Linux Programming from Wrox Press. This book give the best bite sized simple, coherent examples I have seen anywhere.

      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.

      --
      Never trust an atom. They make up everything.
    5. Re:other must have books by richard stevens by Codifex+Maximus · · Score: 1

      I have 2 books within easy reach of my keyboard:
      Linux Application Development and Unix Network Programming. I use the UNP book more but the LAD is good for Linux specific tweaking.

      --
      Codifex Maximus ~ In search of... a shorter sig.
    6. Re:other must have books by richard stevens by KevinArchibald · · Score: 1

      I used the APUE book in my undergraduate systems programming class. I didn't care for the book. It wasn't very readable as a textbook, and it has a mediocre index, which I think is essential for a book to be used a reference. The chapter questions, which I assume would highlight the most important concepts and points, seem to highlight more esoteric details, often which are not discussed in that particular chapter, or the rest of the book. For example, question 7.4: "Some Unix implementations purposely arrange that, when a program is executed, location 0 in the data segment is not accessible. Why? (Stevens 1993: 185)." The answer is not in Chapter 7, or in the rest of the book. If this detail was so important, then why isn't it discussed in the book, and in fact, not listed in the index? After reading and using this book for a quarter, I have not been eager to look at another Stevens book. For me at least, David A. Curry's "Unix Systems Programming for SVR4" was more helpful for systems programming, and Jon C. Snader's "Effective TCP/IP Programming" was very helpful for my computer networks class (Network, Transport, and Application layer programming). However, Sander's Tip 41 is "Read Stevens," and he has this to say about UNIX Network Programming Volume 1 in particular: "Every practicing network programmer should have this book (Snader 2000: 264-266)." So, maybe I'll check out the second edition.

  4. A Great Resource by PixelThis · · Score: 5, Insightful

    This is the best darn book on network programming bar none. I wore the covers off the 1990 edition I first owned and had to get it rebound.

    1. Re:A Great Resource by sunking2 · · Score: 1

      We aren't talking about your Hustler collection.

    2. Re:A Great Resource by Saeger · · Score: 1
      You actually had a book ... rebound?

      Do you also get your shoes resoled and your TV repaired? What century are you living in?

      --

      --
      Power to the Peaceful
    3. Re:A Great Resource by PixelThis · · Score: 2, Informative

      I purchased my copy of the first edition in '91. It finally lost it's cover around 1995.
      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.

      --

    4. Re:A Great Resource by geekoid · · Score: 1

      cool. I didn't even know anybody rebound books.
      well, other then historical books, or high monetary resale books.

      I'm surprised its so cheap.

      Live and learn.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    5. Re:A Great Resource by Bush+Pig · · Score: 1

      I usually don't bother about getting books rebound, after all, gaffer tape is pretty sturdy ...

      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.

      --
      What a long, strange trip it's been.
  5. SCTP? by jeffy124 · · Score: 4, Interesting

    Looking at the ToC on Amazon's page for this book, it says Stream Control Transmission Protocol, and is in the same chapter as TCP and UDP, implying it's a transport layer protocol. I've never heard of it. Anyone know of a decent tutorial page on it?

    --
    The One Rule Of Chess You'll Ever Need: Don't play someone who carries a kit in their bookbag.
    1. Re:SCTP? by DAldredge · · Score: 5, Informative

      Stream Control Transmission Protocol
      http://www.iec.org/online/tutorials/sctp /

    2. Re:SCTP? by geekoid · · Score: 3, Funny

      I read that as "Steam Control Transmission Protocol".

      I was thinking it was another train protocol.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    3. Re:SCTP? by prockcore · · Score: 1

      I'm just waiting for the Spam Control Transmission Protocol.

    4. Re:SCTP? by utopyr · · Score: 1

      Is that one of the basic protocols for The Difference Engine?

    5. Re:SCTP? by Alien+Being · · Score: 1

      There's a section that covers stream pipes. I always read it steam pipes.

    6. Re:SCTP? by geekoid · · Score: 1

      "The Difference Engine?"

      Like Mazda's rotary engine? ;)

      winky add for those who don't know humor... or an attempt thereof.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    7. Re:SCTP? by acaro · · Score: 1

      http://tdrwww.exp-math.uni-essen.de/inhalt/forschu ng/sctp_fb/ is a better tutorial.

      Other resources are available at www.sctp.org, www.sctp.de, and pel.cis.udel.edu

    8. Re:SCTP? by ollyg · · Score: 1

      A Linux kernel version 2.4.23 provides SCTP, enabled by default.

  6. akin to... by Savatte · · Score: 5, Funny

    Unix Network Programming is akin to reviewing the New Testament for a Christian audience, or The Elements of Style for English majors.

    would it also be akin to reviewing Battlefield Earth for Scientologists?

    1. Re:akin to... by AntiOrganic · · Score: 1, Funny

      You're implying that Scientologists are capable of objectively reviewing things without ad-hominem attacks, screaming and logical fallacies?

      For shame!

    2. Re:akin to... by Rudeboy777 · · Score: 3, Informative

      More like reviewing OT-III. (Obligatory link to piss off the Scientologists and attract legal action)

      --

      From hell's heart I fstab at /dev/hdc

    3. Re:akin to... by Anonymous Coward · · Score: 0
      Not Quite... in the reviewers examples, the reader is already familiar with the subject matter. In your example, you're asking the creator to critique something of their own design,


      It's kind of funny for slashdot readers to make fun of scientology. There are plenty of parallels between scientology and open source fanaticism as seen on slashdot.

    4. Re:akin to... by Anonymous Coward · · Score: 0

      Plenty of Slashdot readers make fun of open source fanaticism, too.

    5. Re:akin to... by Jeremy+Erwin · · Score: 1

      It's kind of funny for slashdot readers to make fun of scientology. There are plenty of parallels between scientology and open source fanaticism as seen on slashdot.
      Scientology doesn't allow forks, and is horribly expensive. Free software can be forked, and needn't cost anything.

  7. mmm... fines... by bersl2 · · Score: 2, Funny

    I checked out the 2nd edition from my school's library (I'm surprised they have it). I currently don't have time to read it, so I'm aiming for racking up the most geeky and largest fine I can @ $0.10 per day, and there's a whole semester to go!

    1. Re:mmm... fines... by Anonymous Coward · · Score: 0

      Semesters are ending or will have ended in a week or two...

    2. Re:mmm... fines... by jusdisgi · · Score: 1

      Right, and there's another semester this year. So, there's about a whole semester left for this jackass to continue needlessly and senselessly abusing his parents.

      --
      Given a choice between free speech and free beer, most people will take the beer.
    3. Re:mmm... fines... by Anonymous Coward · · Score: 0

      Really I'd think you could find geekier for taking out. I mean this book is actually worth reading. If you'd taken out say ... "PGP Source Code and Internals" You'd have a book that other than the preface has nothing but C code...

      A book designed and optimized to be scanned by OCR systems not read. The book that let the PGP cat out of the USA bag.

      Now thats geeky.

    4. Re:mmm... fines... by palfreman · · Score: 1

      I suppose renewing it is totally out of the question? Where I went to uni you couldn't graduate if you still had library fines outstanding.

    5. Re:mmm... fines... by X-Nc · · Score: 1

      Me, too. I still have a book, "Asimov on Numbers", that I checked out in '82 and forgot to return. OC, the not graduating part never was an issue as I dropped out after 3 & 1/2 semisters (in which I earned 20 credits). It's funny... I was a miserable student but I ended up 20+ years in the computer field. I do wish I had book lerning on various specific aspects of computing. I know I could be a MUCH better coder if I'd ever had any formal training in programming. Well, other than that class in BASIC I took in High School back in '79. Heh, nothing like programming on a TTY and having the punch tape be your hard copy.

      --
      --
      If I actually could spell I'd have spelled it right in the first place.
  8. Worth the read.. by Anonymous Coward · · Score: 4, Funny


    .. assuming this "Unix" thing ever takes off..

    1. Re:Worth the read.. by elmegil · · Score: 1

      Naw, Unix is obsolete.

      --
      7 November 2006: The day Americans realized corruption and incompetence weren't addressing 11 September 2001
  9. You better watch out by burgburgburg · · Score: 1

    Xemu will get you for that.

    1. Re:You better watch out by Anonymous Coward · · Score: 0

      The full text of Hubbard's highest OT level:

      "YHBT."

  10. Also available... by Anonymous Coward · · Score: 0, Informative

    ...without the slashdot referral fee, from Amazon and B&N

  11. Re:not to be morbid.... by lpp · · Score: 2, Funny
    -puts on tinfoil hat-

    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 hat-
  12. One of my favorites by bighoov · · Score: 5, Interesting

    I feel fortunate to have a signed first edition of the book. In 1993, while doing an internship at IBM and working on a sockets-related project, we brought Rich Stevens (how he signs his name) in to teach a two-day class. He had a knack for taking complicated subject matter and presenting it in an easy-to-understand, straightforward manner.

    1. Re:One of my favorites by jarnot · · Score: 1
      I too had the honor of being trained by Stevens back in 1994. He gave my company (IDD) an accelerated two-day version of UNIX System and Network programming. The man was a walking encyclopedia of UNIX programming knowledge, most of which he obtained by simply writing lots and lots of example code. He had an excellent teaching style and we all had a great time.

      Tragically, he died back in 1999. Info at http://www.kohala.com.

      --
      -------------------------

      slashdot@com.jarnot (swap the domain)

  13. Looks like a referrer to me. by Anonymous Coward · · Score: 3, Informative

    ref=sr_11_1/103-0663527-6482268

    So, your referral fee is somehow better than Slashdots? For you maybe.

    1. Re:Looks like a referrer to me. by Anonymous Coward · · Score: 0

      Well, let me see here. I tried going through Amazon's front page and searching on my own, and this is what came up:

      http://www.amazon.com/exec/obidos/tg/detail/-/
      0131411551/qid=1070911894//
      ref=sr_8_xs_ap_i0_xgl 14/103-2291422-4871869?
      v=glance&s=books&n=507846

      The "ref" refers to a book reference, not an affiliate reference. A referral link looks something like this:

      http://www.amazon.com/exec/obidos/ASIN/BOOK_ISBN /REFERRAL_NAME-20

      So you're right to be suspicious, but this one's clean.

  14. True that by ncc74656 · · Score: 5, Informative
    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.

    I have both this book and Microsoft's take on network coding. 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:

    • A socket descriptor is a SOCKET instead of an int.
    • You close a socket when you're done with it with closesocket() instead of close().
    • You call WSAStartup() before doing any socket stuff and call WSACleanup() when you're done.
    • WSAGetLastError() retrieves any errors that occur.
    • #include <winsock.h> loads all the socket-related headers you need, and you link with ws2_32.lib.

    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).

    --
    20 January 2017: the End of an Error.
    1. Re:True that by Anonymous Coward · · Score: 0

      There's a reason for the similarity between UNIX sockets and Winsock - they are both derived from the same BSD code base. Microsoft just changed a few things to be different, as always.

    2. Re:True that by joe_bruin · · Score: 2, Informative

      i second this.
      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 for:

      most bsd networking calls return -1 on failure, but windows returns either SOCKET_ERROR or INVALID_SOCKET (which have different values), depending on the call.

      windows changes many signed values to unsigned.

    3. Re:True that by AtrN · · Score: 1
      In my code I use a few simple defines to map the Winsock stuff to BSD sockets and program to the Winsock interface. You can't do all the things you want to do but for simple things it suffices.

      #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:

      • You have to use recv() and send() (or recvfrom()/sendto()) rather than read/write and deal with short writes correctly.
      • Beware of the Winsock stream socket (TCP) close behaviour. If you don't recv() up to the FIN a closesocket() will send a RST. Causes no end of trouble that one.
    4. Re:True that by AuMatar · · Score: 1

      There's a few other differences- Window's select() can't take file descriptors and cannot select on TCP and UDP simultaneously. The MSG_PEEK option on Windows is hideously broken. A few of the error conditions have different names. But by and large it matches up exactly. Very easy to write dual OS functions to get around it.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    5. Re:True that by ncc74656 · · Score: 1
      You have to use recv() and send() (or recvfrom()/sendto()) rather than read/write and deal with short writes correctly.

      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 nonblocking I/O, you also want to look out for EWOULDBLOCK/WSAEWOULDBLOCK.)

      --
      20 January 2017: the End of an Error.
    6. Re:True that by Florian+Weimer · · Score: 2, Interesting

      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.

      Actually, Microsoft documentation used to recommend reading "UNIX Network Programming" if you wanted to write TCP/IP programms on Windows.

    7. Re:True that by ncc74656 · · Score: 1
      Actually, Microsoft documentation used to recommend reading "UNIX Network Programming" if you wanted to write TCP/IP programms on Windows.

      Platform SDK: Windows Sockets 2: Additional Documentation

      Check the last entry. :-) (Before that, they also list the three volumes of TCP/IP Illustrated.)

      --
      20 January 2017: the End of an Error.
    8. Re:True that by allanj · · Score: 1

      The points in parent comment are certainly valid, but dive in a little deeper, and it looks less promising.

      • Try messing with socket options or fcntl stuff. getsockopt/setsockopt are reasonably in order, but insists on having its value as a *char. This means that code from *nix will not automatically compile on Windows - if you use a C++ compiler anyway (pointer types are not compatible). Variants of fcntl for Winsock exists, but do NOT work anything like fcntl (and they shouldn't - sockets on Windows are NOT files).
      • A SOCKET is unsigned. Much too often I've seen networking code on *nix test for errors by checking if a socket handle is below zero. Now this never happens with an unsigned value, so at best your compiler reports this as a warning about "condition always true/false" or something. If the code checks errors by checking ==SOCKET_ERROR, it will work cleanly.
      • Error handling is different. As you correctly write, you should use WSAGetLastError() instead. However, WSAGetLastError() is thread specific, while errno is global. So if you expect threaded code for *nix to operate identically on Windows (given that the threading ports correctly - not too difficult, actually), you could be in for a nasty surprise. The worst part is that Windows actually provides an errno (#include <errno.h>), but it is not used for sockets-related errors - just C standard library related issues (where it has to be available for compatibility).

      Most of what I describe are problems you face when porting existing code from *nix to Windows. If you just write new code, most of these issues goes away, and the problem reduces mostly to what parent comment described.
      --
      Black holes are where God divided by zero
  15. 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

  16. Re:It's surprising by BigGerman · · Score: 0, Flamebait

    >>Old testament should be read for reference, or entertainment only
    Just like a book on Unix Socket Programming ;-)

  17. Re:It's surprising by Anonymous Coward · · Score: 0

    I would even go as far as to say a majority of of Christians is analphabetic.

  18. publishers shmublishers by loudici · · Score: 1

    how can the publishers get away with selling this book for 70$? the usual excuse for technical books being expensive is that they do not sell in large quantities, but that does not apply for this one. and it is the 3rd edition. and the last review consisted mainly in removing content...

    --
    Dev elpizw tipota, dev phoboumai tipota eimai lephteros http://euclidian.org
    1. Re:publishers shmublishers by Anonymous Coward · · Score: 0

      Why do they charge $70 for UNIX Network Programming? Because it is 100 times more useful than all the Java dreck books they are selling for $49 each.

    2. Re:publishers shmublishers by Kevin+Stevens · · Score: 1

      This is not a technical book per se, but rather a textbook. The difference is... well... depending on the book, $20-70. And of course, each edition tacks on about $5.

      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.

    3. Re:publishers shmublishers by niglub · · Score: 1

      The spine and binding of a textbook are different than those found on your typical bestseller. Textbook bindings are designed to withstand much more use and/or abuse. That in itself accounts for some of the added cost. Plus, no matter how popular this book is, it still doesn't sell in the quantities that, say, the latest John Grisham or J. K. Rowling novel does.

  19. Re:It's surprising by Anonymous Coward · · Score: 0

    Is it better to read a book and not understand it than to not read it at all? I'd suggest that more problems stem from poor reading comprehension skills than from those who choose not to read the book at all.

    This doesn't even begin to cover problems that stem from bad translations or translations based on a political agenda (the revered King James version is both). Most Americans who claim to have read the Bible are wrong--they've read someone's interpretation of it and think it's the same thing. Not that they would have fewer problems understanding the actual original texts, mind you. They're just reading biased and inaccurate accounts, and not even understanding THAT. That doesn't sound much different than not reading it, if you ask me.

  20. May he rest in peace... by psyconaut · · Score: 1, Redundant

    Shame nobody stopped to mention that Rich Stevens passed away in 1999.

    -psy

    1. Re:May he rest in peace... by Vexler · · Score: 1

      Actually, the review does contain a link to a usenet announcement on Deja that was sent on the 4th of September, just days after his passing, presumably by one of his colleagues. From the thread itself, it sounded like he contributed much to his field of work and to the lives of people around him. He will be missed.

    2. Re:May he rest in peace... by elmegil · · Score: 1

      Did you read the review? You know, where the reviewer said "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." (with a link even) Ok, they didn't mention that it was 1999, but can you explain what is particularly relevant about that?

      --
      7 November 2006: The day Americans realized corruption and incompetence weren't addressing 11 September 2001
    3. Re:May he rest in peace... by Anonymous Coward · · Score: 0

      How did he die? None of the stories I read said anything about this.

  21. Its been years, but... by AtariDatacenter · · Score: 1

    It has been years since I read this in college. I kept the book, and it is *somewhere*. Very useful. Very good for understanding how TCP/IP works because of the programming examples.

    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.

  22. Good Review by Jack9 · · Score: 1

    Sounds exactly like a book I would like to buy.

    Good job on another quality book review /.

    --

    Often wrong but never in doubt.
    I am Jack9.
    Everyone knows me.
  23. Re:True that (well, almost) by Anonymous Coward · · Score: 0

    Dude, if you are writing high performance servers
    in Win32 you are shit out of luck using the BSD
    style calls. The only way to got on Win32 for
    scalable performance is overlaped I/O on sockets.

    The calls that should be of interest to you are things like:

    AcceptEX(...)
    GetQueuedCompletionStatus(...)
    P ostQueuedCompletionStatus(...)

    etc, etc. Totally non-portable but who cares :-)

    - Moomin

  24. Re:Why program for unix by Anonymous Coward · · Score: 0

    Apart from with Gentoy it seems. But then what do you expect of a peice of shit like Gentoy?

  25. Yep, no one by Anonymous Coward · · Score: 0

    From the review:

    W. Richard Stevens didn't live to see the 3rd edition published

  26. Re:Why program for unix by Anonymous Coward · · Score: 0

    never had a problem with windrivers? How long have you been using a computer? 10 minutes? Let me guess you bought a dell with everything configured for you...

  27. Re:It's surprising by pavon · · Score: 1, Insightful

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

    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 doctorine, and reasures them that as long as they remember X, that the confusing details are not as important, and that even learned people like themselves have difficulty understanding the mysteries of the bible. This satisfies them but now they think that the bible is complicated, and are thus discouraged from reading it and are inclined to just read the "good" parts and breeze over the stuff that contradicts what they already "know". And eventually they become the "wise" person and the cycle starts again. In this way the bible becomes supplementary to some cultural teaching X, which often isn't biblical.

    Note to moderators: this post is not off topic. Responding to what someone wrote is never off topic. No need to waste your mod points modding this up or down when it will already only be seen by those following the thread.

  28. Re:Why program for unix by Anonymous Coward · · Score: 0

    Of course you would, Lunix is designed to run on a C64.

  29. Re:It's surprising by Anonymous Coward · · Score: 0

    It's also interesting that the church, instead of being the living body of the Christ, is a state-franchised religious organization instead. I wonder what Jesus would say about today's "realities" of funding (actually, I don't wonder. I KNOW what he would say!).

  30. Re:It's surprising by Anonymous Coward · · Score: 0
    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.

    Mathew 5.17:

    Think not that I am come to destroy the law, or the prophets: I am not come to destroy, but to fulfil.

    The Law of course being the law under which all that killing and such was undertaken.

    The scripture comes from the sermon on the mount, often noted as the summation of the New Testament.

    AC wins - fatality!!

  31. Re:It's surprising by Anonymous Coward · · Score: 0

    What does phabetic mean?

  32. Re:Why program for unix by mr_z_beeblebrox · · Score: 3, Funny

    Given a choice of Windows 95 and the latest and greatest GNU/LuniX distribution I would take Windows 95 anyday.

    Good point all these ./configure and make and make install. They are far too complicated for people like you. Windows computers can even receive code from a stranger (in email)and compile it for you! As though that isn't friendly enough it can then make a copy of it's newfound code and e-mail that to all your friends. This is what people like you need (well, in addition to sterilization). Good luck with your Win 95 box. BTW, myself and most other Unix people I know get paid a wee bit better than free ;-)

  33. 1st, 2nd and now the 3rd edition by veecee_veecee · · Score: 1

    Undoubtedly one of the best technical books that has ever been written. From the review: perhaps donating the 2nd edition to the local church library can wait. Also, if you happen to have the first edition of the book (or if you happen to lay your hands on one) don't give it away either. (Note: UNIX Network Programming, first edition was only a single volume edition). The first edition had an entire chapter on printer spooler application, which was not included in the second edition. (Please correct me if I am wrong...the application was definitely not in Vol I of second ed, but might have been included in Vol II, although I remember having looked for it in the 2nd edition and not finding it...I had to dig out a copy of the first edition from a Motorola warehouse...)

    1. Re:1st, 2nd and now the 3rd edition by fenner · · Score: 2, Informative

      Rich's untimely death occurred before the planned Volume III, which was to cover the applications section of the 1st edition. I've toyed with the idea of starting an outline for this book, but have so far just been relaxing from producing the 3rd edition =)

    2. Re:1st, 2nd and now the 3rd edition by Anonymous Coward · · Score: 0

      Hey, your name seems familiar. You don't by chance know a little about networking, do you?

  34. YHBT YHL HAND by Anonymous Coward · · Score: 0

    for sure

  35. What about Volume 3 - Applications? by ManiaX+Killerian · · Score: 2, Interesting

    When i first saw the article, I thought - finally, the third volume. There were some rummors that Gary Wright, that was co-author in TCP/IP Illustrated Vol.2, was going to finish UNP vol.3....

    I'd love to get this third edition, though... I was used to read UNPv1 before going to bed ... :)

  36. Or ... by Micah · · Score: 1

    Or you could just use Twisted and make it relatively easy ...

  37. A challenging book by acomj · · Score: 1

    I use the book at work. Its been very very helpful. However its not for those new to programming, as it not always the clearest book although the most comprehensive I've found.

    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.

  38. Network programming Vol 2 covers IPC by acomj · · Score: 1


    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..

  39. Are any of the Stevens books available online? by AxelTorvalds · · Score: 1

    Or in ebook? I'd love to have it with me all the time sans lugging the big book around. I'd gladly pay for the ebook.

    1. Re:Are any of the Stevens books available online? by Tsugumi · · Score: 1
      tcp/ip illustrated vols 1 & 2 are both on safari.

      Standard disclaimer: I have nothing to do with o'reilly, but I do like using their online book thingy.

  40. Re:Why program for unix by Anonymous Coward · · Score: 0

    Sigh, as misguided as this guy might be your treating him as a candidate for genocide shows the worst side of our little inbred commnuity. You're hurting the cause when you act like an ass. Quit it.

  41. Re:not to be morbid.... by Anonymous Coward · · Score: 0

    I think he hung himself. Might have been autoerotic, I dunno.

    Most of the oldtime slashdot unix users are now gone, but when Stevens died it turned into probably the biggest flamefest up to that time on /. Apparently Stevens had said some not so nice thing about Perl and Linux and a few people took great joy in his death.

  42. I am wondering... by Michael+Iatrou · · Score: 1

    ... if this book is a SCO-code-free product... you can never be sure!

  43. Repeat! by tibbetts · · Score: 2, Informative

    This book was already reviewed on Slashdot.

    Okay, okay, that was five years ago (to the day!), but how much can really have changed?

    --
    :wq
  44. How much can really have changed? by Tumbleweed · · Score: 1

    dot.com go boom; ask my bank account. I can no longer afford this book. :(

  45. shut up by Tumbleweed · · Score: 1

    Shut up shut up shut up I can't believe you don't shut up!

    L. Ron will _get_ you for that... :)

  46. Re:It's surprising by Duhavid · · Score: 1

    The old testament is more like a "dont do these things" text. I think it is there more as of a "now you can see why God can't just tell you what not to do".

    And if you read it closely enough, I believe you will find they have much the same message, underneath.

    --
    emt 377 emt 4
  47. Hang on a second... by Hecatonchires · · 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?

    --

    Yay me!

  48. Guru of Gurus by Vegigami · · Score: 1

    Heres an interesting article
    about Stevens over at Salon.

    --


    I can tell you the meaning of life,
    but you have to promise not to laugh.
  49. Wish I had this text in Univeristy by Anonymous Coward · · Score: 0

    I bought copies of Stevens "Unix Network Programming: Networking API's - Sockets and X11 Second Edition" and "Unix Network Programming: Interprocess Communications Second Edition". Information is very clearly presented. These are the books to read if you want to learn how TCP/IP works on Linux, Unix, MacOSX or even the lifted BSD code found in recent Microsoft systems (yep, they lifted the code from BSD when their own winsuck protocol was finally taken out and shot). Stevens work is more readable than RFC's but just as thorough. Too bad my university didn't use them.

  50. the arrogance by Anonymous Coward · · Score: 0

    it must take to think "why don't I write a review of one of Richard Stevens' programming books" is simply astounding.

  51. It's called HTTP by Anonymous Coward · · Score: 1, Insightful
    RFC 2616 + the CGI specification.

    Does just what you describe.

  52. Re:Wetbacks and other garbage by larry+bagina · · Score: 1

    Do you know why illegal immigrants pick lettuce and run fast food stands? Because they don't qualify for welfare. Kick out the illegals and end welfare. I think you'll find there are plenty of white folks that could do that work once they're not paid to sit on their ass and watch jerry springer.

    --
    Do you even lift?

    These aren't the 'roids you're looking for.

  53. Re:Why program for unix by Anonymous Coward · · Score: 0

    "Its way to complicated and its only free if your time is worth nothing."

    Hmm, you know, now that you say it... My time is worth something, so hmm, Linux has given me a lot of money then with the large amount of time it has saved me.

    Too complicated? No, not for me.

    Linux is great and is making me rich!

  54. Unix Network Programming Series is pulp by modular_forms_boy · · Score: 1

    Sorry y'all, but Stevens goofed with this series. He goes over bunches of "upcoming" APIs that just never up and came. Named semaphores? Really? What implementation of UNIX do you know with named semaphores? Come on. The last Stevens book on UNIX IPC and Sockets programming that's pretty universal is APUE.

    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 got a universal reference now." And if you're looking for a pedantic list of distinctions between UNIXes, maybe you have a reference. But if you're looking for that, just read the man pages! The good programming books are the short ones that guide you into your environment--<a href="http://cm.bell-labs.com/cm/cs/cbook/">The C Programming Language</a>; <a href="http://cm.bell-labs.com/cm/cs/upe/">The Unix Programming Environment</a>. Big unenlightening reference tomes of APIs are wastes of paper: the internet is constantly changing. Read the <a href="http://www.ietf.org/rfc.html">RFC</a>' s. That's how you learn how the internet works.

    Don't get me wrong. Stevens wrote some good books. APUE is a pretty solid reference (though also <i>too big</i>). TCP/IP Illustrated vol 1 is a really good text for conveying the ideas of networking and the internet protocol -- how they really work. But this series: I don't see it being enlightening to anyone.

    1. Re:Unix Network Programming Series is pulp by Anonymous Coward · · Score: 0

      I have to ask: what implementation of unix do you know that doesn't have named semaphores today? It seems that some providers of huge expensive specialized software systems actually use them, too . On the other hand it's not a good sign that the few mentions I've seen of them being used, were in the troubleshooting manuals of said huge software systems.

  55. So you're the reason I can't find that book! by revividus · · Score: 1
    I was going to read it, you insensitive clod!

  56. Re:Why program for unix by revividus · · Score: 1
    Maybe GNU could learn something from VB.

    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? :-)

  57. more reviews of this book by Anonymous Coward · · Score: 0
  58. stevens will forever live by Anonymous Coward · · Score: 0

    Stevens ain't dead. The first rule to eternal life is you have to die.

  59. Stevens Ain't Dead! by Anonymous Coward · · Score: 0

    Stevens will forever live. the first step to eternal life is you have to die.