The [`IO.select`](http://www.ruby-doc.org/core-2.1.2/IO.html#method-c-select) method allows you to set timeouts. See "[Set socket timeout in Ruby via SO_RCVTIMEO socket option](http://stackoverflow.com/questions/9853516/set-socket-timeout-in-ruby-via-so-rcvtimeo-socket-option/12111120#12111120)."
– the Tin ManAug 18 '14 at 20:24