This is THE guide to UNIX network programming APIs. 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, Third Edition. In this book, the Authors offer unprecedented, start-to-finish guidance on making the most of sockets, the de facto standard for UNIX network programming with APIs - as well as extensive coverage of the X/Open Transport Interface (XTI).
Product Description
This is THE guide to UNIX network programming APIs. 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, Third Edition. In this book, the Authors offer unprecedented, start-to-finish guidance on making the most of sockets, the de facto standard for UNIX network programming with APIs - as well as extensive coverage of the X/Open Transport Interface (XTI).
Features + Benefits
The classic guide to UNIX networking APIs - completely updated!
° Previous editions sold over 160,000 units! Second Edition (1998) sold over 53,000 in retail alone!
° Updates coverage of programming standards, debugging techniques, and covers Operating Systems including Red Hat 9, Solaris 9, HP-UX, Free BSD 4.8/5.0, AIX 5.x, and Mac OS X.
° Bill Fenner (AT/T Labs) and Andrew Rudoff (SUN) carry on the tradition of this great work.
Backcover
UNIX Network Programming, Volume 1: The Sockets Networking API, Third Edition
Everyone will want this book because it provides a great mix of practical experience, historical perspective, and a depth of understanding that only comes from being intimately involved in the field. I've already enjoyed and learned from reading this book, and surely you will too.
--Sam Leffler
The classic guide to UNIX networking APIs... now completely updated! To build today's highly distributed, networked applications and services, you need deep mastery of sockets and other key networking APIs. One book delivers comprehensive, start-to-finish guidance for building robust, high-performance networked systems in any environment: UNIX Network Programming, Volume 1, Third Edition.
Building on the legendary work of W. Richard Stevens, this edition has been fully updated by two leading network programming experts to address today's most crucial standards, implementations, and techniques. New topics include:
POSIX Single UNIX Specification Version 3
IPv6 APIs (including updated guidance on IPv6/IPv4 interoperability)
The new SCTP transport protocol
IPsec-based Key Management Sockets
FreeBSD 4.8/5.1, Red Hat Linux 9.x, Solaris 9, AIX 5.x, HP-UX, and Mac OS X implementations
New network program debugging techniques
Source Specific Multicast API, the key enabler for widespread IP multicast deployment
The authors also update and extend Stevens' definitive coverage of these crucial UNIX networking standards and techniques:
TCP and UDP transport
Sockets: elementary, advanced, routed, and raw
I/O: multiplexing, advanced functions, nonblocking, and signal-driven
Daemons and inetd
UNIX domain protocols
ioctl operations
Broadcasting and multicasting
Threads
Streams
Design: TCP iterative, concurrent, preforked, and prethreaded servers
Since 1990, network programmers have turned to one source for the insights and techniques they need: W. Richard Stevens' UNIX Network Programming. Now, there's an edition specifically designed for today's challenges--and tomorrow's.
Foreword.
Preface.
I. INTRODUCTION AND TCP/IP.
1. Introduction.
Introduction.
A Simple Daytime Client.
Protocol Independence.
Error Handling: Wrapper Functions.
A Simple Daytime Server.
Roadmap 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, UDP, and SCTP.
Introduction.
The Big Picture.
User Datagram Protocol (UDP).
Transmission Control Protocol (TCP).
Stream Control Transmission Protocol (SCTP).
TCP Connection Establishment and Termination.
TIME_WAIT State.
SCTP Association Establishment and Termination.
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.
Summary.
4. Elementary TCP Sockets.
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.
SIGPIPE 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 Functions.
Introduction.
I/O Models.
select Function.
str_cli Function (Revisited).
Batch Input and Buffering.
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.
Generic Socket Options.
IPv4 Socket Options.
ICMPv6 Socket Option.
IPv6 Socket Options.
TCP Socket Options.
SCTP Socket Options.
fcntl Function.
Summary.
8. Elementary UDP Sockets.
Introduction.
recvfrom and sendto Functions.
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 SCTP Sockets.
Introduction.
Interface Models.
sctp_bindx Function.
sctp_connectx Function.
sctp_getpaddrs Function.
sctp_freepaddrs Function.
sctp_getladdrs Function.
sctp_freeladdrs Function.
sctp_sendmsg Function.
sctp_recvmsg Function.
sctp_opt_info Function.
sctp_peeloff Function.
shutdown Function.
Notifications.
Summary.
10. SCTP Client/Server Example.
Introduction.
SCTP One-to-Many-Style Streaming Echo Server: main Function.
SCTP One-to-Many-Style Streaming Echo Client: main Function.
SCTP Streaming Echo Client: str_cli Function.
Exploring Head-of-Line Blocking.
Controlling the Number of Streams.
Controlling Termination.
Summary.
11. Name and Address Conversions.
Introduction.
Domain Name System (DNS).
gethostbyname Function.
gethostbyaddr Function.
getservbyname and getservbyport Functions.
getaddrinfo Function.
gai_strerror Function.
freeaddrinfo Function.
getaddrinfo Function: IPv6.
getaddrinfo Function: Examples.
host_serv Function.
tcp_connect Function.
tcp_listen Function.
udp_client Function.
udp_connect Function.
udp_server Function.
getnameinfo Function.
Re-entrant Functions.
gethostbyname_r and gethostbyaddr_r Functions.
Obsolete IPv6 Address Lookup Functions.
Other Networking Information.
Summary.
III. ADVANCED SOCKETS.
12. IPv4 and IPv6 Interoperability.
Introduction.
IPv4 Client, IPv6 Server.
IPv6 Client, IPv4 Server.
IPv6 Address-Testing Macros.
Source Code Portability.
Summary.
13. Daemon Processes and the inetd Superserver.
Introduction.
syslogd Daemon.
syslog Function.
daemon_init Function.
inetd Daemon.
daemon_inetd Function.
Summary.
14. 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.
Advanced Polling.
Summary.
15. 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.
16. Nonblocking I/O.
Introduction.
Nonblocking Reads and Writes: str_cli Function (Revisited).
<
In this book, the authors offer unprecedented, start-to-finish guidance on making the most of sockets, the de facto standard for UNIX network programming. The authors begin by introducing virtually every basic capability of TCP and UDP sockets, including socket functions and options, I/O multiplexing, and name and address conversions. They present detailed coverage of the Posix.1g standard for sockets and the Posix threads. They also introduce 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, and raw sockets.
Teaches students how to choose among today's leading client/server design approaches, including TCP iterative, concurrent, preforked and prethreaded servers.
The Internet/intranet revolution has dramatically increased the demand for students graduating with a sophisticated understanding of network programming APIs, especially sockets. This book helps students achieve that goal.
Product Description
This is THE guide to UNIX network programming APIs. 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, Third Edition. In this book, the Authors offer unprecedented, start-to-finish guidance on making the most of sockets, the de facto standard for UNIX network programming with APIs - as well as extensive coverage of the X/Open Transport Interface (XTI).
Features + Benefits
The classic guide to UNIX networking APIs - completely updated!
° Previous editions sold over 160,000 units! Second Edition (1998) sold over 53,000 in retail alone!
° Updates coverage of programming standards, debugging techniques, and covers Operating Systems including Red Hat 9, Solaris 9, HP-UX, Free BSD 4.8/5.0, AIX 5.x, and Mac OS X.
° Bill Fenner (AT/T Labs) and Andrew Rudoff (SUN) carry on the tradition of this great work.
Backcover
UNIX Network Programming, Volume 1: The Sockets Networking API, Third Edition
Everyone will want this book because it provides a great mix of practical experience, historical perspective, and a depth of understanding that only comes from being intimately involved in the field. I've already enjoyed and learned from reading this book, and surely you will too.
--Sam Leffler
The classic guide to UNIX networking APIs... now completely updated! To build today's highly distributed, networked applications and services, you need deep mastery of sockets and other key networking APIs. One book delivers comprehensive, start-to-finish guidance for building robust, high-performance networked systems in any environment: UNIX Network Programming, Volume 1, Third Edition.
Building on the legendary work of W. Richard Stevens, this edition has been fully updated by two leading network programming experts to address today's most crucial standards, implementations, and techniques. New topics include:
POSIX Single UNIX Specification Version 3
IPv6 APIs (including updated guidance on IPv6/IPv4 interoperability)
The new SCTP transport protocol
IPsec-based Key Management Sockets
FreeBSD 4.8/5.1, Red Hat Linux 9.x, Solaris 9, AIX 5.x, HP-UX, and Mac OS X implementations
New network program debugging techniques
Source Specific Multicast API, the key enabler for widespread IP multicast deployment
The authors also update and extend Stevens' definitive coverage of these crucial UNIX networking standards and techniques:
TCP and UDP transport
Sockets: elementary, advanced, routed, and raw
I/O: multiplexing, advanced functions, nonblocking, and signal-driven
Daemons and inetd
UNIX domain protocols
ioctl operations
Broadcasting and multicasting
Threads
Streams
Design: TCP iterative, concurrent, preforked, and prethreaded servers
Since 1990, network programmers have turned to one source for the insights and techniques they need: W. Richard Stevens' UNIX Network Programming. Now, there's an edition specifically designed for today's challenges--and tomorrow's.
Foreword.
Preface.
I. INTRODUCTION AND TCP/IP.
1. Introduction.
Introduction.
A Simple Daytime Client.
Protocol Independence.
Error Handling: Wrapper Functions.
A Simple Daytime Server.
Roadmap 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, UDP, and SCTP.
Introduction.
The Big Picture.
User Datagram Protocol (UDP).
Transmission Control Protocol (TCP).
Stream Control Transmission Protocol (SCTP).
TCP Connection Establishment and Termination.
TIME_WAIT State.
SCTP Association Establishment and Termination.
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.
Summary.
4. Elementary TCP Sockets.
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.
SIGPIPE 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 Functions.
Introduction.
I/O Models.
select Function.
str_cli Function (Revisited).
Batch Input and Buffering.
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.
Generic Socket Options.
IPv4 Socket Options.
ICMPv6 Socket Option.
IPv6 Socket Options.
TCP Socket Options.
SCTP Socket Options.
fcntl Function.
Summary.
8. Elementary UDP Sockets.
Introduction.
recvfrom and sendto Functions.
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 SCTP Sockets.
Introduction.
Interface Models.
sctp_bindx Function.
sctp_connectx Function.
sctp_getpaddrs Function.
sctp_freepaddrs Function.
sctp_getladdrs Function.
sctp_freeladdrs Function.
sctp_sendmsg Function.
sctp_recvmsg Function.
sctp_opt_info Function.
sctp_peeloff Function.
shutdown Function.
Notifications.
Summary.
10. SCTP Client/Server Example.
Introduction.
SCTP One-to-Many-Style Streaming Echo Server: main Function.
SCTP One-to-Many-Style Streaming Echo Client: main Function.
SCTP Streaming Echo Client: str_cli Function.
Exploring Head-of-Line Blocking.
Controlling the Number of Streams.
Controlling Termination.
Summary.
11. Name and Address Conversions.
Introduction.
Domain Name System (DNS).
gethostbyname Function.
gethostbyaddr Function.
getservbyname and getservbyport Functions.
getaddrinfo Function.
gai_strerror Function.
freeaddrinfo Function.
getaddrinfo Function: IPv6.
getaddrinfo Function: Examples.
host_serv Function.
tcp_connect Function.
tcp_listen Function.
udp_client Function.
udp_connect Function.
udp_server Function.
getnameinfo Function.
Re-entrant Functions.
gethostbyname_r and gethostbyaddr_r Functions.
Obsolete IPv6 Address Lookup Functions.
Other Networking Information.
Summary.
III. ADVANCED SOCKETS.
12. IPv4 and IPv6 Interoperability.
Introduction.
IPv4 Client, IPv6 Server.
IPv6 Client, IPv4 Server.
IPv6 Address-Testing Macros.
Source Code Portability.
Summary.
13. Daemon Processes and the inetd Superserver.
Introduction.
syslogd Daemon.
syslog Function.
daemon_init Function.
inetd Daemon.
daemon_inetd Function.
Summary.
14. 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.
Advanced Polling.
Summary.
15. 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.
16. Nonblocking I/O.
Introduction.
Nonblocking Reads and Writes: str_cli Function (Revisited).
<
In this book, the authors offer unprecedented, start-to-finish guidance on making the most of sockets, the de facto standard for UNIX network programming. The authors begin by introducing virtually every basic capability of TCP and UDP sockets, including socket functions and options, I/O multiplexing, and name and address conversions. They present detailed coverage of the Posix.1g standard for sockets and the Posix threads. They also introduce 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, and raw sockets.
Teaches students how to choose among today's leading client/server design approaches, including TCP iterative, concurrent, preforked and prethreaded servers.
The Internet/intranet revolution has dramatically increased the demand for students graduating with a sophisticated understanding of network programming APIs, especially sockets. This book helps students achieve that goal.