From: Robert Klemme Date: 2011-10-26T16:12:25+09:00 Subject: Re: How to correctly handle partial write in Ruby Sockets? 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/