Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!gatech!galbp!fafhrd.LBP.HARRIS.COM!bryan From: bryan@fafhrd.LBP.HARRIS.COM (Bryan Ivey (FAFHRD System Adminstrator)) Newsgroups: comp.os.minix Subject: Re: /usr/minix/amoeba/examples/client3.c Message-ID: <7501@galbp.LBP.HARRIS.COM> Date: 22 Mar 89 17:33:31 GMT References: <11077@louie.udel.EDU> <27232@cci632.UUCP> Sender: news@galbp.LBP.HARRIS.COM Reply-To: bryan@fafhrd.LBP.HARRIS.COM (Bryan Ivey (FAFHRD System Adminstrator)) Organization: Lanier/Harris, Atlanta, GA Lines: 37 In article <27232@cci632.UUCP> tvf@ccird7.UUCP (Tom Frauenhofer) writes: >In article <11077@louie.udel.EDU> jnall%FSU.BITNET@cunyvm.cuny.edu (John Nall 904-644-5241) writes: >>client3.c, does not work because the main routine has a read statement >>which is of the form "if ((n=read(fd,buf,bytes) < 0))" and, as stated >>on page 15 of K&R, this always sets n to 0 or 1, rather than the number >>of bytes read. > > >The code is correct. If there is an error with the read, it returns -1. >Check page 160, K&R, section 8.2 (Low Level I/O - Read and Write), the second >paragraph (the one that begins "Each call returns..." - the paragraph after >the sample code). > >Thomas V. Frauenhofer ...!rutgers!rochester!cci632!ccird7!tvf John Nall is making a reference to the levels of parenthesis, i.e., +--------------------------+ |+------------------------+| || +------------+ || || | | || if ((n=read(fd,buf,bytes) < 0)) should be +--------------------------+ |+--------------------+ | || +------------+| | || | || | if ((n=read(fd,buf,bytes)) < 0) Bryan Ivey Harris / Lanier Computer R & D Senior Systems Analyst 2310 Parklake Drive bryan@fafhrd.LBP.HARRIS.COM Atlanta, GA 30345