Sinaddrsaddr sizeofclientaddrsinaddrsaddr afinet

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: nwritten = 0; /* and call write() again */ else return -1; /* errorno set by write() */ } nleft -= nwritten; ptr += nwritten; } return count; } code/src/csapp.c Figure 12.15: readn and writen: Robust versions of read and write Adapted from [77]. 12.4. UNIX FILE I/O 623 Notice that the routines manually restart read or write if they are interrupted by the return from an application signal handler (lines 9-10). Manual restarts are unnecessary on Unix systems, which automatically restart interrupted read and write calls. However, other systems such as Solaris do not restart interrupted system calls, and on these systems we must manually restart them. 12.4.3 Robust Input of Text Lines Using the readline Function A text line is a sequence of ASCII characters terminated by a newline character. (The newline character is the same as the ASCII line feed character (LF) and has a numeric value of 0x0a.) Many network applications, such as Web clients and servers, communicate using sequences of text lines. For these programs you s...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online