《Advanced Programming in the UNIX(R) Environment (2nd Edition)》简介:
"Stephen Rago's update is a long overdue benefit to the community of professionals using the versatile family of UNIX and UNIX-like operating environments. It removes obsolescence and includes newer developments. It also thoroughly updates the context of all topics, examples, and applications to recent releases of popular implementations of UNIX and UNIX-like environments. And yet, it does all this while retaining the style and taste of the original classic."–Mukesh Kacker, cofounder and former CTO of Pronto Networks, Inc."One of the essential classics of UNIX programming."–Eric S. Raymond, author of The Art of UNIX Programming"This is the definitive reference book for any serious or professional UNIX systems programmer. Rago has updated and extended the classic Stevens text while keeping true to the original. The APIs are illuminated by clear examples of their use. He also mentions many of the pitfalls to look out for when programming across different UNIX system implementations and points out how to avoid these pitfalls using relevant standards such as POSIX 1003.1, 2004 edition and the Single UNIX Specification, Version 3."–Andrew Josey, Director, Certification, The Open Group, and Chair of the POSIX 1003.1 Working Group"Advanced Programming in the UNIX® Environment, Second Edition, is an essential reference for anyone writing programs for a UNIX system. It's the first book I turn to when I want to understand or re-learn any of the various system interfaces. Stephen Rago has successfully revised this book to incorporate newer operating systems such as GNU/Linux and Apple's OS X while keeping true to the first edition in terms of both readability and usefulness. It will always have a place right next to my computer."–Dr. Benjamin Kuperman, Swarthmore CollegePraise for the First Edition"Advanced Programming in the UNIX® Environment is a must-have for any serious C programmer who works under UNIX. Its depth, thoroughness, and clarity of explana-tion are unmatched."–UniForum Monthly"Numerous readers recommended Advanced Programming in the UNIX® Environment by W. Richard Stevens (Addison-Wesley), and I'm glad they did; I hadn't even heard of this book, and it's been out since 1992. I just got my hands on a copy, and the first few chapters have been fascinating."–Open Systems Today"A much more readable and detailed treatment of UNIX internals can be found in Advanced Programming in the UNIX® Environment by W. Richard Stevens (Addison-Wesley). This book includes lots of realistic examples, and I find it quite helpful when I have systems programming tasks to do."–RS/Magazine"This is the definitive reference book for any serious or professional UNIX systems programmer. Rago has updated and extended the original Stevens classic while keeping true to the original."–Andrew Josey, Director, Certification, The Open Group, and Chair of the POSIX 1003.1 Working GroupFor over a decade, serious C programmers have relied on one book for practical, in-depth knowledge of the programming interfaces that drive the UNIX and Linux kernels: W. Richard Stevens' Advanced Programming in the UNIX® Environment. Now, Stevens' colleague Stephen Rago has thoroughly updated this classic to reflect the latest technical advances and add support for today's leading UNIX and Linux platforms.Rago carefully retains the spirit and approach that made this book a classic. Building on Stevens' work, he begins with basic topics such as files, directories, and processes, carefully laying the groundwork for understanding more advanced techniques, such as signal handling and terminal I/O.Substantial new material includes chapters on threads and multithreaded programming, using the socket interface to drive interprocess communication (IPC), and extensive coverage of the interfaces added to the latest version of the POSIX.1 standard. Nearly all examples have been tested on four of today's most widely used UNIX/Linux platforms: FreeBSD 5.2.1; the Linux 2.4.22 kernel; Solaris 9; and Darwin 7.4.0, the FreeBSD/Mach hybrid underlying Apple's Mac OS X 10.3.As in the first edition, you'll learn through example, including more than 10,000 lines of downloadable, ANSI C source code. More than 400 system calls and functions are demonstrated with concise, complete programs that clearly illustrate their usage, arguments, and return values. To tie together what you've learned, the book presents several chapter-length case studies, each fully updated for contemporary environments.Advanced Programming in the UNIX® Environment has helped a generation of programmers write code with exceptional power, performance, and reliability. Now updated for today's UNIX/Linux systems, this second edition will be even more indispensable.
《Advanced Programming in the UNIX(R) Environment (2nd Edition)》摘录:
与应用程序使用文件描述符(fd)访问文件一样,访问套接字也需要使用套接字描述符,其在unix系统中是用文件描述符实现的。 在AF_INET通信域中套接字SOCK_STREAM的默认协议是TCP,SOCK_DGRAM的默认协议是UDP。 不同处理器架构支持不同的字节序,小端(little-endian)freebsd linux on intel pentium,大端(big-endian)mac os on power pc solaris on sun sparc,有些处理器可以配置大端和小端,更加混乱。 TCP/IP 采用大端字节序。对于TCP/IP,地址是使用网络字节序来表示,所以应用程序有时候需要在处理器的字节序和网络字节序之间转换。 uint32_t htonl(uint32_t hostint32); uint16_t htons(uint16_t hostint16); uint32_t ntohl(uint32_t netint32); uint16_t ntohsl(uint16_t netint16); h 代表host n 代表network l 代表 long s 代表 short