Home > Store

UNIX Network Programming, Volume 1: Networking APIs - Sockets and XTI, 2nd Edition

Register your product to gain access to bonus material or receive a coupon.

UNIX Network Programming, Volume 1: Networking APIs - Sockets and XTI, 2nd Edition

Book

  • Sorry, this book is no longer in print.
Not for Sale

About

Features

  • Focuses on the two major networking APIs: Sockets and the X/Open Transport Interface.
  • Explains how to build robust UNIX networking software, including Web servers.
  • Includes comprehensive coverage of the sockets API, the defacto standard for network programming.
  • Discusses basic socket functions for TCP and UDP, examples of client/server TCP programming, I/O multiplexing, socket options, and basic name and address conversions.
  • Covers advanced socket topics—Including IPv4 and Ipv6 interoperability, UNIX domain protocols, Nonblocking I/O, Broadcasting, Multicasting, Threads and routing sockets, and XTI (X/Open Transport Interface).
  • Examines client/server design alternatives thoroughly.

Description

  • Copyright 1998
  • Edition: 2nd
  • Book
  • ISBN-10: 0-13-490012-X
  • ISBN-13: 978-0-13-490012-4


49001-1

The only guide to UNIX network programming APIs you'll ever need!

Whether you write Web servers, client/server applications, or any other network software, you need to understand networking APIS—especially sockets in greater detail than ever before. You need UNIX Network Programming, Volume 1, Second Edition.

In this book, leading UNIX networking expert W. Richard Stevens offers unprecedented, start-to-finish guidance on making the most of sockets, the de facto standard for UNIX network programming—as well as extensive coverage of the X/Open Transport Interface (XTI).

Stevens begins by introducing virtually every basic capability of TCP and UDP sockets, including socket functions and options, I/O multiplexing, and name and address conversions. He presents detailed coverage of the Posix.1g standard for sockets and the Posix threads. He also introduces advanced techniques for:

  • Establishing IPv4/IPv6 interoperability.
  • Implementing non-blocking I/O.
  • Routing sockets.
  • Broadcasting and multicasting.
  • IP options.
  • Multithreading.
  • Advanced name and address conversions.
  • UNIX domain protocols.
  • Raw sockets.

Learn how to choose among today's leading client/server design approaches, including TCP iterative, concurrent, preforked and prethreaded servers. Master the X/Open Transport Interface, including XTI TCP clients and servers, name and address functions, options, streams and additional functions.

The Internet/intranet revolution has dramatically increased the demand for developers with a sophisticated understanding of network programming APIs, especially sockets. One book contains all you need to know: UNIX Network Programming, Volume 1, Second Edition.

Sample Content

Table of Contents

I. INTRODUCTION AND TCP/IP.

1. Introduction.

Introduction. A Simple Daytime Client. Protocol Independence. Error Handling: Wrapper Functions. A Simple Daytime Server. Road Map to Client-Server Examples in the Text. OSI Model. BSD Networking History. Test Networks and Hosts. Unix Standards. 64-bit Architectures. Summary.

2. The Transport Layer: TCP and UDP.

Introduction. The Big Picture. UDP: User Datagram Protocol. TCP: Transmission Control Protocol. TCP Connection Establishment and Termination. TIME_WAIT State. Port Numbers. TCP Port Numbers and Concurrent Servers. Buffer Sizes and Limitations. Standard Internet Services. Protocol Usage by Common Internet Applications. Summary.

II. ELEMENTARY SOCKETS.

3. Sockets Introduction.

Introduction. Socket Address Structures. Value-Result Arguments. Byte Ordering Functions. Byte Manipulation Functions. inet_aton, inet_addr, and inet_ntoa Functions. inet_pton and inet_ntop Functions. sock_ntop and Related Functions. readn, writen, and readline Functions. isfdtype Funtion. Summary.

4.

Introduction. socket Function. connect Function. bind Function. listen Function. accept Function. fork and exec Functions. Concurrent Servers. close Function. getsockname and getpeername Functions. Summary.

5. TCP Client-Server Example.

Introduction. TCP Echo Server: main Function. TCP Echo Server: str_echo Function. TCP Echo Client: main Function. TCP Echo Client: str_cli Function. Normal Startup. Normal Termination. Posix Signal Handling. Handling SIGCHLD Signals. wait and waitpid Functions. Connection Abort Before accept Returns. Termination of Server Process. SIFPIPE Signal. Crashing of Server Host. Crashing and Rebooting of Server Host. Shutdown of Server Host. Summary of TCP Example. Data Format. Summary.

