I’ve this sniped that won’t work as I want it to.
def send(data)
socket = UDPSocket.open
Timeout::timeout(1.2) {
socket.send(data, 0, host, port)
resp = if select([socket], nil, nil, 3)
socket.recvfrom_nonblock(65536)
end
}
end
If the server (host) is to slow or doesn’t exists the example above will lock the current script.
It won’t timeout. Any idea why?
I’m using Ruby 1.9.2
It works as aspected when the server (host) exists.
The timeout block worked, it was the code that called
#sendthat was the problem.