How do you set the timeout for blocking operations on a Ruby socket?
The solution I found which appears to work is to use Timeout::timeout:
require 'timeout' ... begin timeout(5) do message, client_address = some_socket.recvfrom(1024) end rescue Timeout::Error puts "Timed out!" end
2.1m questions
2.1m answers
60 comments
57.0k users