Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!linac!att!ucbvax!BRL.MIL!mike From: mike@BRL.MIL (Mike Muuss) Newsgroups: comp.sys.sgi Subject: Re: network data transfers scrambled Message-ID: <9103272032.aa04320@WOLF.BRL.MIL> Date: 28 Mar 91 01:32:50 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 44 There is a slight chance that your problem may be due to not checking the return code from your read() system call. When sending data over the network, it does not always arrive in the same size "chunks" as you sent it in. (The same thing can also happen on pipes, but is seen less often, for a bunch of complicated reasons). I attach a very handy subroutine written by Bob Miles which you can use to aleviate this difficulty. I hope this solves your problem. Best, -Mike ------ /* * M R E A D * * This function performs the function of a read(II) but will * call read(II) multiple times in order to get the requested * number of characters. This can be necessary because pipes * and network connections don't deliver data with the same * grouping as it is written with. */ static int mread(fd, bufp, n) int fd; register char *bufp; unsigned n; { register unsigned count = 0; register int nread; do { nread = read(fd, bufp, n-count); if(nread == -1) return(nread); if(nread == 0) return((int)count); count += (unsigned)nread; bufp += nread; } while(count < n); return((int)count); }