Hi ..
I would like to suggest that Socket trap ETIMEDOUT and raise Timeout::Error
when a socket timeout occurs. This would allow the following:
begin
Timeout::timeout(to) do
t = TCPSocket.new(host,port)
···
#
# do socket stuff
#
t.close
end
rescue Timeout::Error => e
p "Timeout --> #{e}"
rescue Exception => e
p "Exception --> #{e}"
end
Rather than having a separate rescue clause.
Any thoughts?
--
-mark. (probertm @ acm dot org)
Hi ..
I would like to suggest that Socket trap ETIMEDOUT and raise Timeout::Error
when a socket timeout occurs.
I would oppose that.
These are two different error conditions: one is a socket error from the
kernel (the stack has failed to open a TCP connection), and the other is a
user-defined timeout. I'd certainly want to be able to distinguish them.
This would allow the following:
begin
Timeout::timeout(to) do
t = TCPSocket.new(host,port)
#
# do socket stuff
#
t.close
end
rescue Timeout::Error => e
p "Timeout --> #{e}"
rescue Exception => e
p "Exception --> #{e}"
end
Rather than having a separate rescue clause.
Any thoughts?
Assyming you want both types of exception to hit the "Timeout --> #{e}"
line, then all you need to do is
rescue Timeout::Error, Errno::ETIMEDOUT => e
p "Timeout --> #{e}"
Regards,
Brian.
···
On Wed, Oct 06, 2004 at 02:04:49PM +0900, Mark Probert wrote: