From: Frank Preiswerk Date: 2007-10-31T06:40:33+09:00 Subject: Re: Problem with socket.recv() ------=_Part_4078_13303428.1193780426765 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline First of all thanks a lot for all your inputs! Using read instead of recv indeed leads to blocking (like I want it to), at least when sending a bigger amount of data. But only receiving say 2 bytes using socket.read(2) somehow does not work, probably because I don't flush on the sender side. Compared to socket.revc, it does not skip immediately, but blocks until it times out, although the sender has sent the 2 bytes. It receives nothing in the end. I'll have to investigate a bit more. Seems like I did not do my homework in understanding how sockets work in detail (especially on the server side which I wrote in C++/QT). Thanks for the fruitful discussion, Frank On 10/30/07, Roger Pack wrote: > > Make sure you flush on the sending side, as it might not send it all > immediately (uses the nagle algorithm). > > 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... > > > > Any hints would be great. > > > > Thanks in advance, > > Frank > > -- > Posted via http://www.ruby-forum.com/. > > -- ======================= Frank Preiswerk Breitestrasse 50 4132 Muttenz phone: +41 61 463 80 30 mobile: +41 76 390 60 29 ------=_Part_4078_13303428.1193780426765--