From: ara.t.howard@... Date: 2006-06-26T22:45:02+09:00 Subject: Re: Blocking read after select On Mon, 26 Jun 2006, Antonin AMAND wrote: > Hi, > > I've some trouble reading an IO after a select you are calling IO#read, which reads till eof. try something like buf = rsock.read 8192 and you should see data. typically one would have the client do somthing like bufsize = [buf.size].pack 'N' s.write bufsize s.write buf s.flush and, in the server, something like bufsize = s.read 4 bufsize = bufsize.unpack('N').first buf = s.read bufsize in otherwords, every message is preceded by it's length in a packet guarunteed to be 4 bytes big. you might start out with something like this (untested): class NetString < ::String def self.recv io buf = io.read 4 size = buf.unpack('N').first new(read(size)) end def self.send s, io s = s.to_s size = [s.size].pack('N') io.write size io.write s end def send io self.class.send self, io end end then you can do ns = NetString.recv socket or ns = NetString.new 'foobar' ns.send socket regards. -a -- suffering increases your inner strength. also, the wishing for suffering makes the suffering disappear. - h.h. the 14th dali lama