Google

# File rbot/ircbot.rb, line 241
  def mainloop
    socket_timeout = 0.2
    reconnect_wait = 5
    
    while true
      connect
      
      begin
        while true
          if @socket.select socket_timeout
            break unless reply = @socket.gets
            @client.process reply
          end
          @timer.tick
        end
      rescue => e
        puts "connection closed: #{e}"
      end
      
      puts "disconnected"
      @channels.clear
      @socket.clearq
      
      puts "waiting to reconnect"
      sleep reconnect_wait
    end
  end