Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!ncifcrf!nlm-mcs!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.unix.wizards Subject: Re: Write calls which do partial writes Keywords: write select poll SIGIO connect Message-ID: <10198@smoke.BRL.MIL> Date: 3 May 89 11:19:34 GMT References: <103@matrix.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 19 In article <103@matrix.UUCP> neeraj@matrix.UUCP (neeraj sangal) writes: > n = write(fd, buf, len); > 1. Can n be less than len if fd is NOT set to non-blocking? Certainly; if only some but not all bytes were transferred, for example due to the system call being interrupted by a signal, then the best thing for write() to report is the number of bytes successfully transferred. (I forget whether IEEE 1003.1 ended up permitting this or not; it was hotly debated.) Robust stdio implementations have to loop on the write() call until all bytes are transferred or an error occurs. >Will the underlying protocol complete select the moment a single >byte can be transferred...? Obviously it should. The details depend on the exact implementation and are complicated by things like the guaranteed pipe atomic write size, etc.