# File lib/moped/connection.rb, line 114 def read with_connection do |socket| reply = Protocol::Reply.allocate data = read_data(socket, 36) response = data.unpack(REPLY_DECODE_STR) reply.length, reply.request_id, reply.response_to, reply.op_code, reply.flags, reply.cursor_id, reply.offset, reply.count = response if reply.count == 0 reply.documents = [] else sock_read = read_data(socket, reply.length - 36) buffer = StringIO.new(sock_read) reply.documents = reply.count.times.map do ::BSON::Document.from_bson(buffer) end end reply end end