Return to BSD News archive
Received: by minnie.vk1xwt.ampr.org with NNTP id AA7842 ; Tue, 26 Jan 93 20:00:22 EST Path: sserve!manuel.anu.edu.au!munnari.oz.au!sgiblab!spool.mu.edu!olivea!uunet!ddssuprs!lpc From: lpc@dickens.com (Luis P Caamano) Newsgroups: comp.unix.bsd Subject: Re: Problem to transfer large data via socket communication - Need Help Message-ID: <1993Jan25.193306.22638@dickens.com> Date: 25 Jan 93 19:33:06 GMT References: <1993Jan8.071612.13716@news.uni-stuttgart.de> <1829@igd.fhg.de> Organization: Dickens Data Systems, Inc. Lines: 33 In article <1829@igd.fhg.de> mike@igd.fhg.de (Mike Sokolewizc (Gast)) writes: >> we develope a program with socket communication. We have large >> datas to transfer. So we use the following routines >> to send data from socket to socket (stream): >> >> write(socket,(char*)data,buffer) >> read(socket,(char*)data,buffer) >> >> But now we've problems sending/receiving large data for >> example 50*50*50 matrix of floats or larger. Is there any >> Oliver > >the system gives you only exactly what's waiting at that socket at that instant, even if more >data is coming. Therefore, you have to nest the read() within a loop and keep reading until >you get an error or the expected number of bytes: > > num_read = 0; > do > { > l = read( socket, &buffer[num_read], BUF_SIZE - num_read ); > num_read += l; > } > while ( (num_read < BUF_SIZE) && (l > 0) ); > Same thing applies for write() over a socket descriptor. -- Luis P. Caamano | lpc@dickens.com Dickens Data Systems, Inc. Atlanta, GA | uunet!dickens.com!lpc --------------------------------------------------------------------------- If I think I know it all, I'll stop learning. -myself The more I learn, the more I know I know nothing. -somebody else