From: Robert Klemme Date: 2011-10-06T23:36:10+09:00 Subject: Re: socket read, write when string found. On Thu, Oct 6, 2011 at 9:53 AM, Brian Candler wrote: > Almost certainly I'd say you want sock.read(n), not sock.gets, because > it doesn't look like the binary data you're reading ends with a newline > character. I would use #write and #read as default for binary protocols. If the protocol has some kind of delimiter sequence #gets might actually work for reading, because you can pass a parameter for the delimiter: irb(main):001:0> s = StringIO.new("fooXXbarXX") => # irb(main):002:0> s.gets 'XX' => "fooXX" irb(main):003:0> s.gets 'XX' => "barXX" irb(main):004:0> s.gets 'XX' => nil Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/