2007/10/30, 7stud -- <bbxx789_05ss / yahoo.com>: > Robert Klemme wrote: > > 2007/10/30, Francis Cianfrocca <garbagecat10 / gmail.com>: > >> > >> 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. > > That's not what I'm seeing. What I see is: read() blocks until it > either receives the limit number of bytes or eof is encountered(when the > server closes the socket). In other words, read() does not return as > soon as data is available if the amount of bytes read is less than the > limit number of bytes. On the other hand, recv() returns whatever it > reads immediately. Here is the code: Yes, I was imprecise: when using #read(limit) the method will block until either limit bytes were sent or the server closes the connection; up to limit bytes will be returned. When the server closed the connection then the next #read will return nil indicating EOS. Thanks for catching that! Kind regards robert