Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!atexnet!cvbnet!aperez From: aperez@cvbnet.UUCP (Arturo Perez x6739) Newsgroups: comp.unix.wizards Subject: Re: buffer i/o using read(2) on BSD sockets Message-ID: <85@cvbnetPrime.COM> Date: 8 Mar 90 15:43:46 GMT References: <637@lot.ACA.MCC.COM> Sender: postnews@cvbnetPrime.COM Lines: 29 From article <637@lot.ACA.MCC.COM>, by ables@lot.ACA.MCC.COM (King Ables): > I've been using read(2) to read data from a socket and am having > problems when the buffers get large. I'm hoping someone has run > into this before and knows what I am doing wrong. > > I want to read an arbitrarily large block of data and not have to worry > about message boundaries (hence read/write rather than send/recv). > > > King Ables Micro Electronics and Computer Technology Corp. > ables@mcc.com 3500 W. Balcones Center Drive > +1 512 338 3749 Austin, TX 78759 This is one of my pet peeves about BSD sockets. There is no way to read an arbitrary amount of data from a socket. You have to be aware of the kernel level buffering NO MATTER WHAT LEVEL your writing your code at; i.e. apps, system, etc. Why can't the kernel block your process until you get all the data you're asking for (unless, of course, FIONBIO or O_NDELAY is set)? If I'm willing to wait, I'm willing to wait. And if the connection goes down during the transfer, I can live with that, too, just return an error. Why was such a silly decision made? Arturo Perez ComputerVision, a division of Prime aperez@cvbnet.prime.com Too much information, like a bullet through my brain -- The Police