From: Frank Preiswerk Date: 2007-10-30T16:22:48+09:00 Subject: Re: Problem with socket.recv() ------=_Part_90_18499523.1193728970186 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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? Thanks! On 10/30/07, Joel VanderWerf wrote: > > Frank Preiswerk wrote: > > Hi everyone, > > > > I'm currently developing a Ruby TCP client and have a problem with > > socket.recv(). > > After establishing a connection with my server, I exchange a couple of > > messages until the server begins to do some calculations based on the > > client's request that take about 10 seconds. After the server finishes, > it > > sends back the result. Now my problem is that "data = socket.recv(size)" > > seems to behave non-blocking for some reason. It does not wait for the > 10 > > seconds but rather executes immediately and "data" remains empty. When I > add > > "sleep(10)" before, it works... > > #recv gives you data as soon as there is data available, not necessarily > waiting for size bytes. > > You may want to buffer it in your ruby code. > > -- > vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407 > > ------=_Part_90_18499523.1193728970186--