I found what I thought should work perfectly at https://stackoverflow.com/questions/517219?tab=oldest#tab-top but, it did not work for me.
I have Ruby 1.9.1 installe
This may be due to some inherent problems with Rubys Timeout library. You can achieve this by directly accessing the underlying socket library and setting timeouts on the Socket. This article covers this in some depth, although it assumes *nix so you may have some issues with Windows, I'm not sure how similar the socket implementations are.