Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!cme!libes From: libes@cme.nist.gov (Don Libes) Newsgroups: comp.unix.wizards Subject: Re: buffer i/o using read(2) on BSD sockets Message-ID: <3280@muffin.cme.nist.gov> Date: 5 Mar 90 23:41:06 GMT References: <637@lot.ACA.MCC.COM> Reply-To: libes@cme.nist.gov (Don Libes) Organization: National Institute of Standards and Technology Lines: 29 In article <637@lot.ACA.MCC.COM> ables@lot.ACA.MCC.COM (King Ables) writes: >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). > >This works fine on a socket connected between two processes on my Sun up >to a buffer size of 4096. Anything after that doesn't seem to make it. >I get (for example) 8000 back from write(hd, buf, n) where n=8000, but >when I read(hd, buf, 8000) I get 4096 and a successive read(2) returns -1. Well, what's the value of errno? Note that expecting to be able to read arbitrarily-large packets is unrealistic due to limited kernel buffering and protocol design. I know you don't want to encapsulate your I/O, but that is the only solution. I have some code that does it which you can anonymously ftp from durer.cme.nist.gov as pub/sized_io.shar.Z I also wrote a paper describing some of these problems. It is "Packet-Oriented Communications Using a Stream Protocol --or-- Making TCP/IP on Berkeley UNIX a Little More Pleasant to Use", NISTIR 90-4232, January 1990" and is available from: Mary Lou Fahey NIST Bldg 220, Rm A-127 Gaithersburg, MD 20899 fahey@cme.nist.gov Don Libes libes@cme.nist.gov ...!uunet!cme-durer!libes