buffer i/o using read(2) on BSD sockets
Arturo Perez x6739
aperez at cvbnet.UUCP
Fri Mar 9 01:43:46 AEST 1990
>From article <637 at lot.ACA.MCC.COM>, by ables at 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 at 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 at cvbnet.prime.com
Too much information, like a bullet through my brain -- The Police
More information about the Comp.unix.wizards
mailing list