From: Robert Klemme Date: 2007-10-30T17:30:04+09:00 Subject: Re: Problem with socket.recv() 2007/10/30, Francis Cianfrocca : > On 10/30/07, Frank Preiswerk wrote: > > > > Yes, I understand that socket.recv() reads UP TO size bytes, but doesn't > > necessarily wait. > > How would you buffer the data? > > > > Maybe my server indeed sends some data when I think it doesn't, so my > > client > > receives a bit of data and thinks that's it. Buffering should do the trick > > here. But how? > > If the server closes the connection after sending the data, you can simply > use socket#read. If you need to wait for the data and then process them as > they comes in, use #select in a loop until all the data have been received. There is another option - even if the server does not close after sending: use #read with a given size limit. #read will block and return as soon data is available. Using #read without limit is a bad idea on a socket anyway because it has to read until EOS, as you indicated. DRb would be another option if both sides are written in Ruby. Kind regards robert