From: Grigory Petrov Date: 2011-10-26T18:04:09+09:00 Subject: Re: How to correctly handle partial write in Ruby Sockets? Thanks for reply. I have checked source code for IO.write previously (Socket is inherited from BasicSocket that is inherited from IO, as i can see). It's a wrapper over POSIX write() function. And according to POSIX documentation, write() for sockets is exactly same as send() - just without flags. Why do you think write() will help? Maybe i miss something? Best, Grigory. On Wed, Oct 26, 2011 at 11:12 AM, Robert Klemme wrote: > On Wed, Oct 26, 2011 at 9:01 AM, Grigory Petrov wrote: >> TCP sockets are streams, not messages, so berkeley sockets send() >> function on some systems may send less data than required. Since Ruby >> Socket is very thin wrapper over berkeley sockets, AFAIK Socket#send >> will behave exactly like berkeley sockets send(). So what is the >> correct way to send a complete message via Ruby TCP sockets? In python >> it's a special function for that called sendall(). But in Ruby i need >> to manually write code like that: >> >> while (sent = sock.send( data, 0 ) < data.length do >>  data = data[ sent..-1 ] >> end > > In blocking mode you can simply do > > sock.write(data) > > Kind regards > > robert > > -- > remember.guy do |as, often| as.you_can - without end > http://blog.rubybestpractices.com/ > >