Date: Tue, 27 Aug 2002 22:06:58 -0500 From: "Erik" <ehamilt@siue.edu> To: "Gregory Bond" <gnb@itga.com.au> Cc: <freebsd-questions@FreeBSD.ORG> Subject: Re: fread returns eof too soon on a binary file Message-ID: <008701c24e3f$fa46b800$0200000a@amd800> References: <200208280110.LAA01291@lightning.itga.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
I'll bite. What book is that? Although who needs books when you can screw up and ask a mailing list? Erik ----- Original Message ----- From: "Gregory Bond" <gnb@itga.com.au> To: "ERIK G HAMILTON" <ehamilt@siue.edu> Cc: <freebsd-questions@FreeBSD.ORG> Sent: Tuesday, August 27, 2002 8:10 PM Subject: Re: fread returns eof too soon on a binary file > [This is not an appropriate topic for freebsd-bugs] > > The hole you are missing is: What if send() returns a count less than len but > greater than 0? You send only part of a block, but then go and fread() more > data from the current file offset, so the bit in the current block that send() > didn't transmit never gets sent. > > And what if fread() returns less than len bytes? You'll wind up sending more > data than you've read. > > This is nothing to do with fread(), you have two glaring errors in handling > byte counts and short reads/writes. Have a look at any Unix programming book > which should cover this stuff. > > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?008701c24e3f$fa46b800$0200000a>