On Sat, 4 Sep 2010, raje...@cse.iitm.ac.in wrote:
Hi, I have the following piece of code, repeat{ ss<-read.socket(sockfd); if(ss=="") break output<-paste(output,ss) } but somehow, output is not receiving all the data that is coming through the socket.My suspicion is on the if statement. what happens if a white space occurs in between the string arriving over the socket?
That's not the problem. The problem occurs when R reads faster than the data are provided -- R will read and there will not be any new data available, so ss will be the empty string and the program will end. In general you can't rely on the sender transmitting data fast enough to keep ahead of R. The example in make.socket() is reading a very small amount of data, so it worked reasonably well back in the days when the finger daemon was more widely active. You need some more precise way of knowing when the data stream is over. This could be some sort of 'end of transmission' marker or a count of the number of bytes or lines to be expected. -thomas Thomas Lumley Professor of Biostatistics University of Washington, Seattle ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.