You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: socket.rb
    path of file: ./repos/excon/lib/excon
    
    the code of the file until where you have to start completion: # frozen_string_literal: true
require 'resolv'
    
    def read_nonblock(max_length)
      begin
        if @read_offset != 0 && @read_offset >= @read_buffer.length
          # Clear the buffer so we can test for emptiness below
          @read_buffer.clear
          # Reset the offset so it matches the length of the buffer when empty.
          @read_offset = 0
        end