6. I/O Multiplexing: the select and poll Function.

Introduction. I/O Models. select Function. str_cli Function (Revisited). Batch Input. shutdown Function. str_cli Function (Revisited Again). TCP Echo Server (Revisited). pselect Function. poll Function. TCP Echo Server (Revisited Again). Summary.

7. Socket Options.

Introduction. getsockopt and setsockopt Functions. Checking if an Option is Supported and Obtaining the Default. Socket States. Ipv6 Socket Options. TCP Socket Options. fcntl Function. Summary.

8. Elementary UDP Sockets.

Introduction. recvfrom and sendto Function. UDP Echo Server: main Function. UDP Echo Server: dg_echo Function. UDP Echo Client: main Function. UDP Echo Client: dg_cli Function. Lost Datagrams. Verifying Received Response. Server Not Running. Summary of UDP example. connect Function With UDP. dg_cli Function (Revisited). Lack of Flow Control With UDP. Determining Outgoing Interface with UDP. TCP and UDP Echo Server Using select. Summary.

9. Elementary Name and Address Conversions.

Introduction. Domain Name System. gethostbyname Function. RES_USE_INET6 Resolver Option. gethosbyname2 Function and Ipv6 Support. gethosbyaddr Function. uname Function. gethostname Function. getservbyname and getservbyport Functions. Other Networking Information. Summary.

III. Advanced Sockets.

10. IPv4 and IPv6 Interoperability.

Introduction. Ipv4 Client, Ipv6 Server. Ipv6 Client, Ipv4 Server. Ipv6 Address Testing Macros. IPV6_ADDRFORM Socket Option. Source Code Portability. Summary.

11. Advanced Name and Address Conversions.

Introduction. getaddrinfo Function. gai_strerror Function. freeaddringo Function. getaddrinfo Function: Ipv6 and Unix Domain. getaddrinfo Function: Examples. host_serv Function. tcp_connect Function. tcp_listen Function. udp_client Function. udp_connect Function. udp_server Function. getnameinfo Function. Reentrant Functions. gethostbyname_r and gethostbyaddr_r Functions. Implementation of getaddrinfo and getnameinfo Functions. Summary.

12. Daemon Processes and inetd Superserver.

Introduction. syslogd Daemon. syslog Function. daemon_init Function. inetd Daemon. daemon_inetd Function. Summary.

13. Advanced I/O Functions.

Introduction. Socket Timeouts. recv and send Functions. readv and writev Functions. recvmsg and sendmsg Functions. Ancillary Data. How Much Data is Queued? Sockets and Standard I/O. IT/TCP: TCP for Transactions. Summary.

14. Unix Domain Protocols.

Introduction. Unix Domain Socket Address Structure. socketpair Function. Socket Functions. Unix Domain Stream Client-Server. Unix Domain Datagram Client-Server. Passing Descriptors. Receiving Sender Credentials. Summary.

15. Nonblocking I/O.

Introduction. Nonblocking Reads and Writes: str_cli Function (Revisited). Nonblocking connect. Nonblocking connect: Daytime Client. Nonblocking connect: Web Client. Nonblocking accept. Summary.

16. ioctl Operations.

Introduction. ioctl Function. Socket Operations. File Operations. Interface Configuration. get_ifi_info Function. Interface Operations. ARP Cache Operations. Routing Table Operations. Summary.

17. Routing Sockets.

Introduction. Datalink Sockect Address Structure. Reading and Writing. sysctl Operations. get_ifi_info Function. Interface Name and Index Functions. Summary.

18. Broadcasting.

Introduction. Broadcast Addresses. Unicast Versus Broadcast. dg_cli Function Using Broadcasting. Race Conditions. Summary.

19. Multicasting.

Introduction. Multicast Addresses. Multicasting Versus Broadcasting on A LAN. Multicasting on A WAN. Multicast Socket Options. mcast_join and Related Functions. dg_cli Function Using Multicasting. Receiving MBone Session Announcements. Sending and Receiving. SNTP: Simple Network Time Protocol. SNTP (Continued). Summary.

20. Advanced UDP Sockets.

Introduction. Receiving Flags, Destination IP Address, and Interface Index. Datagram Truncation. When to Use UDP Instead of TCP. Adding Reliability to a UDP Application. Binding Interface Addresses. Concurrent UDP Servers. IPv6 Packet Information. Summary.

21. Out-of-Band Data.

