How to retry ftp.new?

Intermitently, we caught the ‘No route to host’ exception thrown by
FTP.new
with these lines of codes. I wonder if rety would help continue the
work.

ftp = Net::FTP.new(server)
ftp.login(@user, @passwd)
ftp.getbinaryfile(remoteFile, localFile, 1024)
ftp.close

/usr/lib/ruby/1.8/net/ftp.rb:159:in open' /usr/lib/ruby/1.8/net/ftp.rb:159:inopen_socket’
/usr/lib/ruby/1.8/net/ftp.rb:175:in connect' /usr/lib/ruby/1.8/monitor.rb:238:insynchronize’
/usr/lib/ruby/1.8/net/ftp.rb:174:in connect' /usr/lib/ruby/1.8/net/ftp.rb:136:ininitialize’
/home/testd/installer.rb:330:in `new’

So I come up with a ftpnew wrapper to help rety. But it doesn’t seem to
work.
Would someone be kindly help with a solution? Thanks very much. --sm

def ftpnew(server, retryCount=5, delayInSecs=10)
count = 0

    log("FTP.new(#{server})")
    loop do
       begin
          ftp = Net::FTP.new(server)
       rescue => exception
          count = count + 1
          if (count < retryCount)
             sleep delayInSecs
             retry
          else
             break
          end
       end
    end
    if (count >= retryCount)
       raise "ftpnewFailed: ftp: #{ftp}, #{exception}"
    else
       log "ftp newed ok "
    end
end