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
1.4m articles
1.4m replys
5 comments
57.0k users