Introduction. TCP Out-of-Band Data. sockatmark Function. TCP Out-of_Band Data Summary. Client-Server Heartbeat Functions. Summary.

22. Signal-Driven I/O.

Introduction. Signal-Driven I/O for Sockets. UDP Echo Server Using SIGIO. Summary.

23. Threads.

Introduction. Basic Thread Functions: Creation and Termination. str_cli Function Using Threads. TCP Echo Server Using Threads. Thread-Specific Data. Web Client and Simultaneous Connections (Continued). Mutexes: Mutual Exclusion. Condition Variables. Web Client and Simultaneous Connections (Continued). Summary.

24. IP Options.

Introduction. IPv4 Options. IPv4 Source Route Options. IPv6 Extension Headers. IPv6 Hop-by-Hop Options and Destination Options. IPv6 Routing Header. IPv6 Sticky Options. Summary.

25. Raw Sockets.

Introduction. Raw Socket Creation. Raw Socket Output. Raw Socket Input. Ping Program. Traceroute Program. An ICMP Message Daemon. Summary.

26. Datalink Access.

Introduction. BPF: BSD Packet Filter. DLPI: Data Link Provider Interface. Linux: SOCK_PACKET. libcap: Packet Capture Library. Examining the UDP Checksum Field. Summary.

27. Client-Server Design Alternatives.

Introduction. TCP Client Alternatives. TCP Test Client. TCP Iterative Server. TCP Concurrent Server, One Child per Client. TCP Preforked Server, No Locking Around accept. TCP Preforked Server, File Locking Around accept. TCP Preforked Server, Thread Locking Around accept. TCP Preforked Server, Descriptor Passing. TCP Concurrent Server, One Thread per Client. TCP Prethreaded Server, Per-Thread accept. TCP Prethreaded Server, Main Thread accept. Summary.

IV. XTI: X/OPEN TRANSPORT INTERFACE.

28. XTI: TCP Clients.

Introduction. t_open Function. t_error and t_strerror Functions. netbuf Structures and XTI Structures. t_bind Function. t_connect Function. t_rcv and t_snd Functions. t_look Function. t_sndrel and t_rcvrel Functions. t_snddis and t_rcvdis Functions. XTI TCP Daytime Client. xti_rdwr Function. Summary.

29. XTI: Name and Address Functions.

Introduction. /etc/netconfig File and netconfig Functions. NETPATH Variable and netpath Functions. netdir Functions. t_alloc and t_free Functions. t_getprotaddr Functions. xti_ntop Function. tcp_connect Function. Summary.

30. XTI: TCP Servers.

Introduction. t_listen Function. tcp_listen Function. t_accept Function. xti_accept Function. Simple Daytime Server. Multiple Pending Connections. xti_accept Function (Revisited). Summary.

31. XTI: UDP Clients and Servers.

Introduction. t_rcvudata and t_sndudata Functions. udp_client Function. t_rcvuderr Function: Asynchronous Errors. udp_server Function. Reading a Datagram in Pieces. Summary.

32. XTI Options.

Introduction. t_opthdr Structure. XTI Options. t_optmgmt Function. Checking if an Option is Supported and Obtaining the Default. Getting and Setting XTI Options. Summary.

33. Streams.

Introduction. Overview. getmsg and putmsg Functions. getpmsg and putpmsg Functions. ioctl Function. TPI: Transport Provider Interface. Summary.

34. XTI: Additional Functions.

Introduction. Nonblocking I/O. t_rcvconnect Function. t_getinfo Function. t_getstate Function. t_sync Function. t_unbind Function. t_rcvv and t_rcvvudata Functions. t_sndv and t_sndvudata Functions. t_rcvreldata and t_sndreldata Functions. Signal-Driven I/O. Out-of-Band Data. Loopback Transport Providers. Summary.

Appendix A. IPv4, IPv6, ICMPv4, and ICMPv6.

Introduction. IPv4 Header. IPv6 Header. IPv4 Addresses. IPv6 Addresses. ICMPv4 and ICMPv6: Internet Control Message Protocol.

Appendix B. Virtual Networks.

Introduction. The Mbone. The 6bone.

Appendix C. Debugging Techniques.

System Call Tracing. Standard Internet Services. sock Program. Small Test Program. tcpdump Program. netstat Program. lsof Program.

Appendix D. Miscellaneous Source Code.

unp.h Header. config.h Header. unpxti.h Header. Standard Error Routines.

Appendix E. Solutions to Selected Exercises.
Bibliography.
Index.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020