def chunked_read(io, timeout)
      begin
        loop do
          list = IO.select([io], [], [], @read_timeout)
          if (list.nil? || list.empty?)
            # IO.select tells us we timed out by giving us nil,
            # disconnect the non-talkative client.
            return
          end
          data = io.recv(4096)
          if (data == "")
            # If recv returns an empty string, that means the other
            # end closed the connection (either in response to our
            # end closing the write pipe or because they just felt
            # like it) so we close the connection from our end too.
            return
          end
          yield data
        end
      ensure
        io.close if (!io.closed?)
      end
    end
def chunked_read(io, timeout)
      begin
        loop do
          list = IO.select([io], [], [], @read_timeout)
          if (list.nil? || list.empty?)
            # IO.select tells us we timed out by giving us nil,
            # disconnect the non-talkative client.
            return
          end
          data = io.recv(4096)
          if (data == "")
            # If recv returns an empty string, that means the other
            # end closed the connection (either in response to our
            # end closing the write pipe or because they just felt
            # like it) so we close the connection from our end too.
            return
          end
          yield data
        end
      ensure
        io.close if (!io.closed?)
      end
    end
Reads from a connection, yielding chunks of data as it goes,
 until the connection closes. Once the connection closes, it returns.