16 which in turn calls the my read function figure

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: but unfortunately programmers rarely check for this error. In Section 12.6.2 we will see that threaded programs that close already closed descriptors can suffer from a subtle race condition that sometimes causes a thread to catastrophically close another thread’s open descriptor. The bottom line: always check return codes, even for seemingly innocuous functions such as close. 12.4.7 Other Unix I/O Functions Unix provides two additional I/O functions, open and lseek. The open function creates new files and opens existing files. In each case, it returns a descriptor that can be used by other Unix file I/O routines. We will not describe open in any more depth because a clear understanding requires numerous details about Unix file systems that are not relevant to network programming. The lseek function modifies the current file position. Since it is illegal to change the current file position of a socket, we will not discuss this function either. 12.4.8 Unix I/O vs. Standard I/O The ANSII C standard defines a set of input and output functions, known as the standard I/O library, that provide a higher-level and more convenient alternative to the underlying Unix I/O functions. Functions such as fopen, fclose, fseek, fread, fwrite, fgetc, fputc, fgets, fputs, fscanf, and...
View Full Document

Ask a homework question - tutors are online